diff options
author | Jeff McCune <jeff@puppetlabs.com> | 2011-06-03 11:56:02 -0700 |
---|---|---|
committer | Jeff McCune <jeff@puppetlabs.com> | 2011-06-03 11:56:02 -0700 |
commit | df2398b59c295c3e27cea5e41a76167a797139d4 (patch) | |
tree | 25450fdb191fa0cece08d9928edc3c92860a122a /spec/unit/puppet | |
parent | fdb175a6af75968a921ebdc8c008bbd5bbee3094 (diff) | |
download | puppet-stdlib-df2398b59c295c3e27cea5e41a76167a797139d4.tar.gz puppet-stdlib-df2398b59c295c3e27cea5e41a76167a797139d4.tar.bz2 |
Add additional tests to validate_bool() spec
Diffstat (limited to 'spec/unit/puppet')
-rw-r--r-- | spec/unit/puppet/parser/functions/validate_bool_spec.rb | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/spec/unit/puppet/parser/functions/validate_bool_spec.rb b/spec/unit/puppet/parser/functions/validate_bool_spec.rb index 19ecf23..e95c396 100644 --- a/spec/unit/puppet/parser/functions/validate_bool_spec.rb +++ b/spec/unit/puppet/parser/functions/validate_bool_spec.rb @@ -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 |