summaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorDan Bode <bodepd@gmail.com>2011-01-11 20:00:32 -0600
committerDan Bode <bodepd@gmail.com>2011-01-12 11:05:27 -0600
commit87c5c30fe8d2bbc31dabeb7383f5e5703a732bc5 (patch)
tree8fcdf4f8f87640237f2518b832ddbf28c3113c3e /spec
parent3f9f37984d1ac5f3ddcc83bf2b1facdb6df6dacd (diff)
downloadpuppet-87c5c30fe8d2bbc31dabeb7383f5e5703a732bc5.tar.gz
puppet-87c5c30fe8d2bbc31dabeb7383f5e5703a732bc5.tar.xz
puppet-87c5c30fe8d2bbc31dabeb7383f5e5703a732bc5.zip
(#5910) Improved logging when declared classes cannot be found:
Previously, when a class could not be found, it was displaying the same error message as when a resource type could not be found. This resulted in confusing error message: Invalid resource type class, when really it should display the name of the class that could not be found. My patch changes the error message to: Could not find declared class #{title}
Diffstat (limited to 'spec')
-rwxr-xr-xspec/unit/resource_spec.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/spec/unit/resource_spec.rb b/spec/unit/resource_spec.rb
index e65e8a13a..11ff904bb 100755
--- a/spec/unit/resource_spec.rb
+++ b/spec/unit/resource_spec.rb
@@ -98,6 +98,14 @@ describe Puppet::Resource do
lambda { Puppet::Resource.new("foo") }.should raise_error(ArgumentError)
end
+ it 'should fail if strict is set and type does not exist' do
+ lambda { Puppet::Resource.new('foo', 'title', {:strict=>true}) }.should raise_error(ArgumentError, 'Invalid resource type foo')
+ end
+
+ it 'should fail if strict is set and class does not exist' do
+ lambda { Puppet::Resource.new('Class', 'foo', {:strict=>true}) }.should raise_error(ArgumentError, 'Could not find declared class foo')
+ end
+
it "should fail if the title is a hash and the type is not a valid resource reference string" do
lambda { Puppet::Resource.new({:type => "foo", :title => "bar"}) }.should raise_error(ArgumentError,
'Puppet::Resource.new does not take a hash as the first argument. Did you mean ("foo", "bar") ?'