summaryrefslogtreecommitdiff
path: root/spec/unit/resource_collection_spec.rb
diff options
context:
space:
mode:
authorAdam Jacob <adam@hjksolutions.com>2008-04-08 00:57:17 -0700
committerAdam Jacob <adam@hjksolutions.com>2008-04-08 00:57:17 -0700
commit95eb1375f0647accd1b1a1569a7d0e3acc4a61e4 (patch)
treea58d6fddde4d7818dc33511ff8275c7b9f69f1c6 /spec/unit/resource_collection_spec.rb
parent434f25ba07b5c0c50baa1e15b14a945bba3c3c3b (diff)
downloadchef-95eb1375f0647accd1b1a1569a7d0e3acc4a61e4.tar.gz
Adding chef-solo command, config examples, Chef::Log class, Chef::Log::Formatter, Chef::Compile, and all the tests
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