From 20b6034574a134da939fe2300a4609d2b777da30 Mon Sep 17 00:00:00 2001 From: Clayton Coleman Date: Fri, 29 Mar 2013 12:37:13 -0400 Subject: [PATCH] Replace expect{}.should with expect{}.to in remaining spots, depend on webmock 1.8 --- rhc.gemspec | 2 +- spec/rhc/commands/account_spec.rb | 24 ++++++++++++------------ spec/rhc/commands/cartridge_spec.rb | 8 ++++---- spec/rhc/commands/git_clone_spec.rb | 6 +++--- spec/rhc/commands/server_spec.rb | 10 +++++----- spec/rhc/commands/setup_spec.rb | 10 +++++----- spec/rhc/commands/tail_spec.rb | 10 +++++----- spec/rhc/commands/threaddump_spec.rb | 6 +++--- spec/rhc/helpers_spec.rb | 10 +++++----- 9 files changed, 43 insertions(+), 43 deletions(-) diff --git a/rhc.gemspec b/rhc.gemspec index 81fac784c..2fe278f0a 100644 --- a/rhc.gemspec +++ b/rhc.gemspec @@ -37,7 +37,7 @@ Gem::Specification.new do |s| s.add_runtime_dependency 'httpclient', '>= 2.2' s.add_runtime_dependency 'open4' s.add_development_dependency 'rake', '>= 0.8.7', '<= 0.9.2.2' - s.add_development_dependency 'webmock', '>= 1.6' + s.add_development_dependency 'webmock', '>= 1.8' s.add_development_dependency 'rspec', '>= 2.8.0' s.add_development_dependency 'fakefs', '>= 0.4' s.add_development_dependency 'thor' diff --git a/spec/rhc/commands/account_spec.rb b/spec/rhc/commands/account_spec.rb index 359ff5fa1..a77c83a3a 100644 --- a/spec/rhc/commands/account_spec.rb +++ b/spec/rhc/commands/account_spec.rb @@ -21,7 +21,7 @@ it('should show the gear capabilities') { run_output.should =~ /Allowed Gear Sizes:\s*small/ } it('should show the consumed gears') { run_output.should =~ /Gears Used:\s*0/ } it('should show the maximum gears') { run_output.should =~ /Gears Allowed:\s*3/ } - it { expect { run }.should exit_with_code(0) } + it { expect { run }.to exit_with_code(0) } context 'with a free plan' do let(:user_plan_id){ 'free' } @@ -53,8 +53,8 @@ RHC::Auth::TokenStore.should_receive(:new).at_least(1).and_return(token_store) end - it("should clear the token cache"){ expect{ run }.should call(:clear).on(token_store) } - it("should exit with success"){ expect{ run }.should exit_with_code(0) } + it("should clear the token cache"){ expect{ run }.to call(:clear).on(token_store) } + it("should exit with success"){ expect{ run }.to exit_with_code(0) } it("should display a message"){ run_output.should match("All local sessions removed.") } context "when --all is requested" do @@ -62,7 +62,7 @@ context "if the server does not implement authorizations" do it("should display a message"){ run_output.should match(/Deleting all authorizations associated with your account.*not supported/) } - it("should exit with success"){ expect{ run }.should exit_with_code(0) } + it("should exit with success"){ expect{ run }.to exit_with_code(0) } end context "if the server implements authorizations" do @@ -70,7 +70,7 @@ before{ stub_delete_authorizations } it("should display a message"){ run_output.should match(/Deleting all authorizations associated with your account.*done/) } - it("should exit with success"){ expect{ run }.should exit_with_code(0) } + it("should exit with success"){ expect{ run }.to exit_with_code(0) } end end @@ -80,7 +80,7 @@ def user_auth; { :token => 'foo' }; end context "if the server does not implement authorizations" do it("should display a message"){ run_output.should match(/Ending session on server.*not supported/) } - it("should exit with success"){ expect{ run }.should exit_with_code(0) } + it("should exit with success"){ expect{ run }.to exit_with_code(0) } end context "if the server implements authorizations" do @@ -90,24 +90,24 @@ def user_auth; { :token => 'foo' }; end before{ stub_delete_authorization('foo') } it("should display a message"){ run_output.should match(/Ending session on server.*deleted/) } - it("should exit with success"){ expect{ run }.should exit_with_code(0) } - it("should clear the token cache"){ expect{ run }.should call(:clear).on(token_store) } + it("should exit with success"){ expect{ run }.to exit_with_code(0) } + it("should clear the token cache"){ expect{ run }.to call(:clear).on(token_store) } end context "if the server rejects the token" do before{ stub_request(:delete, mock_href('broker/rest/user/authorizations/foo', false)).to_return(:status => 401, :body => {}.to_json) } it("should display a message"){ run_output.should match(/Ending session on server.*already closed/) } - it("should exit with success"){ expect{ run }.should exit_with_code(0) } - it("should clear the token cache"){ expect{ run }.should call(:clear).on(token_store) } + it("should exit with success"){ expect{ run }.to exit_with_code(0) } + it("should clear the token cache"){ expect{ run }.to call(:clear).on(token_store) } end context "if the server returns an unexpected error" do before{ stub_request(:delete, mock_href('broker/rest/user/authorizations/foo', false)).to_return(:status => 500, :body => {}.to_json) } it("should display a message"){ run_output.should match(/Ending session on server.*The server did not respond/) } - it("should exit with success"){ expect{ run }.should exit_with_code(0) } - it("should clear the token cache"){ expect{ run }.should call(:clear).on(token_store) } + it("should exit with success"){ expect{ run }.to exit_with_code(0) } + it("should clear the token cache"){ expect{ run }.to call(:clear).on(token_store) } end end end diff --git a/spec/rhc/commands/cartridge_spec.rb b/spec/rhc/commands/cartridge_spec.rb index c6f992ae1..be865ceef 100644 --- a/spec/rhc/commands/cartridge_spec.rb +++ b/spec/rhc/commands/cartridge_spec.rb @@ -6,7 +6,7 @@ describe RHC::Commands::Cartridge do def exit_with_code_and_message(code, message = nil) - expect{ run }.should exit_with_code(code) + expect{ run }.to exit_with_code(code) run_output.should match(message) if message end @@ -50,7 +50,7 @@ def fail_with_code(code = 1) it{ run_output.should match /mock_standalone_cart\-2\s+web/ } it{ run_output.should match /mock_embedded_cart\-1\s+Mock1 Embedded Cart\s+addon/ } it{ run_output.should match /premium_cart\-1 \(\*\)\s+Premium Cart\s+web/ } - it{ expect{ run }.should exit_with_code(0) } + it{ expect{ run }.to exit_with_code(0) } context 'with verbose list' do let(:arguments){ ['cartridge', 'list', '--verbose'] } @@ -200,12 +200,12 @@ def fail_with_code(code = 1) end it "should remove cartridge" do @app.add_cartridge('mock_cart-1') - expect { run }.should exit_with_code(0) + expect { run }.to exit_with_code(0) # framework cart should be the only one listed @app.cartridges.length.should == 1 end it "should raise cartridge not found exception" do - expect { run }.should raise_error RHC::CartridgeNotFoundException + expect { run }.to raise_error RHC::CartridgeNotFoundException end end end diff --git a/spec/rhc/commands/git_clone_spec.rb b/spec/rhc/commands/git_clone_spec.rb index 2d369bfc4..300f5dbbb 100644 --- a/spec/rhc/commands/git_clone_spec.rb +++ b/spec/rhc/commands/git_clone_spec.rb @@ -42,7 +42,7 @@ end end - it { expect { run }.should exit_with_code(0) } + it { expect { run }.to exit_with_code(0) } it { run_output.should match("Cloned") } end @@ -65,14 +65,14 @@ FakeFS::FileSystem.find(hook)) end end - it { expect { run }.should exit_with_code(0) } + it { expect { run }.to exit_with_code(0) } it { run_output.should match("Copied") } end context "reports failure" do before{ @instance.stub(:git_clone_repo).and_raise(RHC::GitException) } - it { expect { run }.should exit_with_code(216) } + it { expect { run }.to exit_with_code(216) } it { run_output.should match("Git returned an error") } end end diff --git a/spec/rhc/commands/server_spec.rb b/spec/rhc/commands/server_spec.rb index a0a205f54..14cb6bd78 100644 --- a/spec/rhc/commands/server_spec.rb +++ b/spec/rhc/commands/server_spec.rb @@ -13,13 +13,13 @@ context 'when server refuses connection' do before { stub_request(:get, 'https://foo.com/broker/rest/api').with(&user_agent_header).with(&expect_authorization(:user => 'person')).to_raise(SocketError) } it('should output an error') { run_output.should =~ /Connected to foo.com.*Unable to connect to the server/m } - it { expect { run }.should exit_with_code(1) } + it { expect { run }.to exit_with_code(1) } end context 'when API is missing' do before { stub_request(:get, 'https://foo.com/broker/rest/api').with(&user_agent_header).with(&expect_authorization(:user => 'person')).to_return(:status => 404) } it('should output an error') { run_output.should =~ /Connected to foo.com.*server is not responding correctly/m } - it { expect { run }.should exit_with_code(1) } + it { expect { run }.to exit_with_code(1) } end context 'when API is at version 1.2' do @@ -27,7 +27,7 @@ rest_client.stub(:api_version_negotiated).and_return('1.2') end it('should output an error') { run_output.should =~ /Connected to foo.com.*Using API version 1.2/m } - it { expect { run }.should exit_with_code(0) } + it { expect { run }.to exit_with_code(0) } end end @@ -38,7 +38,7 @@ context 'when no issues' do before { stub_request(:get, 'https://openshift.redhat.com/app/status/status.json').with(&user_agent_header).to_return(:body => {'issues' => []}.to_json) } it('should output success') { run_output.should =~ /All systems running fine/ } - it { expect { run }.should exit_with_code(0) } + it { expect { run }.to exit_with_code(0) } end context 'when 1 issue' do @@ -55,7 +55,7 @@ }] }}]}.to_json) end - it { expect { run }.should exit_with_code(1) } + it { expect { run }.to exit_with_code(1) } it('should output message') { run_output.should =~ /1 open issue/ } it('should output title') { run_output.should =~ /Root cause/ } it('should contain update') { run_output.should =~ /Working on update/ } diff --git a/spec/rhc/commands/setup_spec.rb b/spec/rhc/commands/setup_spec.rb index b3353faed..b78e1b221 100644 --- a/spec/rhc/commands/setup_spec.rb +++ b/spec/rhc/commands/setup_spec.rb @@ -24,14 +24,14 @@ context 'when no issues' do it "should exit 0" do - expect { run }.should exit_with_code(0) + expect { run }.to exit_with_code(0) end end context 'when there is an issue' do it "should exit 1" do @wizard.stub!(:run).and_return(false) - expect { run }.should exit_with_code(1) + expect { run }.to exit_with_code(1) end end end @@ -72,7 +72,7 @@ let(:input) { ['', 'y', '', ''] } let!(:rest_client){ MockRestClient.new } - it("succeeds"){ FakeFS{ expect { run input }.should exit_with_code 0 } } + it("succeeds"){ FakeFS{ expect { run input }.to exit_with_code 0 } } it("the output includes debug output") do FakeFS{ run_output( input ).should match 'DEBUG' } end @@ -84,7 +84,7 @@ let(:input) { ['', 'y', '', ''] } let!(:rest_client){ MockRestClient.new } - it("succeeds"){ FakeFS{ expect { run input }.should exit_with_code 0 } } + it("succeeds"){ FakeFS{ expect { run input }.to exit_with_code 0 } } it("sets the user name to the value given by the command line") do FakeFS{ run_output( input ).should match 'test@test.foo' } end @@ -96,7 +96,7 @@ context 'help is run' do it "should display help" do @wizard.stub!(:run).and_return(true) - expect { run }.should exit_with_code(0) + expect { run }.to exit_with_code(0) end it('should output usage') { run_output.should match("Connects to an OpenShift server to get you started. Will") } end diff --git a/spec/rhc/commands/tail_spec.rb b/spec/rhc/commands/tail_spec.rb index 4dfa7f9f9..614044c17 100644 --- a/spec/rhc/commands/tail_spec.rb +++ b/spec/rhc/commands/tail_spec.rb @@ -17,7 +17,7 @@ context 'help is run' do it "should display help" do - expect { run }.should exit_with_code(0) + expect { run }.to exit_with_code(0) end it('should output usage') { run_output.should match("Usage: rhc tail") } end @@ -28,24 +28,24 @@ context 'when ssh connects' do before (:each) {Net::SSH.should_receive(:start).with('test.domain.com', 'user') } - it { expect { run }.should exit_with_code(0) } + it { expect { run }.to exit_with_code(0) } end context 'is run on an unreachable domain' do before (:each) {Net::SSH.should_receive(:start).and_raise(SocketError) } - it { expect { run }.should exit_with_code(1) } + it { expect { run }.to exit_with_code(1) } it { run_output.should =~ /The connection to test.domain.com failed: / } end context 'is refused' do before (:each) {Net::SSH.should_receive(:start).and_raise(Errno::ECONNREFUSED) } - it { expect { run }.should exit_with_code(1) } + it { expect { run }.to exit_with_code(1) } it { run_output.should =~ /The server test.domain.com refused a connection with user user/ } end context 'succeeds and exits on Interrupt' do before (:each) { rest_client.stub(:find_domain) { raise Interrupt } } - it { expect { run }.should raise_error(Interrupt) } + it { expect { run }.to raise_error(Interrupt) } end end end diff --git a/spec/rhc/commands/threaddump_spec.rb b/spec/rhc/commands/threaddump_spec.rb index e93d45ce6..a2bca1358 100644 --- a/spec/rhc/commands/threaddump_spec.rb +++ b/spec/rhc/commands/threaddump_spec.rb @@ -63,7 +63,7 @@ context 'help is run' do it "should display help" do - expect { run }.should exit_with_code(0) + expect { run }.to exit_with_code(0) end it('should output usage') { run_output.should match("Usage: rhc threaddump") } end @@ -71,14 +71,14 @@ describe 'threaddump' do let(:arguments) { ['threaddump', 'mock_app_0'] } - it { expect { run }.should exit_with_code(0) } + it { expect { run }.to exit_with_code(0) } it { run_output.should =~ /Application test thread dump complete/ } end describe 'threaddump no args' do let(:arguments) { ['threaddump'] } context 'args not supplied' do - it { expect { run }.should exit_with_code(1) } + it { expect { run }.to exit_with_code(1) } end end end diff --git a/spec/rhc/helpers_spec.rb b/spec/rhc/helpers_spec.rb index 9148f81f6..618202601 100644 --- a/spec/rhc/helpers_spec.rb +++ b/spec/rhc/helpers_spec.rb @@ -173,7 +173,7 @@ def config Class.new(Object){ include RHC::Helpers }.new end - it("should raise on config"){ expect{ subject.config }.should raise_error } + it("should raise on config"){ expect{ subject.config }.to raise_error } end context "with a bad timeout value" do @@ -341,7 +341,7 @@ def config let(:stderr){ 'fatal: error' } let(:exit_status){ 1 } - it { capture{ expect{ subject.git_clone_repo("url", "repo") }.should raise_error(RHC::GitException) } } + it { capture{ expect{ subject.git_clone_repo("url", "repo") }.to raise_error(RHC::GitException) } } it { capture_all{ subject.git_clone_repo("url", "repo") rescue nil }.should match("fake git clone") } it { capture_all{ subject.git_clone_repo("url", "repo") rescue nil }.should match("fatal: error") } end @@ -350,14 +350,14 @@ def config let(:stderr){ "fatal: destination path 'foo' already exists and is not an empty directory." } let(:exit_status){ 1 } - it { capture{ expect{ subject.git_clone_repo("url", "repo") }.should raise_error(RHC::GitDirectoryExists) } } + it { capture{ expect{ subject.git_clone_repo("url", "repo") }.to raise_error(RHC::GitDirectoryExists) } } end context "permission denied" do let(:stderr){ "Permission denied (publickey,gssapi-mic)." } let(:exit_status){ 1 } - it { capture{ expect{ subject.git_clone_repo("url", "repo") }.should raise_error(RHC::GitPermissionDenied) } } + it { capture{ expect{ subject.git_clone_repo("url", "repo") }.to raise_error(RHC::GitPermissionDenied) } } end end end @@ -587,7 +587,7 @@ def reset let(:cartridges){ [] } let(:find_cartridges){ [] } context "with a generic object" do - it { expect{ subject.send(:check_cartridges, 'foo', :from => cartridges) }.should raise_error(RHC::CartridgeNotFoundException, 'There are no cartridges that match \'foo\'.') } + it { expect{ subject.send(:check_cartridges, 'foo', :from => cartridges) }.to raise_error(RHC::CartridgeNotFoundException, 'There are no cartridges that match \'foo\'.') } end end describe '#web_carts_only' do