summaryrefslogtreecommitdiff
path: root/spec/unit/run_list_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/unit/run_list_spec.rb')
-rw-r--r--spec/unit/run_list_spec.rb110
1 files changed, 55 insertions, 55 deletions
diff --git a/spec/unit/run_list_spec.rb b/spec/unit/run_list_spec.rb
index cc7e29af0f..bf996de8c1 100644
--- a/spec/unit/run_list_spec.rb
+++ b/spec/unit/run_list_spec.rb
@@ -31,42 +31,42 @@ describe Chef::RunList do
describe "<<" do
it "should add a recipe to the run list and recipe list with the fully qualified name" do
@run_list << 'recipe[needy]'
- @run_list.should include('recipe[needy]')
- @run_list.recipes.should include("needy")
+ expect(@run_list).to include('recipe[needy]')
+ expect(@run_list.recipes).to include("needy")
end
it "should add a role to the run list and role list with the fully qualified name" do
@run_list << "role[woot]"
- @run_list.should include('role[woot]')
- @run_list.roles.should include('woot')
+ expect(@run_list).to include('role[woot]')
+ expect(@run_list.roles).to include('woot')
end
it "should accept recipes that are unqualified" do
@run_list << "needy"
- @run_list.should include('recipe[needy]')
- @run_list.recipes.include?('needy').should == true
+ expect(@run_list).to include('recipe[needy]')
+ expect(@run_list.recipes.include?('needy')).to eq(true)
end
it "should not allow duplicates" do
@run_list << "needy"
@run_list << "needy"
- @run_list.run_list.length.should == 1
- @run_list.recipes.length.should == 1
+ expect(@run_list.run_list.length).to eq(1)
+ expect(@run_list.recipes.length).to eq(1)
end
it "should allow two versions of a recipe" do
@run_list << "recipe[needy@0.2.0]"
@run_list << "recipe[needy@0.1.0]"
- @run_list.run_list.length.should == 2
- @run_list.recipes.length.should == 2
- @run_list.recipes.include?('needy').should == true
+ expect(@run_list.run_list.length).to eq(2)
+ expect(@run_list.recipes.length).to eq(2)
+ expect(@run_list.recipes.include?('needy')).to eq(true)
end
it "should not allow duplicate versions of a recipe" do
@run_list << "recipe[needy@0.2.0]"
@run_list << "recipe[needy@0.2.0]"
- @run_list.run_list.length.should == 1
- @run_list.recipes.length.should == 1
+ expect(@run_list.run_list.length).to eq(1)
+ expect(@run_list.recipes.length).to eq(1)
end
end
@@ -75,12 +75,12 @@ describe Chef::RunList do
# since full behavior is tested above.
it "should add a recipe to the run_list" do
@run_list.add 'recipe[needy]'
- @run_list.should include('recipe[needy]')
+ expect(@run_list).to include('recipe[needy]')
end
it "should add a role to the run_list" do
@run_list.add 'role[needy]'
- @run_list.should include('role[needy]')
+ expect(@run_list).to include('role[needy]')
end
end
@@ -89,43 +89,43 @@ describe Chef::RunList do
@run_list << "foo"
r = Chef::RunList.new
r << "foo"
- @run_list.should == r
+ expect(@run_list).to eq(r)
end
it "should believe a RunList is equal to an array named after it's members" do
@run_list << "foo"
@run_list << "baz"
- @run_list.should == [ "foo", "baz" ]
+ expect(@run_list).to eq([ "foo", "baz" ])
end
end
describe "empty?" do
it "should be emtpy if the run list has no members" do
- @run_list.empty?.should == true
+ expect(@run_list.empty?).to eq(true)
end
it "should not be empty if the run list has members" do
@run_list << "chromeo"
- @run_list.empty?.should == false
+ expect(@run_list.empty?).to eq(false)
end
end
describe "[]" do
it "should let you look up a member in the run list by position" do
@run_list << 'recipe[loulou]'
- @run_list[0].should == 'recipe[loulou]'
+ expect(@run_list[0]).to eq('recipe[loulou]')
end
end
describe "[]=" do
it "should let you set a member of the run list by position" do
@run_list[0] = 'recipe[loulou]'
- @run_list[0].should == 'recipe[loulou]'
+ expect(@run_list[0]).to eq('recipe[loulou]')
end
it "should properly expand a member of the run list given by position" do
@run_list[0] = 'loulou'
- @run_list[0].should == 'recipe[loulou]'
+ expect(@run_list[0]).to eq('recipe[loulou]')
end
end
@@ -135,8 +135,8 @@ describe Chef::RunList do
@run_list << "bar"
seen = Array.new
@run_list.each { |r| seen << r }
- seen.should be_include("recipe[foo]")
- seen.should be_include("recipe[bar]")
+ expect(seen).to be_include("recipe[foo]")
+ expect(seen).to be_include("recipe[bar]")
end
end
@@ -144,7 +144,7 @@ describe Chef::RunList do
it "should yield each members index to your block" do
to_add = [ "recipe[foo]", "recipe[bar]", "recipe[baz]" ]
to_add.each { |i| @run_list << i }
- @run_list.each_index { |i| @run_list[i].should == to_add[i] }
+ @run_list.each_index { |i| expect(@run_list[i]).to eq(to_add[i]) }
end
end
@@ -160,8 +160,8 @@ describe Chef::RunList do
@run_list << "chromeo"
list = %w{camp chairs snakes clowns}
@run_list.reset!(list)
- list.each { |i| @run_list.should be_include(i) }
- @run_list.include?("chromeo").should == false
+ list.each { |i| expect(@run_list).to be_include(i) }
+ expect(@run_list.include?("chromeo")).to eq(false)
end
end
@@ -173,9 +173,9 @@ describe Chef::RunList do
@role.default_attributes :one => :two
@role.override_attributes :three => :four
- Chef::Role.stub(:load).and_return(@role)
+ allow(Chef::Role).to receive(:load).and_return(@role)
@rest = double("Chef::REST", { :get_rest => @role, :url => "/" })
- Chef::REST.stub(:new).and_return(@rest)
+ allow(Chef::REST).to receive(:new).and_return(@rest)
@run_list << "role[stubby]"
@run_list << "kitty"
@@ -183,13 +183,13 @@ describe Chef::RunList do
describe "from disk" do
it "should load the role from disk" do
- Chef::Role.should_receive(:from_disk).with("stubby")
+ expect(Chef::Role).to receive(:from_disk).with("stubby")
@run_list.expand("_default", "disk")
end
it "should log a helpful error if the role is not available" do
- Chef::Role.stub(:from_disk).and_raise(Chef::Exceptions::RoleNotFound)
- Chef::Log.should_receive(:error).with("Role stubby (included by 'top level') is in the runlist but does not exist. Skipping expand.")
+ allow(Chef::Role).to receive(:from_disk).and_raise(Chef::Exceptions::RoleNotFound)
+ expect(Chef::Log).to receive(:error).with("Role stubby (included by 'top level') is in the runlist but does not exist. Skipping expand.")
@run_list.expand("_default", "disk")
end
end
@@ -198,11 +198,11 @@ describe Chef::RunList do
it "should load the role from the chef server" do
#@rest.should_receive(:get_rest).with("roles/stubby")
expansion = @run_list.expand("_default", "server")
- expansion.recipes.should == ['one', 'two', 'kitty']
+ expect(expansion.recipes).to eq(['one', 'two', 'kitty'])
end
it "should default to expanding from the server" do
- @rest.should_receive(:get_rest).with("roles/stubby")
+ expect(@rest).to receive(:get_rest).with("roles/stubby")
@run_list.expand("_default")
end
@@ -213,7 +213,7 @@ describe Chef::RunList do
it "expands the run list using the environment specific run list" do
expansion = @run_list.expand("production", "server")
- expansion.recipes.should == %w{one two five kitty}
+ expect(expansion.recipes).to eq(%w{one two five kitty})
end
describe "and multiply nested roles" do
@@ -233,13 +233,13 @@ describe Chef::RunList do
end
it "expands the run list using the specified environment for all nested roles" do
- Chef::REST.stub(:new).and_return(@multiple_rest_requests)
- @multiple_rest_requests.should_receive(:get_rest).with("roles/stubby").and_return(@role)
- @multiple_rest_requests.should_receive(:get_rest).with("roles/prod-base").and_return(@role_prod_base)
- @multiple_rest_requests.should_receive(:get_rest).with("roles/nested-deeper").and_return(@role_nested_deeper)
+ allow(Chef::REST).to receive(:new).and_return(@multiple_rest_requests)
+ expect(@multiple_rest_requests).to receive(:get_rest).with("roles/stubby").and_return(@role)
+ expect(@multiple_rest_requests).to receive(:get_rest).with("roles/prod-base").and_return(@role_prod_base)
+ expect(@multiple_rest_requests).to receive(:get_rest).with("roles/nested-deeper").and_return(@role_nested_deeper)
expansion = @run_list.expand("production", "server")
- expansion.recipes.should == %w{one two five prod-secret-sauce kitty}
+ expect(expansion.recipes).to eq(%w{one two five prod-secret-sauce kitty})
end
end
@@ -250,18 +250,18 @@ describe Chef::RunList do
it "should return the list of expanded recipes" do
expansion = @run_list.expand("_default")
- expansion.recipes[0].should == "one"
- expansion.recipes[1].should == "two"
+ expect(expansion.recipes[0]).to eq("one")
+ expect(expansion.recipes[1]).to eq("two")
end
it "should return the list of default attributes" do
expansion = @run_list.expand("_default")
- expansion.default_attrs[:one].should == :two
+ expect(expansion.default_attrs[:one]).to eq(:two)
end
it "should return the list of override attributes" do
expansion = @run_list.expand("_default")
- expansion.override_attrs[:three].should == :four
+ expect(expansion.override_attrs[:three]).to eq(:four)
end
it "should recurse into a child role" do
@@ -270,12 +270,12 @@ describe Chef::RunList do
dog.default_attributes :seven => :nine
dog.run_list "three"
@role.run_list << "role[dog]"
- Chef::Role.stub(:from_disk).with("stubby").and_return(@role)
- Chef::Role.stub(:from_disk).with("dog").and_return(dog)
+ allow(Chef::Role).to receive(:from_disk).with("stubby").and_return(@role)
+ allow(Chef::Role).to receive(:from_disk).with("dog").and_return(dog)
expansion = @run_list.expand("_default", 'disk')
- expansion.recipes[2].should == "three"
- expansion.default_attrs[:seven].should == :nine
+ expect(expansion.recipes[2]).to eq("three")
+ expect(expansion.default_attrs[:seven]).to eq(:nine)
end
it "should not recurse infinitely" do
@@ -284,13 +284,13 @@ describe Chef::RunList do
dog.default_attributes :seven => :nine
dog.run_list "role[dog]", "three"
@role.run_list << "role[dog]"
- Chef::Role.stub(:from_disk).with("stubby").and_return(@role)
- Chef::Role.should_receive(:from_disk).with("dog").once.and_return(dog)
+ allow(Chef::Role).to receive(:from_disk).with("stubby").and_return(@role)
+ expect(Chef::Role).to receive(:from_disk).with("dog").once.and_return(dog)
expansion = @run_list.expand("_default", 'disk')
- expansion.recipes[2].should == "three"
- expansion.recipes[3].should == "kitty"
- expansion.default_attrs[:seven].should == :nine
+ expect(expansion.recipes[2]).to eq("three")
+ expect(expansion.recipes[3]).to eq("kitty")
+ expect(expansion.default_attrs[:seven]).to eq(:nine)
end
end
@@ -300,11 +300,11 @@ describe Chef::RunList do
end
it "converts to an array of the string forms of its items" do
- @run_list.to_a.should == ["recipe[nagios::client]", "role[production]", "recipe[apache2]"]
+ expect(@run_list.to_a).to eq(["recipe[nagios::client]", "role[production]", "recipe[apache2]"])
end
it "converts to json by converting its array form" do
- Chef::JSONCompat.to_json(@run_list).should == Chef::JSONCompat.to_json(["recipe[nagios::client]", "role[production]", "recipe[apache2]"])
+ expect(Chef::JSONCompat.to_json(@run_list)).to eq(Chef::JSONCompat.to_json(["recipe[nagios::client]", "role[production]", "recipe[apache2]"]))
end
include_examples "to_json equalivent to Chef::JSONCompat.to_json" do