summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJay Mundrawala <jdmundrawala@gmail.com>2015-02-12 14:31:49 -0600
committerJay Mundrawala <jdmundrawala@gmail.com>2015-02-12 14:31:49 -0600
commitfad249bf39ce6b452184d23dc9905f7b27be7ab7 (patch)
tree5d85eeb6d179df4d6d2a826b8b1d4e7d7a709c4d
parent3d39aad53a8c0e17ee827ed4b3b7bad78674b2bc (diff)
parent499e8113d798f93b0205fc4a3d63fdb191d2afbe (diff)
downloadchef-fad249bf39ce6b452184d23dc9905f7b27be7ab7.tar.gz
Merge pull request #2903 from chef/lcg/fix-env-run-list-specs
rspec-3-ify all the env-run-list specs
-rw-r--r--spec/unit/knife/role_env_run_list_add_spec.rb112
-rw-r--r--spec/unit/knife/role_env_run_list_clear_spec.rb32
-rw-r--r--spec/unit/knife/role_env_run_list_remove_spec.rb44
-rw-r--r--spec/unit/knife/role_env_run_list_replace_spec.rb50
-rw-r--r--spec/unit/knife/role_env_run_list_set_spec.rb42
-rw-r--r--spec/unit/knife/role_run_list_add_spec.rb86
-rw-r--r--spec/unit/knife/role_run_list_clear_spec.rb18
-rw-r--r--spec/unit/knife/role_run_list_remove_spec.rb30
-rw-r--r--spec/unit/knife/role_run_list_replace_spec.rb42
-rw-r--r--spec/unit/knife/role_run_list_set_spec.rb28
10 files changed, 242 insertions, 242 deletions
diff --git a/spec/unit/knife/role_env_run_list_add_spec.rb b/spec/unit/knife/role_env_run_list_add_spec.rb
index 1e8ddfc1ca..f286d5fd0d 100644
--- a/spec/unit/knife/role_env_run_list_add_spec.rb
+++ b/spec/unit/knife/role_env_run_list_add_spec.rb
@@ -28,10 +28,10 @@ describe Chef::Knife::RoleEnvRunListAdd do
:after => nil
}
@knife.name_args = [ "will", "QA", "role[monkey]" ]
- @knife.stub!(:output).and_return(true)
+ allow(@knife).to receive(:output).and_return(true)
@role = Chef::Role.new()
- @role.stub!(:save).and_return(true)
- Chef::Role.stub!(:load).and_return(@role)
+ allow(@role).to receive(:save).and_return(true)
+ allow(Chef::Role).to receive(:load).and_return(@role)
end
describe "run" do
@@ -43,31 +43,31 @@ describe Chef::Knife::RoleEnvRunListAdd do
it "should have an empty default run list" do
@knife.run
- @role.run_list[0].should be_nil
+ expect(@role.run_list[0]).to be_nil
end
it "should have a QA environment" do
@knife.run
- @role.active_run_list_for('QA').should == 'QA'
+ expect(@role.active_run_list_for('QA')).to eq('QA')
end
it "should load the role named will" do
- Chef::Role.should_receive(:load).with("will")
+ expect(Chef::Role).to receive(:load).with("will")
@knife.run
end
it "should be able to add an environment specific run list" do
@knife.run
- @role.run_list_for('QA')[0].should == 'role[monkey]'
+ expect(@role.run_list_for('QA')[0]).to eq('role[monkey]')
end
it "should save the role" do
- @role.should_receive(:save)
+ expect(@role).to receive(:save)
@knife.run
end
it "should print the run list" do
- @knife.should_receive(:output).and_return(true)
+ expect(@knife).to receive(:output).and_return(true)
@knife.run
end
@@ -78,10 +78,10 @@ describe Chef::Knife::RoleEnvRunListAdd do
@knife.config[:after] = "role[acorns]"
@knife.name_args = [ "will", "QA", "role[pad]" ]
@knife.run
- @role.run_list_for("QA")[0].should be_nil
- @role.run_list[0].should == "role[acorns]"
- @role.run_list[1].should == "role[barn]"
- @role.run_list[2].should be_nil
+ expect(@role.run_list_for("QA")[0]).to be_nil
+ expect(@role.run_list[0]).to eq("role[acorns]")
+ expect(@role.run_list[1]).to eq("role[barn]")
+ expect(@role.run_list[2]).to be_nil
end
it "should add to the run list after the specified entries in the QA run list" do
@@ -96,14 +96,14 @@ describe Chef::Knife::RoleEnvRunListAdd do
@knife.name_args = [ "will", "QA", "role[pad]", "role[whackadoo]" ]
@knife.run
#The actual tests
- @role.run_list_for("QA")[0].should == "role[monkey]"
- @role.run_list_for("QA")[1].should == "role[pencil]"
- @role.run_list_for("QA")[2].should == "role[pad]"
- @role.run_list_for("QA")[3].should == "role[whackadoo]"
- @role.run_list_for("QA")[4].should == "role[pen]"
- @role.run_list[0].should == "role[acorns]"
- @role.run_list[1].should == "role[barn]"
- @role.run_list[2].should be_nil
+ expect(@role.run_list_for("QA")[0]).to eq("role[monkey]")
+ expect(@role.run_list_for("QA")[1]).to eq("role[pencil]")
+ expect(@role.run_list_for("QA")[2]).to eq("role[pad]")
+ expect(@role.run_list_for("QA")[3]).to eq("role[whackadoo]")
+ expect(@role.run_list_for("QA")[4]).to eq("role[pen]")
+ expect(@role.run_list[0]).to eq("role[acorns]")
+ expect(@role.run_list[1]).to eq("role[barn]")
+ expect(@role.run_list[2]).to be_nil
end
end
@@ -112,10 +112,10 @@ describe Chef::Knife::RoleEnvRunListAdd do
@knife.name_args = [ "will", "QA", "role[monkey],role[duck]" ]
@role.run_list_for("_default") << "role[acorns]"
@knife.run
- @role.run_list_for("QA")[0].should == "role[monkey]"
- @role.run_list_for("QA")[1].should == "role[duck]"
- @role.run_list[0].should == "role[acorns]"
- @role.run_list[1].should be_nil
+ expect(@role.run_list_for("QA")[0]).to eq("role[monkey]")
+ expect(@role.run_list_for("QA")[1]).to eq("role[duck]")
+ expect(@role.run_list[0]).to eq("role[acorns]")
+ expect(@role.run_list[1]).to be_nil
end
end
@@ -124,10 +124,10 @@ describe Chef::Knife::RoleEnvRunListAdd do
@knife.name_args = [ "will", "QA", "role[monkey], role[duck]" ]
@role.run_list_for("_default") << "role[acorns]"
@knife.run
- @role.run_list_for("QA")[0].should == "role[monkey]"
- @role.run_list_for("QA")[1].should == "role[duck]"
- @role.run_list[0].should == "role[acorns]"
- @role.run_list[1].should be_nil
+ expect(@role.run_list_for("QA")[0]).to eq("role[monkey]")
+ expect(@role.run_list_for("QA")[1]).to eq("role[duck]")
+ expect(@role.run_list[0]).to eq("role[acorns]")
+ expect(@role.run_list[1]).to be_nil
end
end
@@ -136,10 +136,10 @@ describe Chef::Knife::RoleEnvRunListAdd do
@knife.name_args = [ "will", "QA", "role[monkey]", "role[duck]" ]
@role.run_list_for("_default") << "role[acorns]"
@knife.run
- @role.run_list_for("QA")[0].should == "role[monkey]"
- @role.run_list_for("QA")[1].should == "role[duck]"
- @role.run_list[0].should == "role[acorns]"
- @role.run_list[1].should be_nil
+ expect(@role.run_list_for("QA")[0]).to eq("role[monkey]")
+ expect(@role.run_list_for("QA")[1]).to eq("role[duck]")
+ expect(@role.run_list[0]).to eq("role[acorns]")
+ expect(@role.run_list[1]).to be_nil
end
end
@@ -148,11 +148,11 @@ describe Chef::Knife::RoleEnvRunListAdd do
@knife.name_args = [ "will", "QA", "role[monkey]", "role[duck],recipe[bird::fly]" ]
@role.run_list_for("_default") << "role[acorns]"
@knife.run
- @role.run_list_for("QA")[0].should == "role[monkey]"
- @role.run_list_for("QA")[1].should == "role[duck]"
- @role.run_list_for("QA")[2].should == "recipe[bird::fly]"
- @role.run_list[0].should == "role[acorns]"
- @role.run_list[1].should be_nil
+ expect(@role.run_list_for("QA")[0]).to eq("role[monkey]")
+ expect(@role.run_list_for("QA")[1]).to eq("role[duck]")
+ expect(@role.run_list_for("QA")[2]).to eq("recipe[bird::fly]")
+ expect(@role.run_list[0]).to eq("role[acorns]")
+ expect(@role.run_list[1]).to be_nil
end
end
@@ -161,11 +161,11 @@ describe Chef::Knife::RoleEnvRunListAdd do
@knife.name_args = [ "will", "QA", "role[monkey]", "role[duck],recipe[bird::fly@1.1.3]" ]
@role.run_list_for("_default") << "role[acorns]"
@knife.run
- @role.run_list_for("QA")[0].should == "role[monkey]"
- @role.run_list_for("QA")[1].should == "role[duck]"
- @role.run_list_for("QA")[2].should == "recipe[bird::fly@1.1.3]"
- @role.run_list[0].should == "role[acorns]"
- @role.run_list[1].should be_nil
+ expect(@role.run_list_for("QA")[0]).to eq("role[monkey]")
+ expect(@role.run_list_for("QA")[1]).to eq("role[duck]")
+ expect(@role.run_list_for("QA")[2]).to eq("recipe[bird::fly@1.1.3]")
+ expect(@role.run_list[0]).to eq("role[acorns]")
+ expect(@role.run_list[1]).to be_nil
end
end
@@ -174,10 +174,10 @@ describe Chef::Knife::RoleEnvRunListAdd do
@role.run_list_for("_default") << "role[acorns]"
@knife.name_args = [ "will", "QA", "role[monkey]," ]
@knife.run
- @role.run_list_for("QA")[0].should == "role[monkey]"
- @role.run_list_for("QA")[1].should be_nil
- @role.run_list[0].should == "role[acorns]"
- @role.run_list[1].should be_nil
+ expect(@role.run_list_for("QA")[0]).to eq("role[monkey]")
+ expect(@role.run_list_for("QA")[1]).to be_nil
+ expect(@role.run_list[0]).to eq("role[acorns]")
+ expect(@role.run_list[1]).to be_nil
end
end
@@ -187,9 +187,9 @@ describe Chef::Knife::RoleEnvRunListAdd do
@knife.run
@knife.name_args = [ "will", "QA", "role[black]," ]
@knife.run
- @role.run_list_for("QA")[0].should == "role[blue]"
- @role.run_list_for("QA")[1].should == "role[black]"
- @role.run_list[0].should be_nil
+ expect(@role.run_list_for("QA")[0]).to eq("role[blue]")
+ expect(@role.run_list_for("QA")[1]).to eq("role[black]")
+ expect(@role.run_list[0]).to be_nil
end
end
@@ -204,12 +204,12 @@ describe Chef::Knife::RoleEnvRunListAdd do
@knife.run
@role.run_list_for("PRD") << "role[pen]"
- @role.run_list_for("QA")[0].should == "role[blue]"
- @role.run_list_for("PRD")[0].should == "role[ball]"
- @role.run_list_for("QA")[1].should == "role[walnuts]"
- @role.run_list_for("PRD")[1].should == "role[pen]"
- @role.run_list[0].should == "role[acorns]"
- @role.run_list[1].should be_nil
+ expect(@role.run_list_for("QA")[0]).to eq("role[blue]")
+ expect(@role.run_list_for("PRD")[0]).to eq("role[ball]")
+ expect(@role.run_list_for("QA")[1]).to eq("role[walnuts]")
+ expect(@role.run_list_for("PRD")[1]).to eq("role[pen]")
+ expect(@role.run_list[0]).to eq("role[acorns]")
+ expect(@role.run_list[1]).to be_nil
end
end
diff --git a/spec/unit/knife/role_env_run_list_clear_spec.rb b/spec/unit/knife/role_env_run_list_clear_spec.rb
index 39e57b1055..525376c358 100644
--- a/spec/unit/knife/role_env_run_list_clear_spec.rb
+++ b/spec/unit/knife/role_env_run_list_clear_spec.rb
@@ -31,14 +31,14 @@ describe Chef::Knife::RoleEnvRunListClear do
:print_after => nil
}
@knife.name_args = [ "will", "QA" ]
- @knife.stub!(:output).and_return(true)
+ allow(@knife).to receive(:output).and_return(true)
@role = Chef::Role.new()
@role.name("will")
- @role.stub!(:save).and_return(true)
+ allow(@role).to receive(:save).and_return(true)
- @knife.ui.stub!(:confirm).and_return(true)
- Chef::Role.stub!(:load).and_return(@role)
+ allow(@knife.ui).to receive(:confirm).and_return(true)
+ allow(Chef::Role).to receive(:load).and_return(@role)
end
@@ -53,24 +53,24 @@ describe Chef::Knife::RoleEnvRunListClear do
# end
it "should load the node" do
- Chef::Role.should_receive(:load).with("will").and_return(@role)
+ expect(Chef::Role).to receive(:load).with("will").and_return(@role)
@knife.run
end
it "should remove the item from the run list" do
@setup.run
@knife.run
- @role.run_list_for('QA')[0].should be_nil
- @role.run_list[0].should be_nil
+ expect(@role.run_list_for('QA')[0]).to be_nil
+ expect(@role.run_list[0]).to be_nil
end
it "should save the node" do
- @role.should_receive(:save).and_return(true)
+ expect(@role).to receive(:save).and_return(true)
@knife.run
end
it "should print the run list" do
- @knife.should_receive(:output).and_return(true)
+ expect(@knife).to receive(:output).and_return(true)
@knife.config[:print_after] = true
@setup.run
@knife.run
@@ -84,13 +84,13 @@ describe Chef::Knife::RoleEnvRunListClear do
@setup.run
@knife.name_args = [ 'will', 'QA' ]
@knife.run
- @role.run_list_for('QA')[0].should be_nil
- @role.run_list_for('PRD')[0].should == 'recipe[orange::chicken]'
- @role.run_list_for('PRD')[1].should == 'role[monkey]'
- @role.run_list_for('PRD')[2].should == 'recipe[duck::type]'
- @role.run_list_for('PRD')[3].should == 'role[person]'
- @role.run_list_for('PRD')[4].should == 'role[bird]'
- @role.run_list_for('PRD')[5].should == 'role[town]'
+ expect(@role.run_list_for('QA')[0]).to be_nil
+ expect(@role.run_list_for('PRD')[0]).to eq('recipe[orange::chicken]')
+ expect(@role.run_list_for('PRD')[1]).to eq('role[monkey]')
+ expect(@role.run_list_for('PRD')[2]).to eq('recipe[duck::type]')
+ expect(@role.run_list_for('PRD')[3]).to eq('role[person]')
+ expect(@role.run_list_for('PRD')[4]).to eq('role[bird]')
+ expect(@role.run_list_for('PRD')[5]).to eq('role[town]')
end
end
end
diff --git a/spec/unit/knife/role_env_run_list_remove_spec.rb b/spec/unit/knife/role_env_run_list_remove_spec.rb
index 53f0f76427..a15d0af691 100644
--- a/spec/unit/knife/role_env_run_list_remove_spec.rb
+++ b/spec/unit/knife/role_env_run_list_remove_spec.rb
@@ -31,14 +31,14 @@ describe Chef::Knife::RoleEnvRunListRemove do
:print_after => nil
}
@knife.name_args = [ "will", "QA", "role[monkey]" ]
- @knife.stub!(:output).and_return(true)
+ allow(@knife).to receive(:output).and_return(true)
@role = Chef::Role.new()
@role.name("will")
- @role.stub!(:save).and_return(true)
+ allow(@role).to receive(:save).and_return(true)
- @knife.ui.stub!(:confirm).and_return(true)
- Chef::Role.stub!(:load).and_return(@role)
+ allow(@knife.ui).to receive(:confirm).and_return(true)
+ allow(Chef::Role).to receive(:load).and_return(@role)
end
@@ -53,25 +53,25 @@ describe Chef::Knife::RoleEnvRunListRemove do
# end
it "should load the node" do
- Chef::Role.should_receive(:load).with("will").and_return(@role)
+ expect(Chef::Role).to receive(:load).with("will").and_return(@role)
@knife.run
end
it "should remove the item from the run list" do
@setup.run
@knife.run
- @role.run_list_for('QA')[0].should_not == 'role[monkey]'
- @role.run_list_for('QA')[0].should == 'role[person]'
- @role.run_list[0].should be_nil
+ expect(@role.run_list_for('QA')[0]).not_to eq('role[monkey]')
+ expect(@role.run_list_for('QA')[0]).to eq('role[person]')
+ expect(@role.run_list[0]).to be_nil
end
it "should save the node" do
- @role.should_receive(:save).and_return(true)
+ expect(@role).to receive(:save).and_return(true)
@knife.run
end
it "should print the run list" do
- @knife.should_receive(:output).and_return(true)
+ expect(@knife).to receive(:output).and_return(true)
@knife.config[:print_after] = true
@setup.run
@knife.run
@@ -87,18 +87,18 @@ describe Chef::Knife::RoleEnvRunListRemove do
@knife.run
@knife.name_args = [ 'will', 'QA', 'recipe[duck::type]' ]
@knife.run
- @role.run_list_for('QA').should_not include('role[monkey]')
- @role.run_list_for('QA').should_not include('recipe[duck::type]')
- @role.run_list_for('QA')[0].should == 'recipe[orange::chicken]'
- @role.run_list_for('QA')[1].should == 'role[person]'
- @role.run_list_for('QA')[2].should == 'role[bird]'
- @role.run_list_for('QA')[3].should == 'role[town]'
- @role.run_list_for('PRD')[0].should == 'recipe[orange::chicken]'
- @role.run_list_for('PRD')[1].should == 'role[monkey]'
- @role.run_list_for('PRD')[2].should == 'recipe[duck::type]'
- @role.run_list_for('PRD')[3].should == 'role[person]'
- @role.run_list_for('PRD')[4].should == 'role[bird]'
- @role.run_list_for('PRD')[5].should == 'role[town]'
+ expect(@role.run_list_for('QA')).not_to include('role[monkey]')
+ expect(@role.run_list_for('QA')).not_to include('recipe[duck::type]')
+ expect(@role.run_list_for('QA')[0]).to eq('recipe[orange::chicken]')
+ expect(@role.run_list_for('QA')[1]).to eq('role[person]')
+ expect(@role.run_list_for('QA')[2]).to eq('role[bird]')
+ expect(@role.run_list_for('QA')[3]).to eq('role[town]')
+ expect(@role.run_list_for('PRD')[0]).to eq('recipe[orange::chicken]')
+ expect(@role.run_list_for('PRD')[1]).to eq('role[monkey]')
+ expect(@role.run_list_for('PRD')[2]).to eq('recipe[duck::type]')
+ expect(@role.run_list_for('PRD')[3]).to eq('role[person]')
+ expect(@role.run_list_for('PRD')[4]).to eq('role[bird]')
+ expect(@role.run_list_for('PRD')[5]).to eq('role[town]')
end
end
end
diff --git a/spec/unit/knife/role_env_run_list_replace_spec.rb b/spec/unit/knife/role_env_run_list_replace_spec.rb
index 0978e3e566..ea48601b8d 100644
--- a/spec/unit/knife/role_env_run_list_replace_spec.rb
+++ b/spec/unit/knife/role_env_run_list_replace_spec.rb
@@ -31,14 +31,14 @@ describe Chef::Knife::RoleEnvRunListReplace do
:print_after => nil
}
@knife.name_args = [ "will", "QA", "role[dude]", "role[person]" ]
- @knife.stub!(:output).and_return(true)
+ allow(@knife).to receive(:output).and_return(true)
@role = Chef::Role.new()
@role.name("will")
- @role.stub!(:save).and_return(true)
+ allow(@role).to receive(:save).and_return(true)
- @knife.ui.stub!(:confirm).and_return(true)
- Chef::Role.stub!(:load).and_return(@role)
+ allow(@knife.ui).to receive(:confirm).and_return(true)
+ allow(Chef::Role).to receive(:load).and_return(@role)
end
@@ -53,25 +53,25 @@ describe Chef::Knife::RoleEnvRunListReplace do
# end
it "should load the node" do
- Chef::Role.should_receive(:load).with("will").and_return(@role)
+ expect(Chef::Role).to receive(:load).with("will").and_return(@role)
@knife.run
end
it "should remove the item from the run list" do
@setup.run
@knife.run
- @role.run_list_for('QA')[1].should_not == 'role[dude]'
- @role.run_list_for('QA')[1].should == 'role[person]'
- @role.run_list[0].should be_nil
+ expect(@role.run_list_for('QA')[1]).not_to eq('role[dude]')
+ expect(@role.run_list_for('QA')[1]).to eq('role[person]')
+ expect(@role.run_list[0]).to be_nil
end
it "should save the node" do
- @role.should_receive(:save).and_return(true)
+ expect(@role).to receive(:save).and_return(true)
@knife.run
end
it "should print the run list" do
- @knife.should_receive(:output).and_return(true)
+ expect(@knife).to receive(:output).and_return(true)
@knife.config[:print_after] = true
@setup.run
@knife.run
@@ -87,21 +87,21 @@ describe Chef::Knife::RoleEnvRunListReplace do
@knife.run
@knife.name_args = [ 'will', 'QA', 'recipe[duck::type]', 'recipe[duck::mallard]' ]
@knife.run
- @role.run_list_for('QA').should_not include('role[monkey]')
- @role.run_list_for('QA').should_not include('recipe[duck::type]')
- @role.run_list_for('QA')[0].should == 'recipe[orange::chicken]'
- @role.run_list_for('QA')[1].should == 'role[gibbon]'
- @role.run_list_for('QA')[2].should == 'recipe[duck::mallard]'
- @role.run_list_for('QA')[3].should == 'role[person]'
- @role.run_list_for('QA')[4].should == 'role[bird]'
- @role.run_list_for('QA')[5].should == 'role[town]'
- @role.run_list_for('PRD')[0].should == 'recipe[orange::chicken]'
- @role.run_list_for('PRD')[1].should == 'role[monkey]'
- @role.run_list_for('PRD')[2].should == 'recipe[duck::type]'
- @role.run_list_for('PRD')[3].should == 'role[person]'
- @role.run_list_for('PRD')[4].should == 'role[bird]'
- @role.run_list_for('PRD')[5].should == 'role[town]'
- @role.run_list[0].should be_nil
+ expect(@role.run_list_for('QA')).not_to include('role[monkey]')
+ expect(@role.run_list_for('QA')).not_to include('recipe[duck::type]')
+ expect(@role.run_list_for('QA')[0]).to eq('recipe[orange::chicken]')
+ expect(@role.run_list_for('QA')[1]).to eq('role[gibbon]')
+ expect(@role.run_list_for('QA')[2]).to eq('recipe[duck::mallard]')
+ expect(@role.run_list_for('QA')[3]).to eq('role[person]')
+ expect(@role.run_list_for('QA')[4]).to eq('role[bird]')
+ expect(@role.run_list_for('QA')[5]).to eq('role[town]')
+ expect(@role.run_list_for('PRD')[0]).to eq('recipe[orange::chicken]')
+ expect(@role.run_list_for('PRD')[1]).to eq('role[monkey]')
+ expect(@role.run_list_for('PRD')[2]).to eq('recipe[duck::type]')
+ expect(@role.run_list_for('PRD')[3]).to eq('role[person]')
+ expect(@role.run_list_for('PRD')[4]).to eq('role[bird]')
+ expect(@role.run_list_for('PRD')[5]).to eq('role[town]')
+ expect(@role.run_list[0]).to be_nil
end
end
end
diff --git a/spec/unit/knife/role_env_run_list_set_spec.rb b/spec/unit/knife/role_env_run_list_set_spec.rb
index 150579c0ab..f3abb86fcf 100644
--- a/spec/unit/knife/role_env_run_list_set_spec.rb
+++ b/spec/unit/knife/role_env_run_list_set_spec.rb
@@ -31,14 +31,14 @@ describe Chef::Knife::RoleEnvRunListSet do
:print_after => nil
}
@knife.name_args = [ "will", "QA", "role[owen]", "role[mauntel]" ]
- @knife.stub!(:output).and_return(true)
+ allow(@knife).to receive(:output).and_return(true)
@role = Chef::Role.new()
@role.name("will")
- @role.stub!(:save).and_return(true)
+ allow(@role).to receive(:save).and_return(true)
- @knife.ui.stub!(:confirm).and_return(true)
- Chef::Role.stub!(:load).and_return(@role)
+ allow(@knife.ui).to receive(:confirm).and_return(true)
+ allow(Chef::Role).to receive(:load).and_return(@role)
end
@@ -53,26 +53,26 @@ describe Chef::Knife::RoleEnvRunListSet do
# end
it "should load the node" do
- Chef::Role.should_receive(:load).with("will").and_return(@role)
+ expect(Chef::Role).to receive(:load).with("will").and_return(@role)
@knife.run
end
it "should replace all the items in the runlist with what is specified" do
@setup.run
@knife.run
- @role.run_list_for('QA')[0].should == "role[owen]"
- @role.run_list_for('QA')[1].should == "role[mauntel]"
- @role.run_list_for('QA')[2].should be_nil
- @role.run_list[0].should be_nil
+ expect(@role.run_list_for('QA')[0]).to eq("role[owen]")
+ expect(@role.run_list_for('QA')[1]).to eq("role[mauntel]")
+ expect(@role.run_list_for('QA')[2]).to be_nil
+ expect(@role.run_list[0]).to be_nil
end
it "should save the node" do
- @role.should_receive(:save).and_return(true)
+ expect(@role).to receive(:save).and_return(true)
@knife.run
end
it "should print the run list" do
- @knife.should_receive(:output).and_return(true)
+ expect(@knife).to receive(:output).and_return(true)
@knife.config[:print_after] = true
@setup.run
@knife.run
@@ -86,16 +86,16 @@ describe Chef::Knife::RoleEnvRunListSet do
@setup.run
@knife.name_args = [ "will", "QA", "role[coke]", "role[pepsi]" ]
@knife.run
- @role.run_list_for('QA')[0].should == "role[coke]"
- @role.run_list_for('QA')[1].should == "role[pepsi]"
- @role.run_list_for('QA')[2].should be_nil
- @role.run_list_for('PRD')[0].should == 'recipe[orange::chicken]'
- @role.run_list_for('PRD')[1].should == 'role[monkey]'
- @role.run_list_for('PRD')[2].should == 'recipe[duck::type]'
- @role.run_list_for('PRD')[3].should == 'role[person]'
- @role.run_list_for('PRD')[4].should == 'role[bird]'
- @role.run_list_for('PRD')[5].should == 'role[town]'
- @role.run_list[0].should be_nil
+ expect(@role.run_list_for('QA')[0]).to eq("role[coke]")
+ expect(@role.run_list_for('QA')[1]).to eq("role[pepsi]")
+ expect(@role.run_list_for('QA')[2]).to be_nil
+ expect(@role.run_list_for('PRD')[0]).to eq('recipe[orange::chicken]')
+ expect(@role.run_list_for('PRD')[1]).to eq('role[monkey]')
+ expect(@role.run_list_for('PRD')[2]).to eq('recipe[duck::type]')
+ expect(@role.run_list_for('PRD')[3]).to eq('role[person]')
+ expect(@role.run_list_for('PRD')[4]).to eq('role[bird]')
+ expect(@role.run_list_for('PRD')[5]).to eq('role[town]')
+ expect(@role.run_list[0]).to be_nil
end
end
end
diff --git a/spec/unit/knife/role_run_list_add_spec.rb b/spec/unit/knife/role_run_list_add_spec.rb
index 57e0eb0553..d61c114912 100644
--- a/spec/unit/knife/role_run_list_add_spec.rb
+++ b/spec/unit/knife/role_run_list_add_spec.rb
@@ -28,10 +28,10 @@ describe Chef::Knife::RoleRunListAdd do
:after => nil
}
@knife.name_args = [ "will", "role[monkey]" ]
- @knife.stub!(:output).and_return(true)
+ allow(@knife).to receive(:output).and_return(true)
@role = Chef::Role.new()
- @role.stub!(:save).and_return(true)
- Chef::Role.stub!(:load).and_return(@role)
+ allow(@role).to receive(:save).and_return(true)
+ allow(Chef::Role).to receive(:load).and_return(@role)
end
describe "run" do
@@ -43,21 +43,21 @@ describe Chef::Knife::RoleRunListAdd do
it "should have a run list with the monkey role" do
@knife.run
- @role.run_list[0].should == "role[monkey]"
+ expect(@role.run_list[0]).to eq("role[monkey]")
end
it "should load the role named will" do
- Chef::Role.should_receive(:load).with("will")
+ expect(Chef::Role).to receive(:load).with("will")
@knife.run
end
it "should save the role" do
- @role.should_receive(:save)
+ expect(@role).to receive(:save)
@knife.run
end
it "should print the run list" do
- @knife.should_receive(:output).and_return(true)
+ expect(@knife).to receive(:output).and_return(true)
@knife.run
end
@@ -68,9 +68,9 @@ describe Chef::Knife::RoleRunListAdd do
@knife.config[:after] = "role[tree]"
@knife.name_args = [ "will", "role[pad]" ]
@knife.run
- @role.run_list[0].should == "role[acorns]"
- @role.run_list[1].should == "role[barn]"
- @role.run_list[2].should be_nil
+ expect(@role.run_list[0]).to eq("role[acorns]")
+ expect(@role.run_list[1]).to eq("role[barn]")
+ expect(@role.run_list[2]).to be_nil
end
it "should add to the run list after the specified entries in the default run list" do
@@ -82,11 +82,11 @@ describe Chef::Knife::RoleRunListAdd do
@knife.name_args = [ "will", "role[pad]", "role[whackadoo]" ]
@knife.run
#The actual tests
- @role.run_list[0].should == "role[acorns]"
- @role.run_list[1].should == "role[pad]"
- @role.run_list[2].should == "role[whackadoo]"
- @role.run_list[3].should == "role[barn]"
- @role.run_list[4].should be_nil
+ expect(@role.run_list[0]).to eq("role[acorns]")
+ expect(@role.run_list[1]).to eq("role[pad]")
+ expect(@role.run_list[2]).to eq("role[whackadoo]")
+ expect(@role.run_list[3]).to eq("role[barn]")
+ expect(@role.run_list[4]).to be_nil
end
end
@@ -95,10 +95,10 @@ describe Chef::Knife::RoleRunListAdd do
@knife.name_args = [ "will", "role[monkey],role[duck]" ]
@role.run_list_for("_default") << "role[acorns]"
@knife.run
- @role.run_list[0].should == "role[acorns]"
- @role.run_list[1].should == "role[monkey]"
- @role.run_list[2].should == "role[duck]"
- @role.run_list[3].should be_nil
+ expect(@role.run_list[0]).to eq("role[acorns]")
+ expect(@role.run_list[1]).to eq("role[monkey]")
+ expect(@role.run_list[2]).to eq("role[duck]")
+ expect(@role.run_list[3]).to be_nil
end
end
@@ -107,10 +107,10 @@ describe Chef::Knife::RoleRunListAdd do
@knife.name_args = [ "will", "role[monkey], role[duck]" ]
@role.run_list_for("_default") << "role[acorns]"
@knife.run
- @role.run_list[0].should == "role[acorns]"
- @role.run_list[1].should == "role[monkey]"
- @role.run_list[2].should == "role[duck]"
- @role.run_list[3].should be_nil
+ expect(@role.run_list[0]).to eq("role[acorns]")
+ expect(@role.run_list[1]).to eq("role[monkey]")
+ expect(@role.run_list[2]).to eq("role[duck]")
+ expect(@role.run_list[3]).to be_nil
end
end
@@ -119,10 +119,10 @@ describe Chef::Knife::RoleRunListAdd do
@knife.name_args = [ "will", "role[monkey]", "role[duck]" ]
@role.run_list_for("_default") << "role[acorns]"
@knife.run
- @role.run_list[0].should == "role[acorns]"
- @role.run_list[1].should == "role[monkey]"
- @role.run_list[2].should == "role[duck]"
- @role.run_list[3].should be_nil
+ expect(@role.run_list[0]).to eq("role[acorns]")
+ expect(@role.run_list[1]).to eq("role[monkey]")
+ expect(@role.run_list[2]).to eq("role[duck]")
+ expect(@role.run_list[3]).to be_nil
end
end
@@ -131,11 +131,11 @@ describe Chef::Knife::RoleRunListAdd do
@knife.name_args = [ "will", "role[monkey]", "role[duck],recipe[bird::fly]" ]
@role.run_list_for("_default") << "role[acorns]"
@knife.run
- @role.run_list[0].should == "role[acorns]"
- @role.run_list[1].should == "role[monkey]"
- @role.run_list[2].should == "role[duck]"
- @role.run_list[3].should == "recipe[bird::fly]"
- @role.run_list[4].should be_nil
+ expect(@role.run_list[0]).to eq("role[acorns]")
+ expect(@role.run_list[1]).to eq("role[monkey]")
+ expect(@role.run_list[2]).to eq("role[duck]")
+ expect(@role.run_list[3]).to eq("recipe[bird::fly]")
+ expect(@role.run_list[4]).to be_nil
end
end
@@ -144,11 +144,11 @@ describe Chef::Knife::RoleRunListAdd do
@knife.name_args = [ "will", "role[monkey]", "role[duck],recipe[bird::fly@1.1.3]" ]
@role.run_list_for("_default") << "role[acorns]"
@knife.run
- @role.run_list[0].should == "role[acorns]"
- @role.run_list[1].should == "role[monkey]"
- @role.run_list[2].should == "role[duck]"
- @role.run_list[3].should == "recipe[bird::fly@1.1.3]"
- @role.run_list[4].should be_nil
+ expect(@role.run_list[0]).to eq("role[acorns]")
+ expect(@role.run_list[1]).to eq("role[monkey]")
+ expect(@role.run_list[2]).to eq("role[duck]")
+ expect(@role.run_list[3]).to eq("recipe[bird::fly@1.1.3]")
+ expect(@role.run_list[4]).to be_nil
end
end
@@ -157,9 +157,9 @@ describe Chef::Knife::RoleRunListAdd do
@role.run_list_for("_default") << "role[acorns]"
@knife.name_args = [ "will", "role[monkey]," ]
@knife.run
- @role.run_list[0].should == "role[acorns]"
- @role.run_list[1].should == "role[monkey]"
- @role.run_list[2].should be_nil
+ expect(@role.run_list[0]).to eq("role[acorns]")
+ expect(@role.run_list[1]).to eq("role[monkey]")
+ expect(@role.run_list[2]).to be_nil
end
end
@@ -169,9 +169,9 @@ describe Chef::Knife::RoleRunListAdd do
@knife.run
@knife.name_args = [ "will", "role[black]," ]
@knife.run
- @role.run_list[0].should == "role[blue]"
- @role.run_list[1].should == "role[black]"
- @role.run_list[2].should be_nil
+ expect(@role.run_list[0]).to eq("role[blue]")
+ expect(@role.run_list[1]).to eq("role[black]")
+ expect(@role.run_list[2]).to be_nil
end
end
diff --git a/spec/unit/knife/role_run_list_clear_spec.rb b/spec/unit/knife/role_run_list_clear_spec.rb
index 7ec8dce769..e5a6e18673 100644
--- a/spec/unit/knife/role_run_list_clear_spec.rb
+++ b/spec/unit/knife/role_run_list_clear_spec.rb
@@ -30,14 +30,14 @@ describe Chef::Knife::RoleRunListClear do
:print_after => nil
}
@knife.name_args = [ "will" ]
- @knife.stub!(:output).and_return(true)
+ allow(@knife).to receive(:output).and_return(true)
@role = Chef::Role.new()
@role.name("will")
- @role.stub!(:save).and_return(true)
+ allow(@role).to receive(:save).and_return(true)
- @knife.ui.stub!(:confirm).and_return(true)
- Chef::Role.stub!(:load).and_return(@role)
+ allow(@knife.ui).to receive(:confirm).and_return(true)
+ allow(Chef::Role).to receive(:load).and_return(@role)
end
@@ -52,23 +52,23 @@ describe Chef::Knife::RoleRunListClear do
# end
it "should load the node" do
- Chef::Role.should_receive(:load).with("will").and_return(@role)
+ expect(Chef::Role).to receive(:load).with("will").and_return(@role)
@knife.run
end
it "should remove the item from the run list" do
@setup.run
@knife.run
- @role.run_list[0].should be_nil
+ expect(@role.run_list[0]).to be_nil
end
it "should save the node" do
- @role.should_receive(:save).and_return(true)
+ expect(@role).to receive(:save).and_return(true)
@knife.run
end
it "should print the run list" do
- @knife.should_receive(:output).and_return(true)
+ expect(@knife).to receive(:output).and_return(true)
@knife.config[:print_after] = true
@setup.run
@knife.run
@@ -80,7 +80,7 @@ describe Chef::Knife::RoleRunListClear do
@setup.run
@knife.name_args = [ 'will' ]
@knife.run
- @role.run_list[0].should be_nil
+ expect(@role.run_list[0]).to be_nil
end
end
end
diff --git a/spec/unit/knife/role_run_list_remove_spec.rb b/spec/unit/knife/role_run_list_remove_spec.rb
index 0ff329e2eb..0f4adf253b 100644
--- a/spec/unit/knife/role_run_list_remove_spec.rb
+++ b/spec/unit/knife/role_run_list_remove_spec.rb
@@ -30,14 +30,14 @@ describe Chef::Knife::RoleRunListRemove do
:print_after => nil
}
@knife.name_args = [ "will", "role[monkey]" ]
- @knife.stub!(:output).and_return(true)
+ allow(@knife).to receive(:output).and_return(true)
@role = Chef::Role.new()
@role.name("will")
- @role.stub!(:save).and_return(true)
+ allow(@role).to receive(:save).and_return(true)
- @knife.ui.stub!(:confirm).and_return(true)
- Chef::Role.stub!(:load).and_return(@role)
+ allow(@knife.ui).to receive(:confirm).and_return(true)
+ allow(Chef::Role).to receive(:load).and_return(@role)
end
@@ -52,24 +52,24 @@ describe Chef::Knife::RoleRunListRemove do
# end
it "should load the node" do
- Chef::Role.should_receive(:load).with("will").and_return(@role)
+ expect(Chef::Role).to receive(:load).with("will").and_return(@role)
@knife.run
end
it "should remove the item from the run list" do
@setup.run
@knife.run
- @role.run_list[0].should == 'role[person]'
- @role.run_list[1].should be_nil
+ expect(@role.run_list[0]).to eq('role[person]')
+ expect(@role.run_list[1]).to be_nil
end
it "should save the node" do
- @role.should_receive(:save).and_return(true)
+ expect(@role).to receive(:save).and_return(true)
@knife.run
end
it "should print the run list" do
- @knife.should_receive(:output).and_return(true)
+ expect(@knife).to receive(:output).and_return(true)
@knife.config[:print_after] = true
@setup.run
@knife.run
@@ -83,12 +83,12 @@ describe Chef::Knife::RoleRunListRemove do
@knife.run
@knife.name_args = [ 'will', 'recipe[duck::type]' ]
@knife.run
- @role.run_list.should_not include('role[monkey]')
- @role.run_list.should_not include('recipe[duck::type]')
- @role.run_list[0].should == 'recipe[orange::chicken]'
- @role.run_list[1].should == 'role[person]'
- @role.run_list[2].should == 'role[bird]'
- @role.run_list[3].should == 'role[town]'
+ expect(@role.run_list).not_to include('role[monkey]')
+ expect(@role.run_list).not_to include('recipe[duck::type]')
+ expect(@role.run_list[0]).to eq('recipe[orange::chicken]')
+ expect(@role.run_list[1]).to eq('role[person]')
+ expect(@role.run_list[2]).to eq('role[bird]')
+ expect(@role.run_list[3]).to eq('role[town]')
end
end
end
diff --git a/spec/unit/knife/role_run_list_replace_spec.rb b/spec/unit/knife/role_run_list_replace_spec.rb
index 118a4316ba..2ff38f573c 100644
--- a/spec/unit/knife/role_run_list_replace_spec.rb
+++ b/spec/unit/knife/role_run_list_replace_spec.rb
@@ -30,14 +30,14 @@ describe Chef::Knife::RoleRunListReplace do
:print_after => nil
}
@knife.name_args = [ "will", "role[dude]", "role[person]" ]
- @knife.stub!(:output).and_return(true)
+ allow(@knife).to receive(:output).and_return(true)
@role = Chef::Role.new()
@role.name("will")
- @role.stub!(:save).and_return(true)
+ allow(@role).to receive(:save).and_return(true)
- @knife.ui.stub!(:confirm).and_return(true)
- Chef::Role.stub!(:load).and_return(@role)
+ allow(@knife.ui).to receive(:confirm).and_return(true)
+ allow(Chef::Role).to receive(:load).and_return(@role)
end
@@ -52,27 +52,27 @@ describe Chef::Knife::RoleRunListReplace do
# end
it "should load the node" do
- Chef::Role.should_receive(:load).with("will").and_return(@role)
+ expect(Chef::Role).to receive(:load).with("will").and_return(@role)
@knife.run
end
it "should remove the item from the run list" do
@setup.run
@knife.run
- @role.run_list[0].should == 'role[monkey]'
- @role.run_list[1].should_not == 'role[dude]'
- @role.run_list[1].should == 'role[person]'
- @role.run_list[2].should == 'role[fixer]'
- @role.run_list[3].should be_nil
+ expect(@role.run_list[0]).to eq('role[monkey]')
+ expect(@role.run_list[1]).not_to eq('role[dude]')
+ expect(@role.run_list[1]).to eq('role[person]')
+ expect(@role.run_list[2]).to eq('role[fixer]')
+ expect(@role.run_list[3]).to be_nil
end
it "should save the node" do
- @role.should_receive(:save).and_return(true)
+ expect(@role).to receive(:save).and_return(true)
@knife.run
end
it "should print the run list" do
- @knife.should_receive(:output).and_return(true)
+ expect(@knife).to receive(:output).and_return(true)
@knife.config[:print_after] = true
@setup.run
@knife.run
@@ -86,15 +86,15 @@ describe Chef::Knife::RoleRunListReplace do
@knife.run
@knife.name_args = [ 'will', 'recipe[duck::type]', 'recipe[duck::mallard]' ]
@knife.run
- @role.run_list.should_not include('role[monkey]')
- @role.run_list.should_not include('recipe[duck::type]')
- @role.run_list[0].should == 'recipe[orange::chicken]'
- @role.run_list[1].should == 'role[gibbon]'
- @role.run_list[2].should == 'recipe[duck::mallard]'
- @role.run_list[3].should == 'role[person]'
- @role.run_list[4].should == 'role[bird]'
- @role.run_list[5].should == 'role[town]'
- @role.run_list[6].should be_nil
+ expect(@role.run_list).not_to include('role[monkey]')
+ expect(@role.run_list).not_to include('recipe[duck::type]')
+ expect(@role.run_list[0]).to eq('recipe[orange::chicken]')
+ expect(@role.run_list[1]).to eq('role[gibbon]')
+ expect(@role.run_list[2]).to eq('recipe[duck::mallard]')
+ expect(@role.run_list[3]).to eq('role[person]')
+ expect(@role.run_list[4]).to eq('role[bird]')
+ expect(@role.run_list[5]).to eq('role[town]')
+ expect(@role.run_list[6]).to be_nil
end
end
end
diff --git a/spec/unit/knife/role_run_list_set_spec.rb b/spec/unit/knife/role_run_list_set_spec.rb
index 04362c4d0d..1350741f10 100644
--- a/spec/unit/knife/role_run_list_set_spec.rb
+++ b/spec/unit/knife/role_run_list_set_spec.rb
@@ -30,14 +30,14 @@ describe Chef::Knife::RoleRunListSet do
:print_after => nil
}
@knife.name_args = [ "will", "role[owen]", "role[mauntel]" ]
- @knife.stub!(:output).and_return(true)
+ allow(@knife).to receive(:output).and_return(true)
@role = Chef::Role.new()
@role.name("will")
- @role.stub!(:save).and_return(true)
+ allow(@role).to receive(:save).and_return(true)
- @knife.ui.stub!(:confirm).and_return(true)
- Chef::Role.stub!(:load).and_return(@role)
+ allow(@knife.ui).to receive(:confirm).and_return(true)
+ allow(Chef::Role).to receive(:load).and_return(@role)
end
@@ -52,25 +52,25 @@ describe Chef::Knife::RoleRunListSet do
# end
it "should load the node" do
- Chef::Role.should_receive(:load).with("will").and_return(@role)
+ expect(Chef::Role).to receive(:load).with("will").and_return(@role)
@knife.run
end
it "should replace all the items in the runlist with what is specified" do
@setup.run
@knife.run
- @role.run_list[0].should == "role[owen]"
- @role.run_list[1].should == "role[mauntel]"
- @role.run_list[2].should be_nil
+ expect(@role.run_list[0]).to eq("role[owen]")
+ expect(@role.run_list[1]).to eq("role[mauntel]")
+ expect(@role.run_list[2]).to be_nil
end
it "should save the node" do
- @role.should_receive(:save).and_return(true)
+ expect(@role).to receive(:save).and_return(true)
@knife.run
end
it "should print the run list" do
- @knife.should_receive(:output).and_return(true)
+ expect(@knife).to receive(:output).and_return(true)
@knife.config[:print_after] = true
@setup.run
@knife.run
@@ -82,10 +82,10 @@ describe Chef::Knife::RoleRunListSet do
@setup.run
@knife.name_args = [ "will", "role[coke]", "role[pepsi]" ]
@knife.run
- @role.run_list[0].should == "role[coke]"
- @role.run_list[1].should == "role[pepsi]"
- @role.run_list[2].should be_nil
- @role.run_list[3].should be_nil
+ expect(@role.run_list[0]).to eq("role[coke]")
+ expect(@role.run_list[1]).to eq("role[pepsi]")
+ expect(@role.run_list[2]).to be_nil
+ expect(@role.run_list[3]).to be_nil
end
end
end