diff options
author | Claire McQuin <claire@getchef.com> | 2014-10-29 15:14:22 -0700 |
---|---|---|
committer | Claire McQuin <claire@getchef.com> | 2014-10-29 15:59:04 -0700 |
commit | 5fed7a65a2f024d964ecf2de1bcf2911cf8a600c (patch) | |
tree | 14cc6968e4fe4fd2485c0211088b25c645a80a4b /spec/unit/knife/index_rebuild_spec.rb | |
parent | b92c309b0f1aa0837f76ab89d6c81c36076ceca9 (diff) | |
download | chef-5fed7a65a2f024d964ecf2de1bcf2911cf8a600c.tar.gz |
Update to RSpec 3.
Diffstat (limited to 'spec/unit/knife/index_rebuild_spec.rb')
-rw-r--r-- | spec/unit/knife/index_rebuild_spec.rb | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/spec/unit/knife/index_rebuild_spec.rb b/spec/unit/knife/index_rebuild_spec.rb index 3a8ec00651..6c3b60bd88 100644 --- a/spec/unit/knife/index_rebuild_spec.rb +++ b/spec/unit/knife/index_rebuild_spec.rb @@ -24,18 +24,18 @@ describe Chef::Knife::IndexRebuild do let(:rest_client){double(Chef::REST)} let(:stub_rest!) do - knife.should_receive(:rest).and_return(rest_client) + expect(knife).to receive(:rest).and_return(rest_client) end before :each do # This keeps the test output clean - knife.ui.stub(:stdout).and_return(StringIO.new) + allow(knife.ui).to receive(:stdout).and_return(StringIO.new) end context "#grab_api_info" do let(:http_not_found_response) do e = Net::HTTPNotFound.new("1.1", 404, "blah") - e.stub(:[]).with("x-ops-api-info").and_return(api_header_value) + allow(e).to receive(:[]).with("x-ops-api-info").and_return(api_header_value) e end @@ -45,20 +45,20 @@ describe Chef::Knife::IndexRebuild do before(:each) do stub_rest! - rest_client.stub(:get_rest).and_raise(http_server_exception) + allow(rest_client).to receive(:get_rest).and_raise(http_server_exception) end context "against a Chef 11 server" do let(:api_header_value){"flavor=osc;version=11.0.0;erchef=1.2.3"} it "retrieves API information" do - knife.grab_api_info.should == {"flavor" => "osc", "version" => "11.0.0", "erchef" => "1.2.3"} + expect(knife.grab_api_info).to eq({"flavor" => "osc", "version" => "11.0.0", "erchef" => "1.2.3"}) end end # Chef 11 context "against a Chef 10 server" do let(:api_header_value){nil} it "finds no API information" do - knife.grab_api_info.should == {} + expect(knife.grab_api_info).to eq({}) end end # Chef 10 end # grab_api_info @@ -66,18 +66,18 @@ describe Chef::Knife::IndexRebuild do context "#unsupported_version?" do context "with Chef 11 API metadata" do it "is unsupported" do - knife.unsupported_version?({"version" => "11.0.0", "flavor" => "osc", "erchef" => "1.2.3"}).should be_true + expect(knife.unsupported_version?({"version" => "11.0.0", "flavor" => "osc", "erchef" => "1.2.3"})).to be_truthy end it "only truly relies on the version being non-nil" do - knife.unsupported_version?({"version" => "1", "flavor" => "osc", "erchef" => "1.2.3"}).should be_true + expect(knife.unsupported_version?({"version" => "1", "flavor" => "osc", "erchef" => "1.2.3"})).to be_truthy end end context "with Chef 10 API metadata" do it "is supported" do # Chef 10 will have no metadata - knife.unsupported_version?({}).should be_false + expect(knife.unsupported_version?({})).to be_falsey end end end # unsupported_version? @@ -85,7 +85,7 @@ describe Chef::Knife::IndexRebuild do context "Simulating a 'knife index rebuild' run" do before :each do - knife.should_receive(:grab_api_info).and_return(api_info) + expect(knife).to receive(:grab_api_info).and_return(api_info) server_specific_stubs! end @@ -97,8 +97,8 @@ describe Chef::Knife::IndexRebuild do } end let(:server_specific_stubs!) do - knife.should_receive(:unsupported_server_message).with(api_info) - knife.should_receive(:exit).with(1) + expect(knife).to receive(:unsupported_server_message).with(api_info) + expect(knife).to receive(:exit).with(1) end it "should not be allowed" do @@ -110,11 +110,11 @@ describe Chef::Knife::IndexRebuild do let(:api_info){ {} } let(:server_specific_stubs!) do stub_rest! - rest_client.should_receive(:post_rest).with("/search/reindex", {}).and_return("representative output") - knife.should_not_receive(:unsupported_server_message) - knife.should_receive(:deprecated_server_message) - knife.should_receive(:nag) - knife.should_receive(:output).with("representative output") + expect(rest_client).to receive(:post_rest).with("/search/reindex", {}).and_return("representative output") + expect(knife).not_to receive(:unsupported_server_message) + expect(knife).to receive(:deprecated_server_message) + expect(knife).to receive(:nag) + expect(knife).to receive(:output).with("representative output") end it "should be allowed" do knife.run |