Skip to content

Commit

Permalink
Replace expect{}.should with expect{}.to in remaining spots, depend o…
Browse files Browse the repository at this point in the history
…n webmock 1.8
  • Loading branch information
smarterclayton committed Mar 29, 2013
1 parent 37a104d commit 20b6034
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 43 deletions.
2 changes: 1 addition & 1 deletion rhc.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
24 changes: 12 additions & 12 deletions spec/rhc/commands/account_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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' }
Expand Down Expand Up @@ -53,24 +53,24 @@
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
let(:arguments) { ['account', 'logout', '--all'] }

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
let(:supports_auth) { true }
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

Expand All @@ -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
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions spec/rhc/commands/cartridge_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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'] }
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions spec/rhc/commands/git_clone_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down
10 changes: 5 additions & 5 deletions spec/rhc/commands/server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,21 @@
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
before do
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

Expand All @@ -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
Expand All @@ -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/ }
Expand Down
10 changes: 5 additions & 5 deletions spec/rhc/commands/setup_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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 '[email protected]' }
end
Expand All @@ -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
Expand Down
10 changes: 5 additions & 5 deletions spec/rhc/commands/tail_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
6 changes: 3 additions & 3 deletions spec/rhc/commands/threaddump_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,22 +63,22 @@

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
end

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
10 changes: 5 additions & 5 deletions spec/rhc/helpers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 20b6034

Please sign in to comment.