Skip to content

Commit

Permalink
Add additional tests to validate_bool() spec
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeff McCune committed Jun 3, 2011
1 parent fdb175a commit df2398b
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions spec/unit/puppet/parser/functions/validate_bool_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,29 @@ def get_scope
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
Expand Down

0 comments on commit df2398b

Please sign in to comment.