]> gitweb.fluxo.info Git - puppet-stdlib.git/commitdiff
Add additional tests to validate_bool() spec
authorJeff McCune <jeff@puppetlabs.com>
Fri, 3 Jun 2011 18:56:02 +0000 (11:56 -0700)
committerJeff McCune <jeff@puppetlabs.com>
Fri, 3 Jun 2011 18:56:02 +0000 (11:56 -0700)
spec/unit/puppet/parser/functions/validate_bool_spec.rb

index 19ecf23626c7a9077dce718b1506da978778a4df..e95c396e9e9aca4a9fa2b28c0696cbcd9c1e0a1a 100644 (file)
@@ -21,21 +21,29 @@ describe Puppet::Parser::Functions.function(:validate_bool) do
   end
 
   describe 'when calling validate_bool from puppet' do
-    it "should validate true and false as bare words" do
-      Puppet[:code] = 'validate_bool(true)'
-      get_scope
-      @scope.compiler.compile
-    end
-    it "should not compile when false is a string" do
-      Puppet[:code] = 'validate_bool("false")'
-      get_scope
-      expect { @scope.compiler.compile }.should raise_error(Puppet::ParseError, /is not a boolean/)
+
+    %w{ true false }.each do |the_string|
+
+      it "should not compile when #{the_string} is a string" do
+        Puppet[:code] = "validate_bool('#{the_string}')"
+        get_scope
+        expect { @scope.compiler.compile }.should raise_error(Puppet::ParseError, /is not a boolean/)
+      end
+
+      it "should compile when #{the_string} is a bare word" do
+        Puppet[:code] = "validate_bool(#{the_string})"
+        get_scope
+        @scope.compiler.compile
+      end
+
     end
+
     it "should not compile when an arbitrary string is passed" do
       Puppet[:code] = 'validate_bool("jeff and dan are awesome")'
       get_scope
       expect { @scope.compiler.compile }.should raise_error(Puppet::ParseError, /is not a boolean/)
     end
+
     it "should not compile when no arguments are passed" do
       Puppet[:code] = 'validate_bool()'
       get_scope