summaryrefslogtreecommitdiff
path: root/spec/unit/resource_collection_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/unit/resource_collection_spec.rb')
-rw-r--r--spec/unit/resource_collection_spec.rb17
1 files changed, 16 insertions, 1 deletions
diff --git a/spec/unit/resource_collection_spec.rb b/spec/unit/resource_collection_spec.rb
index 10f7d43cde..10f251aaac 100644
--- a/spec/unit/resource_collection_spec.rb
+++ b/spec/unit/resource_collection_spec.rb
@@ -30,16 +30,26 @@ describe Chef::ResourceCollection do
@rc.should be_kind_of(Chef::ResourceCollection)
end
- it "should accept Chef::Resources" do
+ it "should accept Chef::Resources through [index]" do
lambda { @rc[0] = @resource }.should_not raise_error
lambda { @rc[0] = "string" }.should raise_error
end
+ it "should not accept duplicate resources [index]=" do
+ @rc[0] = @resource
+ lambda { @rc[1] = @resource }.should raise_error(ArgumentError)
+ end
+
it "should accept Chef::Resources through pushing" do
lambda { @rc.push(@resource) }.should_not raise_error
lambda { @rc.push("string") }.should raise_error
end
+ it "should not accept duplicate resources through pushing" do
+ lambda { @rc.push(@resource) }.should_not raise_error
+ lambda { @rc.push(@resource) }.should raise_error(ArgumentError)
+ end
+
it "should allow you to fetch Chef::Resources by position" do
@rc[0] = @resource
@rc[0].should eql(@resource)
@@ -49,6 +59,11 @@ describe Chef::ResourceCollection do
lambda { @rc << @resource }.should_not raise_error
end
+ it "should not accept duplicate resources through the << operator" do
+ lambda { @rc << @resource }.should_not raise_error
+ lambda { @rc << @resource }.should raise_error(ArgumentError)
+ end
+
it "should allow you to iterate over every resource in the collection" do
load_up_resources
results = Array.new