summaryrefslogtreecommitdiff
path: root/spec/unit/resource_collection_spec.rb
diff options
context:
space:
mode:
authortyler-ball <tyleraball@gmail.com>2014-10-17 08:30:53 -0500
committertyler-ball <tyleraball@gmail.com>2014-10-17 08:30:53 -0500
commit9323a77206955327fef2f17a42ca5e66c864cb26 (patch)
treea02afc15ce5340d5a10906e5d6868f4b26f12f0f /spec/unit/resource_collection_spec.rb
parentb4adfb4cee189f2d3fdc534a24077269616cdd28 (diff)
downloadchef-9323a77206955327fef2f17a42ca5e66c864cb26.tar.gz
Cleaning up based on review comments
Diffstat (limited to 'spec/unit/resource_collection_spec.rb')
-rw-r--r--spec/unit/resource_collection_spec.rb17
1 files changed, 13 insertions, 4 deletions
diff --git a/spec/unit/resource_collection_spec.rb b/spec/unit/resource_collection_spec.rb
index 631e3730d8..81a203af6f 100644
--- a/spec/unit/resource_collection_spec.rb
+++ b/spec/unit/resource_collection_spec.rb
@@ -26,6 +26,10 @@ describe Chef::ResourceCollection do
@resource = Chef::Resource::ZenMaster.new("makoto")
end
+ it "should throw an error when calling a non-delegated method" do
+ expect { @rc.not_a_method }.to raise_error(NoMethodError)
+ end
+
describe "initialize" do
it "should return a Chef::ResourceCollection" do
@rc.should be_kind_of(Chef::ResourceCollection)
@@ -35,7 +39,7 @@ describe Chef::ResourceCollection do
describe "[]" do
it "should accept Chef::Resources through [index]" do
lambda { @rc[0] = @resource }.should_not raise_error
- lambda { @rc[0] = "string" }.should raise_error
+ lambda { @rc[0] = "string" }.should raise_error(ArgumentError)
end
it "should allow you to fetch Chef::Resources by position" do
@@ -47,7 +51,7 @@ describe Chef::ResourceCollection do
describe "push" do
it "should accept Chef::Resources through pushing" do
lambda { @rc.push(@resource) }.should_not raise_error
- lambda { @rc.push("string") }.should raise_error
+ lambda { @rc.push("string") }.should raise_error(ArgumentError)
end
end
@@ -60,7 +64,12 @@ describe Chef::ResourceCollection do
describe "insert" do
it "should accept only Chef::Resources" do
lambda { @rc.insert(@resource) }.should_not raise_error
- lambda { @rc.insert("string") }.should raise_error
+ lambda { @rc.insert("string") }.should raise_error(ArgumentError)
+ end
+
+ it "should accept named arguments in any order" do
+ @rc.insert(@resource, at_location:0, instance_name:'foo', resource_type:'bar')
+ expect(@rc[0]).to eq(@resource)
end
it "should append resources to the end of the collection when not executing a run" do
@@ -92,7 +101,7 @@ describe Chef::ResourceCollection do
it "should accept only Chef::Resources" do
lambda { @rc.insert_at(0, @resource, @resource) }.should_not raise_error
lambda { @rc.insert_at(0, "string") }.should raise_error
- lambda { @rc.insert_at(0, @resource, "string") }.should raise_error
+ lambda { @rc.insert_at(0, @resource, "string") }.should raise_error(ArgumentError)
end
it "should toss an error if it receives a bad index" do