diff options
| author | Daniel Pittman <daniel@puppetlabs.com> | 2011-03-21 15:44:43 -0700 |
|---|---|---|
| committer | Daniel Pittman <daniel@puppetlabs.com> | 2011-03-21 15:44:43 -0700 |
| commit | 23f4ff338949e085e42d778809a97f39be021da9 (patch) | |
| tree | 96a76e3df09413b2e7b7a442460aa71007c3946b /spec/unit | |
| parent | 9f379b641c05d7e25b4ae92ee449ca66512eff90 (diff) | |
| parent | 072becf6b51cb359d18b30d7eb01391f641dd840 (diff) | |
| download | puppet-23f4ff338949e085e42d778809a97f39be021da9.tar.gz puppet-23f4ff338949e085e42d778809a97f39be021da9.tar.xz puppet-23f4ff338949e085e42d778809a97f39be021da9.zip | |
Merge branch 'bug/master/6806-improve-error-checking-and-testing-of-interface-naming'
Diffstat (limited to 'spec/unit')
| -rwxr-xr-x[-rw-r--r--] | spec/unit/interface_spec.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/spec/unit/interface_spec.rb b/spec/unit/interface_spec.rb index 4b6fd117f..cfa0111f6 100644..100755 --- a/spec/unit/interface_spec.rb +++ b/spec/unit/interface_spec.rb @@ -92,4 +92,31 @@ describe Puppet::Interface do end it "should be able to load all actions in all search paths" + + describe "#constantize" do + faulty = [1, "#foo", "$bar", "sturm und drang", :"sturm und drang"] + valid = { + "foo" => "Foo", + :foo => "Foo", + "foo_bar" => "FooBar", + :foo_bar => "FooBar", + "foo-bar" => "FooBar", + :"foo-bar" => "FooBar", + } + + valid.each do |input, expect| + it "should map '#{input}' to '#{expect}'" do + result = Puppet::Interface.constantize(input) + result.should be_a String + result.to_s.should == expect + end + end + + faulty.each do |input| + it "should fail when presented with #{input.inspect} (#{input.class})" do + expect { Puppet::Interface.constantize(input) }. + should raise_error ArgumentError, /not a valid interface name/ + end + end + end end |
