summaryrefslogtreecommitdiff
path: root/spec/unit/resource_collection_spec.rb
diff options
context:
space:
mode:
authordanielsdeleo <dan@opscode.com>2013-04-26 10:40:37 -0700
committerBryan McLellan <btm@opscode.com>2013-05-30 09:06:51 -0700
commit22f434166352974a371c404a84b62f46118d67a6 (patch)
treee36896af4b97ca705b056d96f45e2b5591166129 /spec/unit/resource_collection_spec.rb
parent16e6c3c0bc62bc2a447b361757c689d4990c3523 (diff)
downloadchef-22f434166352974a371c404a84b62f46118d67a6.tar.gz
[CHEF-4135] Cleanup whitespace in resource collection spec
Diffstat (limited to 'spec/unit/resource_collection_spec.rb')
-rw-r--r--spec/unit/resource_collection_spec.rb64
1 files changed, 32 insertions, 32 deletions
diff --git a/spec/unit/resource_collection_spec.rb b/spec/unit/resource_collection_spec.rb
index 909ba71e00..d75d3927a4 100644
--- a/spec/unit/resource_collection_spec.rb
+++ b/spec/unit/resource_collection_spec.rb
@@ -7,9 +7,9 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
-#
+#
# http://www.apache.org/licenses/LICENSE-2.0
-#
+#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,49 +20,49 @@
require 'spec_helper'
describe Chef::ResourceCollection do
-
+
before(:each) do
@rc = Chef::ResourceCollection.new()
@resource = Chef::Resource::ZenMaster.new("makoto")
end
-
+
describe "initialize" do
it "should return a Chef::ResourceCollection" do
@rc.should be_kind_of(Chef::ResourceCollection)
end
end
-
+
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
end
-
+
it "should allow you to fetch Chef::Resources by position" do
@rc[0] = @resource
@rc[0].should eql(@resource)
end
end
-
+
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
end
end
-
+
describe "<<" do
it "should accept the << operator" do
lambda { @rc << @resource }.should_not raise_error
end
end
-
- describe "insert" 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
end
-
+
it "should append resources to the end of the collection when not executing a run" do
zmr = Chef::Resource::ZenMaster.new("there is no spoon")
@rc.insert(@resource)
@@ -70,18 +70,18 @@ describe Chef::ResourceCollection do
@rc[0].should eql(@resource)
@rc[1].should eql(zmr)
end
-
+
it "should insert resources to the middle of the collection if called while executing a run" do
resource_to_inject = Chef::Resource::ZenMaster.new("there is no spoon")
zmr = Chef::Resource::ZenMaster.new("morpheus")
dummy = Chef::Resource::ZenMaster.new("keanu reeves")
@rc.insert(zmr)
@rc.insert(dummy)
-
+
@rc.execute_each_resource do |resource|
@rc.insert(resource_to_inject) if resource == zmr
end
-
+
@rc[0].should eql(zmr)
@rc[1].should eql(resource_to_inject)
@rc[2].should eql(dummy)
@@ -92,7 +92,7 @@ describe Chef::ResourceCollection do
it "should allow you to iterate over every resource in the collection" do
load_up_resources
results = Array.new
- lambda {
+ lambda {
@rc.each do |r|
results << r.name
end
@@ -109,15 +109,15 @@ describe Chef::ResourceCollection do
end
end
end
-
+
describe "each_index" do
it "should allow you to iterate over every resource by index" do
load_up_resources
results = Array.new
- lambda {
+ lambda {
@rc.each_index do |i|
results << @rc[i].name
- end
+ end
}.should_not raise_error()
results.each_index do |i|
case i
@@ -131,7 +131,7 @@ describe Chef::ResourceCollection do
end
end
end
-
+
describe "lookup" do
it "should allow you to find resources by name via lookup" do
zmr = Chef::Resource::ZenMaster.new("dog")
@@ -141,21 +141,21 @@ describe Chef::ResourceCollection do
zmr = Chef::Resource::ZenMaster.new("cat")
@rc[0] = zmr
@rc.lookup(zmr).should eql(zmr)
-
+
zmr = Chef::Resource::ZenMaster.new("monkey")
@rc.push(zmr)
@rc.lookup(zmr).should eql(zmr)
end
-
+
it "should raise an exception if you send something strange to lookup" do
lambda { @rc.lookup(:symbol) }.should raise_error(ArgumentError)
end
-
+
it "should raise an exception if it cannot find a resource with lookup" do
lambda { @rc.lookup("zen_master[dog]") }.should raise_error(Chef::Exceptions::ResourceNotFound)
end
end
-
+
describe "resources" do
it "should find a resource by symbol and name (:zen_master => monkey)" do
@@ -195,11 +195,11 @@ describe Chef::ResourceCollection do
results.length.should eql(2)
check_by_names(results, "monkey", "something")
end
-
+
it "should raise an exception if you pass a bad name to resources" do
- lambda { @rc.resources("michael jackson") }.should raise_error(ArgumentError)
+ lambda { @rc.resources("michael jackson") }.should raise_error(ArgumentError)
end
-
+
it "should raise an exception if you pass something other than a string or hash to resource" do
lambda { @rc.resources([Array.new]) }.should raise_error(ArgumentError)
end
@@ -209,7 +209,7 @@ describe Chef::ResourceCollection do
end
end
-
+
describe "to_json" do
it "should serialize to json" do
json = @rc.to_json
@@ -217,7 +217,7 @@ describe Chef::ResourceCollection do
json.should =~ /instance_vars/
end
end
-
+
describe "self.from_json" do
it "should deserialize itself from json" do
@rc << @resource
@@ -227,13 +227,13 @@ describe Chef::ResourceCollection do
s_rc[0].name.should eql(@resource.name)
end
end
-
+
describe "provides access to the raw resources array" do
it "returns the resources via the all_resources method" do
@rc.all_resources.should equal(@rc.instance_variable_get(:@resources))
end
end
-
+
describe "provides access to stepable iterator" do
it "returns the iterator object" do
@rc.instance_variable_set(:@iterator, :fooboar)
@@ -246,12 +246,12 @@ describe Chef::ResourceCollection do
results.detect{ |res| res.name == res_name }.should_not eql(nil)
end
end
-
+
def load_up_resources
%w{dog cat monkey}.each do |n|
@rc << Chef::Resource::ZenMaster.new(n)
end
@rc << Chef::Resource::File.new("something")
end
-
+
end