Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Upgrade spec tests to passing, fix RSpec2 syntax errors, ensure rando…

…mized tests pass correctly

Make randomization the default.
  • Loading branch information...
commit 37a104d9526f5ac2a9d38072f658c31ec660cf6f 1 parent 4b43d44
@smarterclayton smarterclayton authored
View
1  .rspec
@@ -0,0 +1 @@
+--color --order random
View
2  features/README.md
@@ -179,7 +179,7 @@ doesn't exist.
Given "a demo directory exists or is created" do
begin
Given "the demo directory exists"
- rescue Spec::Expectations::ExpectationNotMetError
+ rescue RSpec::Expectations::ExpectationNotMetError
Then "create the demo directory"
end
end
View
6 features/support/assumptions.rb
@@ -9,7 +9,7 @@
begin
step 'the key "key1" is shown'
step 'the output includes the key information for "key1"'
- rescue Spec::Expectations::ExpectationNotMetError
+ rescue RSpec::Expectations::ExpectationNotMetError
step 'a new SSH key "key1.pub" is added as "key1"'
end
end
@@ -27,7 +27,7 @@
retried = false
begin
step "the #{type} cartridge should be #{status}"
- rescue Spec::Expectations::ExpectationNotMetError
+ rescue RSpec::Expectations::ExpectationNotMetError
step "the #{type} cartridge is #{cmd}"
(retried = true && retry) unless retried
end
@@ -43,7 +43,7 @@
begin
step "the application should #{before}"
- rescue Spec::Expectations::ExpectationNotMetError
+ rescue RSpec::Expectations::ExpectationNotMetError
step "the application is #{after}"
end
end
View
14 features/support/env.rb
@@ -1,5 +1,19 @@
$: << File.expand_path(File.join(File.dirname(__FILE__), "../lib"))
+begin
+ require 'rspec/expectations'
+ World(RSpec::Matchers)
+rescue
+ puts "Require RSpec >= 2"
+ exit 1
+end
+
+if File.exist?("/etc/fedora-release")
+ $target_os = "Fedora"
+else
+ $target_os = "RHEL"
+end
+
require 'rhc/coverage_helper'
SimpleCov.at_exit{ SimpleCov.result.format! } if defined? SimpleCov
View
2  rhc.gemspec
@@ -38,7 +38,7 @@ Gem::Specification.new do |s|
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 'rspec', '~> 1.3'
+ s.add_development_dependency 'rspec', '>= 2.8.0'
s.add_development_dependency 'fakefs', '>= 0.4'
s.add_development_dependency 'thor'
s.add_development_dependency 'cucumber'
View
4 spec/rest_spec_helper.rb
@@ -4,7 +4,7 @@
require 'rhc/exceptions'
require 'base64'
-Spec::Matchers.define :have_same_attributes_as do |expected|
+RSpec::Matchers.define :have_same_attributes_as do |expected|
match do |actual|
(actual.instance_variables == expected.instance_variables) &&
(actual.instance_variables.map { |i| instance_variable_get(i) } ==
@@ -26,6 +26,6 @@ module RestSpecHelper
include RHC::Rest::Mock
end
-Spec::Runner.configure do |configuration|
+RSpec.configure do |configuration|
include(RestSpecHelper)
end
View
44 spec/rhc/commands/alias_spec.rb
@@ -99,7 +99,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 alias <command> <application> <alias> [--namespace namespace]") }
end
@@ -110,7 +110,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 alias add <application> <alias> [--namespace namespace]") }
end
@@ -121,7 +121,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 alias remove <application> <alias> [--namespace namespace]") }
end
@@ -132,7 +132,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 alias update-cert <application> <alias> --certificate FILE --private-key FILE [--passphrase passphrase]") }
end
@@ -143,7 +143,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 alias delete-cert <application> <alias>") }
end
@@ -154,7 +154,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 alias list <application>") }
end
@@ -162,7 +162,7 @@
describe 'add alias' do
let(:arguments) { ['alias', 'add', 'mock_app_0', 'www.foo.bar' ] }
- it { expect { run }.should exit_with_code(0) }
+ it { expect { run }.to exit_with_code(0) }
it { run_output.should =~ /Alias 'www.foo.bar' has been added/m }
end
@@ -172,7 +172,7 @@
end
context 'remove alias successfully' do
let(:arguments) { ['alias', 'remove', 'mock_app_0', 'www.foo.bar' ] }
- it { expect { run }.should exit_with_code(0) }
+ it { expect { run }.to exit_with_code(0) }
it { run_output.should =~ /Alias 'www.foo.bar' has been removed/m }
end
context 'remove alias with server api <= 1.3' do
@@ -180,7 +180,7 @@
before do
rest_client.stub(:api_version_negotiated).and_return(1.3)
end
- it { expect { run }.should exit_with_code(0) }
+ it { expect { run }.to exit_with_code(0) }
it { run_output.should =~ /Alias 'www.foo.bar' has been removed/m }
end
end
@@ -193,28 +193,28 @@
let(:arguments) { ['alias', 'update-cert', 'mock_app_0', 'www.foo.bar',
'--certificate', File.expand_path('../../assets/cert.crt', __FILE__),
'--private-key', File.expand_path('../../assets/cert_key_rsa', __FILE__) ] }
- it { expect { run }.should exit_with_code(0) }
+ it { expect { run }.to exit_with_code(0) }
it { run_output.should =~ /SSL certificate successfully added/m }
end
context 'cert file not found' do
let(:arguments) { ['alias', 'update-cert', 'mock_app_0', 'www.foo.bar',
'--certificate', File.expand_path('../../assets/nothing.foo', __FILE__),
'--private-key', File.expand_path('../../assets/cert_key_rsa', __FILE__) ] }
- it { expect { run }.should exit_with_code(1) }
+ it { expect { run }.to exit_with_code(1) }
it { run_output.should =~ /Certificate file not found/m }
end
context 'private key file not found' do
let(:arguments) { ['alias', 'update-cert', 'mock_app_0', 'www.foo.bar',
'--certificate', File.expand_path('../../assets/cert.crt', __FILE__),
'--private-key', File.expand_path('../../assets/nothing.foo', __FILE__) ] }
- it { expect { run }.should exit_with_code(1) }
+ it { expect { run }.to exit_with_code(1) }
it { run_output.should =~ /Private key file not found/m }
end
context 'not existing certificate alias' do
let(:arguments) { ['alias', 'update-cert', 'mock_app_0', 'www.unicorns.com',
'--certificate', File.expand_path('../../assets/cert.crt', __FILE__),
'--private-key', File.expand_path('../../assets/cert_key_rsa', __FILE__) ] }
- it { expect { run }.should exit_with_code(156) }
+ it { expect { run }.to exit_with_code(156) }
it { run_output.should =~ /Alias www.unicorns.com can't be found in application/m }
end
context 'fails if server does not support' do
@@ -224,21 +224,21 @@
before do
rest_client.stub(:api_version_negotiated).and_return(1.3)
end
- it { expect { run }.should exit_with_code(1) }
+ it { expect { run }.to exit_with_code(1) }
it { run_output.should =~ /The server does not support SSL certificates for custom aliases/m }
end
context 'invalid certificate file (empty)' do
let(:arguments) { ['alias', 'update-cert', 'mock_app_0', 'www.foo.bar',
'--certificate', File.expand_path('../../assets/empty.txt', __FILE__),
'--private-key', File.expand_path('../../assets/cert_key_rsa', __FILE__) ] }
- it { expect { run }.should exit_with_code(1) }
+ it { expect { run }.to exit_with_code(1) }
it { run_output.should =~ /Invalid certificate file/m }
end
context 'invalid private key file (empty)' do
let(:arguments) { ['alias', 'update-cert', 'mock_app_0', 'www.foo.bar',
'--certificate', File.expand_path('../../assets/cert.crt', __FILE__),
'--private-key', File.expand_path('../../assets/empty.txt', __FILE__) ] }
- it { expect { run }.should exit_with_code(1) }
+ it { expect { run }.to exit_with_code(1) }
it { run_output.should =~ /Invalid private key file/m }
end
end
@@ -249,12 +249,12 @@
end
context 'delete existing certificate' do
let(:arguments) { ['alias', 'delete-cert', 'mock_app_0', 'www.foo.bar', '--confirm'] }
- it { expect { run }.should exit_with_code(0) }
+ it { expect { run }.to exit_with_code(0) }
it { run_output.should =~ /SSL certificate successfully deleted/m }
end
context 'delete not existing certificate' do
let(:arguments) { ['alias', 'delete-cert', 'mock_app_0', 'www.unicorns.com', '--confirm'] }
- it { expect { run }.should exit_with_code(156) }
+ it { expect { run }.to exit_with_code(156) }
it { run_output.should =~ /Alias www.unicorns.com can't be found in application mock_app_0/m }
end
context 'fails if server does not support' do
@@ -262,7 +262,7 @@
before do
rest_client.stub(:api_version_negotiated).and_return(1.3)
end
- it { expect { run }.should exit_with_code(1) }
+ it { expect { run }.to exit_with_code(1) }
it { run_output.should =~ /The server does not support SSL certificates for custom aliases/m }
end
end
@@ -273,14 +273,14 @@
end
context 'list app with existing certificate' do
let(:arguments) { ['alias', 'list', 'mock_app_0'] }
- it { expect { run }.should exit_with_code(0) }
+ it { expect { run }.to exit_with_code(0) }
it { run_output.should =~ /Has Certificate?/m }
it { run_output.should =~ /Certificate Added/m }
it { run_output.should =~ /www.foo.bar/m }
end
context 'list app without certificates' do
let(:arguments) { ['alias', 'list', 'mock_app_1'] }
- it { expect { run }.should exit_with_code(0) }
+ it { expect { run }.to exit_with_code(0) }
it { run_output.should =~ /No aliases associated with the application mock_app_1/m }
end
context 'simple list is server does not support ssl certs' do
@@ -288,7 +288,7 @@
before do
rest_client.stub(:api_version_negotiated).and_return(1.3)
end
- it { expect { run }.should exit_with_code(0) }
+ it { expect { run }.to exit_with_code(0) }
it { run_output.should =~ /no/m }
it { run_output.should =~ /-/m }
it { run_output.should =~ /www.foo.bar/m }
View
52 spec/rhc/commands/app_spec.rb
@@ -10,8 +10,8 @@
FakeFS.activate!
FakeFS::FileSystem.clear
user_config
- RHC::Helpers::remove_const(:MAX_RETRIES) rescue nil
- RHC::Helpers::const_set(:MAX_RETRIES, 3)
+ RHC::Helpers.send(:remove_const, :MAX_RETRIES) rescue nil
+ RHC::Helpers.const_set(:MAX_RETRIES, 3)
@instance = RHC::Commands::App.new
RHC::Commands::App.stub(:new) do
@instance.stub(:git_config_get) { "" }
@@ -62,7 +62,7 @@
context 'when run with a valid cart' do
let(:arguments) { ['app', 'create', 'app1', 'mock_standalone_cart-1', '--noprompt', '--timeout', '10', '--config', 'test.conf', '-l', 'test@test.foo', '-p', 'password'] }
- it { expect { run }.should exit_with_code(0) }
+ it { expect { run }.to exit_with_code(0) }
it { run_output.should match("Success") }
it { run_output.should match("Cartridges: mock_standalone_cart-1\n") }
end
@@ -75,13 +75,13 @@
resolver.should_receive(:getaddress).with('app1-mockdomain.fake.foo').and_raise(ArgumentError)
end
- it { expect { run }.should exit_with_code(0) }
+ it { expect { run }.to exit_with_code(0) }
it { run_output.should match("Success") }
end
context 'when run with multiple carts' do
let(:arguments) { ['app', 'create', 'app1', 'mock_standalone_cart-1', 'mock_cart-1', '--noprompt', '-p', 'password'] }
- it { expect { run }.should exit_with_code(0) }
+ it { expect { run }.to exit_with_code(0) }
it { run_output.should match("Success") }
it { run_output.should match("Cartridges: mock_standalone_cart-1, mock_cart-1\n") }
after{ rest_client.domains.first.applications.first.cartridges.find{ |c| c.name == 'mock_cart-1' }.should be_true }
@@ -89,7 +89,7 @@
context 'when run with a git url' do
let(:arguments) { ['app', 'create', 'app1', 'mock_standalone_cart-1', '--from', 'git://url', '--noprompt', '-p', 'password'] }
- it { expect { run }.should exit_with_code(0) }
+ it { expect { run }.to exit_with_code(0) }
it { run_output.should match("Success") }
it { run_output.should match("Source Code: git://url\n") }
it { run_output.should match("Initial Git URL: git://url\n") }
@@ -106,7 +106,7 @@
end
context 'with trace' do
let(:arguments) { ['app', 'create', 'app1', 'nomatch_cart', '--noprompt', '--config', 'test.conf', '-l', 'test@test.foo', '-p', 'password', '--trace'] }
- it { expect { run }.should raise_error(RHC::CartridgeNotFoundException, "There are no cartridges that match 'nomatch_cart'.") }
+ it { expect { run }.to raise_error(RHC::CartridgeNotFoundException, "There are no cartridges that match 'nomatch_cart'.") }
end
end
@@ -119,7 +119,7 @@
context 'multiple web matches' do
let(:arguments) { ['app', 'create', 'app1', 'mock_standalone_cart', '--trace', '--noprompt'] }
- it { expect { run }.should raise_error(RHC::MultipleCartridgesException) }
+ it { expect { run }.to raise_error(RHC::MultipleCartridgesException) }
end
context 'when only a single cart can match' do
let(:arguments) { ['app', 'create', 'app1', 'unique', '--trace', '--noprompt'] }
@@ -135,15 +135,15 @@
end
context 'when I pick only embedded carts' do
let(:arguments) { ['app', 'create', 'app1', 'mock_cart', '--trace', '--noprompt'] }
- it { expect { run }.should raise_error(RHC::CartridgeNotFoundException, /Every application needs a web cartridge/) }
+ it { expect { run }.to raise_error(RHC::CartridgeNotFoundException, /Every application needs a web cartridge/) }
end
context 'when I pick multiple embedded carts' do
let(:arguments) { ['app', 'create', 'app1', 'unique_standalone', 'mock_cart', '--trace', '--noprompt'] }
- it { expect { run }.should raise_error(RHC::MultipleCartridgesException, /There are multiple cartridges matching 'mock_cart'/) }
+ it { expect { run }.to raise_error(RHC::MultipleCartridgesException, /There are multiple cartridges matching 'mock_cart'/) }
end
context 'when I pick multiple standalone carts' do
let(:arguments) { ['app', 'create', 'app1', 'unique_standalone', 'mock_standalone_cart', '--trace', '--noprompt'] }
- it { expect { run }.should raise_error(RHC::MultipleCartridgesException, /You must select only a single web cart/) }
+ it { expect { run }.to raise_error(RHC::MultipleCartridgesException, /You must select only a single web cart/) }
end
end
@@ -156,7 +156,7 @@
end
it "should create a jenkins app and a regular app with an embedded jenkins client" do
#puts run_output
- expect { run }.should exit_with_code(0)
+ expect { run }.to exit_with_code(0)
jenkins_app = rest_client.find_application(@domain.id,"jenkins")
jenkins_app.cartridges[0].name.should == "jenkins-1.4"
app = rest_client.find_application(@domain.id,"app1")
@@ -172,7 +172,7 @@
before(:each) do
domain = rest_client.add_domain("mockdomain")
end
- it { expect { run }.should_not raise_error(ArgumentError, /The --no-dns option can't be used in conjunction with --enable-jenkins/) }
+ it { expect { run }.to_not raise_error(ArgumentError, /The --no-dns option can't be used in conjunction with --enable-jenkins/) }
end
end
@@ -183,7 +183,7 @@
before(:each) do
domain = rest_client.add_domain("mockdomain")
end
- it { expect { run }.should raise_error(ArgumentError, /You have named both your main application and your Jenkins application/) }
+ it { expect { run }.to raise_error(ArgumentError, /You have named both your main application and your Jenkins application/) }
end
end
@@ -196,9 +196,9 @@
@domain.add_application("jenkins", "jenkins-1.4")
end
it "should use existing jenkins" do
- expect { run }.should exit_with_code(0)
- expect { rest_client.find_application(@domain.id,"jenkins") }.should_not raise_error
- expect { rest_client.find_application(@domain.id,"jenkins2") }.should raise_error(RHC::Rest::ApplicationNotFoundException)
+ expect { run }.to exit_with_code(0)
+ expect { rest_client.find_application(@domain.id,"jenkins") }.to_not raise_error
+ expect { rest_client.find_application(@domain.id,"jenkins2") }.to raise_error(RHC::Rest::ApplicationNotFoundException)
end
end
end
@@ -324,7 +324,7 @@
end
context 'when run' do
- it { expect { run }.should exit_with_code(0) }
+ it { expect { run }.to exit_with_code(0) }
end
end
@@ -335,34 +335,34 @@
before{ @domain = rest_client.add_domain("mockdomain") }
it "should raise cartridge not found exception when no apps exist" do
- expect { run }.should raise_error RHC::Rest::ApplicationNotFoundException
+ expect { run }.to raise_error RHC::Rest::ApplicationNotFoundException
end
context "with an app" do
before{ @app = @domain.add_application("app1", "mock_type") }
it "should not remove app when no is sent as input" do
- expect { run(["no"]) }.should raise_error(RHC::ConfirmationError)
+ expect { run(["no"]) }.to raise_error(RHC::ConfirmationError)
@domain.applications.length.should == 1
@domain.applications[0] == @app
end
it "should remove app when yes is sent as input" do
- expect { run(["yes"]) }.should exit_with_code(0)
+ expect { run(["yes"]) }.to exit_with_code(0)
@domain.applications.length.should == 0
end
context "with --noprompt but without --confirm" do
let(:arguments) { ['app', 'delete', 'app1', '--noprompt', '--trace'] }
it "should not remove the app" do
- expect { run(["no"]) }.should raise_error(RHC::ConfirmationError)
+ expect { run(["no"]) }.to raise_error(RHC::ConfirmationError)
@domain.applications.length.should == 1
end
end
context "with --noprompt and --confirm" do
let(:arguments) { ['app', 'delete', 'app1', '--noprompt', '--confirm'] }
it "should remove the app" do
- expect { run }.should exit_with_code(0)
+ expect { run }.to exit_with_code(0)
@domain.applications.length.should == 0
end
end
@@ -445,7 +445,7 @@
Kernel.should_receive(:system).with("ssh fakeuuidfortestsapp1@127.0.0.1").and_return(0)
end
it { run_output.should match("Connecting to fakeuuidfortestsapp") }
- it { expect { run }.should exit_with_code(0) }
+ it { expect { run }.to exit_with_code(0) }
end
end
@@ -459,7 +459,7 @@
@instance.should_receive(:has_ssh?).and_return(false)
end
it { run_output.should match("Please use the --ssh option to specify the path to your SSH executable, or install SSH.") }
- it { expect { run }.should exit_with_code(1) }
+ it { expect { run }.to exit_with_code(1) }
end
end
@@ -474,7 +474,7 @@
Kernel.should_receive(:system).with("path_to_ssh fakeuuidfortestsapp1@127.0.0.1").and_return(1)
end
it { run_output.should match("Connecting to fakeuuidfortestsapp") }
- it { expect { run }.should exit_with_code(1) }
+ it { expect { run }.to exit_with_code(1) }
end
end
View
8 spec/rhc/commands/apps_spec.rb
@@ -10,7 +10,7 @@
context 'when no domains' do
let(:arguments) { ['apps'] }
- it { expect { run }.should exit_with_code(1) }
+ it { expect { run }.to exit_with_code(1) }
it { run_output.should match(/In order to deploy applications.*rhc domain create/) }
end
@@ -18,21 +18,21 @@
let(:arguments){ ['apps'] }
let!(:domain){ rest_client.add_domain("first") }
- it { expect { run }.should exit_with_code(1) }
+ it { expect { run }.to exit_with_code(1) }
it { run_output.should match(/No applications.*rhc app create/) }
context 'with apps' do
let(:arguments) { ['apps'] }
before{ domain.add_application('scaled', 'php', true) }
- it { expect { run }.should exit_with_code(0) }
+ it { expect { run }.to exit_with_code(0) }
it { run_output.should match(/scaled.*\-\-.*php.*Scaling:.*x2 \(minimum/m) }
end
end
context 'when help is shown' do
let(:arguments) { ['apps', '--help'] }
- it { expect { run }.should exit_with_code(0) }
+ it { expect { run }.to exit_with_code(0) }
it { run_output.should match(/rhc apps.*Display the list of applications/m) }
end
end
View
16 spec/rhc/commands/authorization_spec.rb
@@ -23,7 +23,7 @@ def self.expect_an_unsupported_message
context "without authorizations" do
without_authorization
it('should warn that the server doesn\'t support auth'){ run_output.should =~ /The server does not support setting, retrieving, or authenticating with authorization tokens/ }
- it{ expect{ run }.should exit_with_code(1) }
+ it{ expect{ run }.to exit_with_code(1) }
end
end
@@ -37,7 +37,7 @@ def self.expect_an_unsupported_message
it('should display the expiration') { run_output.should =~ /Expires In:\s+1 minute/ }
it('should display the creation date') { run_output.should =~ /Created:\s+#{RHC::Helpers.date('2013-02-21T01:00:01Z')}/ }
it('should display the scopes') { run_output.should =~ /Scopes:\s+session read/ }
- it{ expect{ run }.should exit_with_code(0) }
+ it{ expect{ run }.to exit_with_code(0) }
end
expect_an_unsupported_message
@@ -47,7 +47,7 @@ def self.expect_an_unsupported_message
let(:arguments) { ['authorization', '--h']}
context 'given --h' do
it 'should not raise SystemStackError' do
- expect{ run }.should_not raise_error(SystemStackError)
+ expect{ run }.to_not raise_error(SystemStackError)
end
end
end
@@ -60,7 +60,7 @@ def self.expect_an_unsupported_message
before{ stub_delete_authorization('foo') }
before{ stub_delete_authorization('bar') }
it('should display success') { run_output.should =~ /Deleting auth.*done/ }
- it{ expect{ run }.should exit_with_code(0) }
+ it{ expect{ run }.to exit_with_code(0) }
after{ a_request(:delete, mock_href('broker/rest/user/authorizations/foo', true)).should have_been_made }
after{ a_request(:delete, mock_href('broker/rest/user/authorizations/bar', true)).should have_been_made }
end
@@ -68,7 +68,7 @@ def self.expect_an_unsupported_message
context "without a token in the command line" do
let(:arguments) { ['authorization', 'delete'] }
it('should display success') { run_output.should =~ /You must specify one or more tokens to delete/ }
- it{ expect{ run }.should exit_with_code(1) }
+ it{ expect{ run }.to exit_with_code(1) }
end
expect_an_unsupported_message
@@ -81,7 +81,7 @@ def self.expect_an_unsupported_message
with_authorization
before{ stub_delete_authorizations }
it('should display success') { run_output.should =~ /Deleting all auth.*done/ }
- it{ expect{ run }.should exit_with_code(0) }
+ it{ expect{ run }.to exit_with_code(0) }
after{ a_request(:delete, mock_href('broker/rest/user/authorizations', true)).should have_been_made }
end
@@ -105,7 +105,7 @@ def self.expect_an_unsupported_message
before{ instance.should_receive(:scope_help) }
it('should display the scope help') { command_output.should =~ /When adding an authorization.*to see more options/m }
- it{ expect{ run_command }.should exit_with_code(0) }
+ it{ expect{ run_command }.to exit_with_code(0) }
end
expect_an_unsupported_message
@@ -121,7 +121,7 @@ def self.expect_an_unsupported_message
it('should display the expiration') { run_output.should =~ /Expires In:\s+5 minutes/ }
it('should display the creation date') { run_output.should =~ /Created:\s+#{RHC::Helpers.date(mock_date_1)}/ }
it('should display the scopes') { run_output.should =~ /Scopes:\s+foo bar/ }
- it{ expect{ run }.should exit_with_code(0) }
+ it{ expect{ run }.to exit_with_code(0) }
expect_an_unsupported_message
end
View
32 spec/rhc/commands/domain_spec.rb
@@ -10,13 +10,13 @@
context 'when run with no domains' do
let(:arguments) { ['domain', '--noprompt', '--config', 'test.conf', '-l', 'test@test.foo', '-p', 'password'] }
- it { expect { run }.should exit_with_code(1) }
+ it { expect { run }.to exit_with_code(1) }
it { run_output.should match(/In order to deploy applications.*rhc domain create/) }
end
context 'when help is shown' do
let(:arguments) { ['domain', '--noprompt', '--help'] }
- it { expect { run }.should exit_with_code(0) }
+ it { expect { run }.to exit_with_code(0) }
it { run_output.should match(/The default action for this resource is 'show'/) }
end
end
@@ -25,14 +25,14 @@
let(:arguments) { ['domain', 'show', '--noprompt', '--config', 'test.conf', '-l', 'test@test.foo', '-p', 'password'] }
context 'when run with no domains' do
- it { expect { run }.should exit_with_code(1) }
+ it { expect { run }.to exit_with_code(1) }
it { run_output.should match(/In order to deploy applications.*rhc domain create/) }
end
context 'when run with one domain no apps' do
before{ rest_client.add_domain("onedomain") }
- it { expect { run }.should exit_with_code(0) }
+ it { expect { run }.to exit_with_code(0) }
it "should match output" do
output = run_output
output.should match("The domain onedomain exists but has no applications. You can use")
@@ -44,7 +44,7 @@
rest_client.add_domain("firstdomain")
rest_client.add_domain("seconddomain")
end
- it { expect { run }.should exit_with_code(0) }
+ it { expect { run }.to exit_with_code(0) }
it "should match output" do
output = run_output
output.should match("The domain firstdomain exists but has no applications. You can use")
@@ -61,7 +61,7 @@
a.add_cartridge("testcart-2")
a.add_cartridge("testcart-3")
end
- it { expect { run }.should exit_with_code(0) }
+ it { expect { run }.to exit_with_code(0) }
it "should match output" do
output = run_output
output.should match("app_no_carts")
@@ -78,7 +78,7 @@
d = rest_client.add_domain("appdomain")
a = d.add_application("app_no_carts")
end
- it { expect { run }.should exit_with_code(0) }
+ it { expect { run }.to exit_with_code(0) }
it "should match output" do
output = run_output
output.should match("app_no_carts")
@@ -93,7 +93,7 @@
context 'when no issues with ' do
it "should create a domain" do
- expect { run }.should exit_with_code(0)
+ expect { run }.to exit_with_code(0)
rest_client.domains[0].id.should == 'testnamespace'
end
it { run_output.should match(/'testnamespace'.*?RESULT:.*?Success/m) }
@@ -107,7 +107,7 @@
before{ rest_client.add_domain("olddomain") }
it "should update a domain" do
- expect { run }.should exit_with_code(0)
+ expect { run }.to exit_with_code(0)
rest_client.domains[0].id.should == 'alterednamespace'
end
it { run_output.should match(/Changing namespace 'olddomain' to 'alterednamespace'.*?RESULT:.*?Success/m) }
@@ -115,7 +115,7 @@
context 'when there is no domain' do
it "should not create a domain" do
- expect { run }.should exit_with_code(127)
+ expect { run }.to exit_with_code(127)
rest_client.domains.empty?.should be_true
end
it { run_output.should match("not found") }
@@ -129,7 +129,7 @@
before{ rest_client.add_domain("olddomain") }
it "should update a domain" do
- expect { run }.should exit_with_code(0)
+ expect { run }.to exit_with_code(0)
rest_client.domains[0].id.should == 'alterednamespace'
end
it { run_output.should match(/Changing namespace 'olddomain' to 'alterednamespace'.*?RESULT:.*?Success/m) }
@@ -143,7 +143,7 @@
before{ rest_client.add_domain("deleteme") }
it "should delete a domain" do
- expect { run }.should exit_with_code(0)
+ expect { run }.to exit_with_code(0)
rest_client.domains.empty?.should be_true
end
end
@@ -152,7 +152,7 @@
before{ rest_client.add_domain("dontdelete") }
it "should error out" do
- expect { run }.should exit_with_code(127)
+ expect { run }.to exit_with_code(127)
rest_client.domains[0].id.should == 'dontdelete'
end
it { run_output.should match("Domain deleteme not found") }
@@ -164,7 +164,7 @@
domain.add_application 'testapp1', 'mock-1.0'
end
it "should error out" do
- expect { run }.should exit_with_code(128)
+ expect { run }.to exit_with_code(128)
rest_client.domains[0].id.should == 'deleteme'
end
it { run_output.should match("Domain contains applications.*?Delete applications first.") }
@@ -178,7 +178,7 @@
before{ rest_client.add_domain("deleteme") }
it "should delete a domain" do
- expect { run }.should exit_with_code(0)
+ expect { run }.to exit_with_code(0)
rest_client.domains.empty?.should be_true
end
end
@@ -189,7 +189,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 domain") }
end
View
18 spec/rhc/commands/port_forward_spec.rb
@@ -26,7 +26,7 @@
@gg.should_receive(:gears).and_return([{'state' => 'stopped', 'id' => 'fakegearid'}])
end
it "should error out and suggest restarting the application" do
- expect { run }.should exit_with_code(1)
+ expect { run }.to exit_with_code(1)
end
it { run_output.should match(/Application \S+ is stopped\..*restart/m) }
end
@@ -37,7 +37,7 @@
@ssh.should_receive(:exec!).with("rhc-list-ports").and_yield(nil, :stderr, '127.0.0.1:3306')
end
it "should error out as no ports to forward" do
- expect { run }.should exit_with_code(102)
+ expect { run }.to exit_with_code(102)
rest_client.domains[0].id.should == 'mockdomain'
rest_client.domains[0].applications.size.should == 1
rest_client.domains[0].applications[0].name.should == 'mockapp'
@@ -51,7 +51,7 @@
@ssh.should_receive(:exec!).with("rhc-list-ports").and_yield(nil, :stderr, 'permission denied')
end
it "should error out as permission denied" do
- expect { run }.should exit_with_code(129)
+ expect { run }.to exit_with_code(129)
rest_client.domains[0].id.should == 'mockdomain'
rest_client.domains[0].applications.size.should == 1
rest_client.domains[0].applications[0].name.should == 'mockapp'
@@ -69,7 +69,7 @@
@ssh.should_receive(:loop)
end
it "should run successfully" do
- expect { run }.should exit_with_code(0)
+ expect { run }.to exit_with_code(0)
rest_client.domains[0].id.should == 'mockdomain'
rest_client.domains[0].applications.size.should == 1
rest_client.domains[0].applications[0].name.should == 'mockapp'
@@ -82,7 +82,7 @@
Net::SSH.should_receive(:start).and_raise(Errno::EHOSTUNREACH)
end
it "should error out" do
- expect { run }.should exit_with_code(1)
+ expect { run }.to exit_with_code(1)
rest_client.domains[0].id.should == 'mockdomain'
rest_client.domains[0].applications.size.should == 1
rest_client.domains[0].applications[0].name.should == 'mockapp'
@@ -94,7 +94,7 @@
before(:each) do
rest_client.should_receive(:find_domain).and_raise(RHC::Rest::ConnectionException)
end
- it("should error out") { expect { run }.should exit_with_code(1) }
+ it("should error out") { expect { run }.to exit_with_code(1) }
it{ run_output.should match("Connection.*failed:") }
end
@@ -108,7 +108,7 @@
@ssh.should_receive(:loop).and_raise(Interrupt.new)
end
it "should exit when user interrupts" do
- expect { run }.should exit_with_code(0)
+ expect { run }.to exit_with_code(0)
rest_client.domains[0].id.should == 'mockdomain'
rest_client.domains[0].applications.size.should == 1
rest_client.domains[0].applications[0].name.should == 'mockapp'
@@ -139,7 +139,7 @@
@ssh.should_receive(:forward).and_raise(Errno::ECONNREFUSED)
end
it "should error out" do
- expect { run }.should exit_with_code(0)
+ expect { run }.to exit_with_code(0)
end
it { run_output.should include("ssh -N") }
it { run_output.should include("Error forwarding") }
@@ -164,7 +164,7 @@
@ssh.should_receive(:loop).and_raise(Interrupt.new)
end
it "should exit when user interrupts" do
- expect { run }.should exit_with_code(0)
+ expect { run }.to exit_with_code(0)
rest_client.domains[0].id.should == 'mockdomain'
rest_client.domains[0].applications.size.should == 1
rest_client.domains[0].applications[0].name.should == 'mockapp'
View
24 spec/rhc/commands/snapshot_spec.rb
@@ -9,7 +9,7 @@
APP_NAME = 'mockapp'
let!(:rest_client) { MockRestClient.new }
- before(:each) do
+ before do
user_config
@app = rest_client.add_domain("mockdomain").add_application APP_NAME, 'mock-1.0'
@ssh_uri = URI.parse @app.ssh_url
@@ -17,14 +17,14 @@
FileUtils.cp(File.expand_path('../../assets/targz_sample.tar.gz', __FILE__), filename)
end
- after(:each) do
+ after do
filename = APP_NAME + '.tar.gz'
File.delete filename if File.exist? filename
end
describe 'snapshot without an action' do
let(:arguments) {['snapshot', '--trace', '--noprompt']}
- it('should raise') { expect{ run }.should raise_error(ArgumentError, /Please specify an action to take/) }
+ it('should raise') { expect{ run }.to raise_error(ArgumentError, /Please specify an action to take/) }
end
describe 'snapshot save' do
@@ -35,7 +35,7 @@
`(exit 0)`
Kernel.should_receive(:`).with("ssh #{@ssh_uri.user}@#{@ssh_uri.host} 'snapshot' > #{@app.name}.tar.gz")
end
- it { expect { run }.should exit_with_code(0) }
+ it { expect { run }.to exit_with_code(0) }
end
context 'when failing to save a snapshot' do
@@ -43,7 +43,7 @@
`(exit 1)`
Kernel.should_receive(:`).with("ssh #{@ssh_uri.user}@#{@ssh_uri.host} 'snapshot' > #{@app.name}.tar.gz")
end
- it { expect { run }.should exit_with_code(130) }
+ it { expect { run }.to exit_with_code(130) }
end
context 'when saving a snapshot on windows' do
@@ -55,7 +55,7 @@
Net::SSH.should_receive(:start).with(@ssh_uri.host, @ssh_uri.user).and_yield(ssh)
ssh.should_receive(:exec!).with("snapshot").and_yield(nil, :stdout, 'foo').and_yield(nil, :stderr, 'foo')
end
- it { expect { run }.should exit_with_code(0) }
+ it { expect { run }.to exit_with_code(0) }
it { run_output.should match("Success") }
end
@@ -67,7 +67,7 @@
ssh = mock(Net::SSH)
Net::SSH.should_receive(:start).with(@ssh_uri.host, @ssh_uri.user).and_raise(Timeout::Error)
end
- it { expect { run }.should exit_with_code(130) }
+ it { expect { run }.to exit_with_code(130) }
end
end
@@ -82,7 +82,7 @@
`(exit 0)`
Kernel.should_receive(:`).with("cat #{@app.name}.tar.gz | ssh #{@ssh_uri.user}@#{@ssh_uri.host} 'restore INCLUDE_GIT'")
end
- it { expect { run }.should exit_with_code(0) }
+ it { expect { run }.to exit_with_code(0) }
end
context 'when restoring a snapshot and failing to ssh' do
@@ -92,7 +92,7 @@
Kernel.should_receive(:`).with("cat #{@app.name}.tar.gz | ssh #{@ssh_uri.user}@#{@ssh_uri.host} 'restore INCLUDE_GIT'")
$?.stub(:exitstatus) { 1 }
end
- it { expect { run }.should exit_with_code(130) }
+ it { expect { run }.to exit_with_code(130) }
end
context 'when restoring a snapshot on windows' do
@@ -119,7 +119,7 @@
channel.should_receive(:eof!)
session.should_receive(:loop)
end
- it { expect { run }.should exit_with_code(0) }
+ it { expect { run }.to exit_with_code(0) }
end
context 'when timing out on windows' do
@@ -130,7 +130,7 @@
ssh = mock(Net::SSH)
Net::SSH.should_receive(:start).with(@ssh_uri.host, @ssh_uri.user).and_raise(Timeout::Error)
end
- it { expect { run }.should exit_with_code(130) }
+ it { expect { run }.to exit_with_code(130) }
end
end
@@ -138,7 +138,7 @@
describe 'snapshot restore file not found' do
let(:arguments) {['snapshot', 'restore', '--noprompt', '-l', 'test@test.foo', '-p', 'password', '--app', 'mockapp', '-f', 'foo.tar.gz']}
context 'when restoring a snapshot' do
- it { expect { run }.should exit_with_code(130) }
+ it { expect { run }.to exit_with_code(130) }
end
end
View
22 spec/rhc/commands/sshkey_spec.rb
@@ -13,7 +13,7 @@
context "when run with list command" do
let(:arguments) { %w[sshkey list --noprompt --config test.conf -l test@test.foo -p password --trace] }
- it { expect { run }.should exit_with_code(0) }
+ it { expect { run }.to exit_with_code(0) }
it { run_output.should match(/mockkey1 \(type: ssh-rsa\)/) }
end
end
@@ -22,7 +22,7 @@
context "when run with show command" do
let(:arguments) { %w[sshkey show mockkey1 --noprompt --config test.conf -l test@test.foo -p password --trace] }
- it { expect { run }.should exit_with_code(0) }
+ it { expect { run }.to exit_with_code(0) }
it { run_output.should match(/mockkey1 \(type: ssh-rsa\)/) }
end
end
@@ -38,7 +38,7 @@
File.open('id_rsa.pub', 'w') do |f|
f << 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCnCOqK7/mmvZ9AtCAerxjAasJ1rSpfuWT4vNm1+O/Fh0Di3chTWjY9a0M2hEnqkqnVG589L9CqCUeT0kdc3Vgw3JEcacSUr1z7tLr9kO+p/D5lSdQYzDGGRFOZ0H6lc/y8iNxWV1VO/sJvKx6cr5zvKIn8Q6GvhVNOxlai0IOb9FJxLGK95GLpZ+elzh8Tc9giy7KfwheAwhV2JoF9uRltE5JP/CNs7w/E29i1Z+jlueuu8RVotLmhSVNJm91Ey7OCtoI1iBE0Wv/SucFe32Qi08RWTM/MaGGz93KQNOVRGjNkosJjPmP1qU6WGBfliDkJAZXB0b6sEcnx1fbVikwZ'
end
- expect { run }.should exit_with_code(0)
+ expect { run }.to exit_with_code(0)
rest_client.sshkeys.length.should == num_keys + 1
end
end
@@ -54,7 +54,7 @@
File.open('id_rsa.pub', 'w') do |f|
f << 'ssh-rsa AADAQABAAABAQCnCOqK7/mmvZ9AtCAerxjAasJ1rSpfuWT4vNm1+O/Fh0Di3chTWjY9a0M2hEnqkqnVG589L9CqCUeT0kdc3Vgw3JEcacSUr1z7tLr9kO+p/D5lSdQYzDGGRFOZ0H6lc/y8iNxWV1VO/sJvKx6cr5zvKIn8Q6GvhVNOxlai0IOb9FJxLGK95GLpZ+elzh8Tc9giy7KfwheAwhV2JoF9uRltE5JP/CNs7w/E29i1Z+jlueuu8RVotLmhSVNJm91Ey7OCtoI1iBE0Wv/SucFe32Qi08RWTM/MaGGz93KQNOVRGjNkosJjPmP1qU6WGBfliDkJAZXB0b6sEcnx1fbVikwZ'
end
- expect { run }.should exit_with_code(128)
+ expect { run }.to exit_with_code(128)
expect { run_output.should match(/Name:.* mockkey/) }
rest_client.sshkeys.length.should == num_keys
end
@@ -67,7 +67,7 @@
File.open('id_rsa.pub', 'w') do |f|
f << ''
end
- expect { run }.should exit_with_code(128)
+ expect { run }.to exit_with_code(128)
expect { run_output.should match(/Name:.* mockkey/) }
rest_client.sshkeys.length.should == num_keys
end
@@ -75,7 +75,7 @@
it "exits with status code Errno::EACCES::Errno" do
IO.should_receive(:read).and_return("ssh_foo bar")
- expect { run }.should exit_with_code(128)
+ expect { run }.to exit_with_code(128)
end
end
@@ -89,7 +89,7 @@
File.open('id_rsa.pub', 'w') do |f|
f << 'ssh-rsa AADAQABAAABAQCnCOqK7/mmvZ9AtCAerxjAasJ1rSpfuWT4vNm1+O/Fh0Di3chTWjY9a0M2hEnqkqnVG589L9CqCUeT0kdc3Vgw3JEcacSUr1z7tLr9kO+p/D5lSdQYzDGGRFOZ0H6lc/y8iNxWV1VO/sJvKx6cr5zvKIn8Q6GvhVNOxlai0IOb9FJxLGK95GLpZ+elzh8Tc9giy7KfwheAwhV2JoF9uRltE5JP/CNs7w/E29i1Z+jlueuu8RVotLmhSVNJm91Ey7OCtoI1iBE0Wv/SucFe32Qi08RWTM/MaGGz93KQNOVRGjNkosJjPmP1qU6WGBfliDkJAZXB0b6sEcnx1fbVikwZ'
end
- expect { run }.should exit_with_code(0)
+ expect { run }.to exit_with_code(0)
expect { run_output.should match("key you are uploading is not recognized") }
rest_client.sshkeys.length.should == num_keys + 1
end
@@ -100,7 +100,7 @@
let(:arguments) { %w[sshkey add --noprompt --config test.conf -l test@test.foo -p password foobar id_rsa.pub] }
it "exits with status code Errno::ENOENT::Errno" do
- expect { run }.should exit_with_code(128)
+ expect { run }.to exit_with_code(128)
end
end
@@ -119,7 +119,7 @@
it "exits with status code Errno::EACCES::Errno" do
IO.should_receive(:read).and_raise(Errno::EACCES)
- expect { run }.should exit_with_code(128)
+ expect { run }.to exit_with_code(128)
end
end
@@ -132,7 +132,7 @@
it 'deletes the key' do
keys = rest_client.sshkeys
num_keys = keys.length
- expect {run}.should exit_with_code(0)
+ expect{ run }.to exit_with_code(0)
rest_client.sshkeys.length.should == num_keys - 1
end
end
@@ -143,7 +143,7 @@
it 'leaves keys untouched' do
num_keys = @keys.length
- expect {run}.should exit_with_code(0)
+ expect{ run }.to exit_with_code(0)
rest_client.sshkeys.length.should == num_keys
end
end
View
12 spec/rhc/config_spec.rb
@@ -4,7 +4,7 @@
describe RHC::Config do
subject{ RHC::Config }
- before(:all) do
+ before do
ENV['LIBRA_SERVER'] = nil
ENV['HTTP_PROXY'] = nil
ENV['http_proxy'] = nil
@@ -14,10 +14,12 @@
FakeFS::FileSystem.clear
end
- after(:all) do
+ after do
FakeFS.deactivate!
ENV['HTTP_PROXY'] = nil
ENV['http_proxy'] = nil
+ ENV['LIBRA_SERVER'] = nil
+ RHC::Config.send(:instance_variable_set, :@default, nil)
end
describe "class" do
@@ -86,6 +88,7 @@
end
context "Config values with /etc/openshift/express.conf" do
+
it "should have only a global config" do
ConfigHelper.write_out_config(ConfigHelper.global_config_path, "global.openshift.redhat.com", "global@redhat.com")
subject.initialize
@@ -260,11 +263,8 @@ def stub_config
end
context "Debug options" do
- after(:all) do
- FakeFS::FileSystem.clear
- end
-
it "should show debug as false because nothing is set" do
+ subject.initialize
ConfigHelper.check_legacy_debug({}).should be_false
end
View
49 spec/rhc/helpers_spec.rb
@@ -10,25 +10,35 @@
require 'date'
require 'resolv'
+class MockHelpers
+ include RHC::Helpers
+ include RHC::SSHHelpers
+
+ def config
+ @config ||= RHC::Config.new
+ end
+ def options
+ @options ||= OpenStruct.new(:server => nil)
+ end
+end
+
+class MockCartridgeHelpers
+ include RHC::Helpers
+ include RHC::CartridgeHelpers
+
+ def config
+ @config ||= RHC::Config.new
+ end
+end
+
describe RHC::Helpers do
- before(:each) do
+ before do
mock_terminal
user_config
end
- subject do
- Class.new(Object) do
- include RHC::Helpers
- include RHC::SSHHelpers
+ subject{ MockHelpers.new }
- def config
- @config ||= RHC::Config.new
- end
- def options
- @options ||= OpenStruct.new(:server => nil)
- end
- end.new
- end
let(:tests) { OutputTests.new }
its(:openshift_server) { should == 'openshift.redhat.com' }
@@ -526,6 +536,8 @@ def reset
end
describe HighLine do
+ before{ mock_terminal }
+
it "should wrap the terminal" do
$terminal.wrap_at = 10
say "Lorem ipsum dolor sit amet"
@@ -569,16 +581,7 @@ def reset
mock_terminal
end
- subject do
- Class.new(Object) do
- include RHC::Helpers
- include RHC::CartridgeHelpers
-
- def config
- @config ||= RHC::Config.new
- end
- end.new
- end
+ subject{ MockCartridgeHelpers.new }
describe '#check_cartridges' do
let(:cartridges){ [] }
View
30 spec/rhc/rest_client_spec.rb
@@ -22,6 +22,9 @@ module RHC
module Rest
describe Client do
+ after{ ENV['http_proxy'] = nil }
+ after{ ENV['HTTP_PROXY'] = nil }
+
it 'should set the proxy protocol if it is missing' do
ENV['http_proxy'] = 'foo.bar.com:8081'
load 'rhc/rest/client.rb'
@@ -80,13 +83,13 @@ module Rest
context "against an endpoint that won't connect" do
let(:endpoint){ mock_href('api_error') }
it "raises an error message" do
- expect{ client.api }.should raise_error
+ expect{ client.api }.to raise_error
end
end
context "against an endpoint that has a generic error" do
let(:endpoint){ mock_href('other_error') }
it "raises a generic error for any other error condition" do
- expect{ client.api }.should raise_error(RHC::Rest::ConnectionException, "An unexpected error occured: Other Error")
+ expect{ client.api }.to raise_error(RHC::Rest::ConnectionException, "An unexpected error occured: Other Error")
end
end
end
@@ -227,13 +230,13 @@ module Rest
end
it "returns a domain object for matching domain IDs" do
match = nil
- expect { match = client.find_domain('mock_domain_0') }.should_not raise_error
+ expect { match = client.find_domain('mock_domain_0') }.to_not raise_error
match.id.should == 'mock_domain_0'
match.class.should == RHC::Rest::Domain
end
it "raise an error when no matching domain IDs can be found" do
- expect { client.find_domain('mock_domain_2') }.should raise_error(RHC::Rest::DomainNotFoundException)
+ expect { client.find_domain('mock_domain_2') }.to raise_error(RHC::Rest::DomainNotFoundException)
end
end
@@ -275,16 +278,16 @@ module Rest
mock_response_links(mock_app_links(mock_domain, mock_app))
end
it "Raises an exception when no matching applications can be found" do
- expect { client.find_application(mock_domain, missing) }.should raise_error(RHC::Rest::ApplicationNotFoundException)
+ expect { client.find_application(mock_domain, missing) }.to raise_error(RHC::Rest::ApplicationNotFoundException)
end
it "Raises an exception when no matching domain can be found" do
- expect { client.find_application(missing, mock_app) }.should raise_error(RHC::Rest::DomainNotFoundException)
+ expect { client.find_application(missing, mock_app) }.to raise_error(RHC::Rest::DomainNotFoundException)
end
end
describe RHC::Rest::Cartridge do
subject do
- described_class.new({
+ RHC::Rest::Cartridge.new({
:name => 'foo',
:links => mock_response_links([
['GET', 'broker/rest/cartridge', 'get']
@@ -444,7 +447,7 @@ module Rest
end
it "returns a list of key objects for matching keys" do
key = nil
- expect { key = client.find_key('mock_key_0') }.should_not raise_error
+ expect { key = client.find_key('mock_key_0') }.to_not raise_error
key.class.should == RHC::Rest::Key
key.name.should == 'mock_key_0'
@@ -454,7 +457,7 @@ module Rest
mock_response_links(mock_key_links('mock_key_0'))
end
it "raise an error when no matching keys can be found" do
- expect { client.find_key('no_match') }.should raise_error(RHC::KeyNotFoundException)
+ expect { client.find_key('no_match') }.to raise_error(RHC::KeyNotFoundException)
end
end
@@ -521,12 +524,11 @@ module Rest
end
it "should delete keys" do
- expect { client.delete_key('mock_key_0') }.should be_true
+ expect { client.delete_key('mock_key_0') }.to be_true
end
it 'raises an error if nonexistent key is requested' do
- expect { client.find_key('no_match') }.
- should raise_error(RHC::KeyNotFoundException)
+ expect { client.find_key('no_match') }.to raise_error(RHC::KeyNotFoundException)
end
end
@@ -589,11 +591,11 @@ module Rest
describe "#supports_sessions?" do
before{ subject.should_receive(:api).at_least(2).times.and_return(stub) }
context "with ADD_AUTHORIZATION link" do
- before{ subject.api.should_receive(:supports?).twice.with('ADD_AUTHORIZATION').and_return(true) }
+ before{ subject.api.should_receive(:supports?).with('ADD_AUTHORIZATION').and_return(true) }
its(:supports_sessions?){ should be_true }
end
context "without ADD_AUTHORIZATION link" do
- before{ subject.api.should_receive(:supports?).twice.with('ADD_AUTHORIZATION').and_return(false) }
+ before{ subject.api.should_receive(:supports?).with('ADD_AUTHORIZATION').and_return(false) }
its(:supports_sessions?){ should be_false }
end
end
View
2  spec/rhc/wizard_spec.rb
@@ -53,7 +53,7 @@ def mock_config
mock_config
FileUtils.mkdir_p(RHC::Config.ssh_dir)
File.open(RHC::Config.ssh_priv_key_file_path, 'w'){}
- File.chmod(0666, RHC::Config.ssh_priv_key_file_path)
+ File.expect_mode(RHC::Config.ssh_priv_key_file_path, 0666)
expect{ subject.send(:test_private_key_mode) }.to raise_error(StandardError)
end
end
View
1  spec/spec.opts
@@ -1 +0,0 @@
---color
View
10 spec/spec_helper.rb
@@ -178,7 +178,7 @@ def const_for(obj=nil)
if obj
Object.const_set(const_for, obj)
else
- "#{description}".split(" ").map{|word| word.capitalize}.join.gsub(/[^\w]/, '')
+ "#{example.full_description}".split(" ").map{|word| word.capitalize}.join.gsub(/[^\w]/, '')
end
end
@@ -342,7 +342,7 @@ def user_config
end
module ExitCodeMatchers
- Spec::Matchers.define :exit_with_code do |code|
+ RSpec::Matchers.define :exit_with_code do |code|
actual = nil
match do |block|
begin
@@ -366,7 +366,7 @@ module ExitCodeMatchers
end
module CommanderInvocationMatchers
- Spec::Matchers.define :call do |method|
+ RSpec::Matchers.define :call do |method|
chain :on do |object|
@object = object
end
@@ -399,7 +399,7 @@ module ColorMatchers
:clear => 0
}
- Spec::Matchers.define :be_colorized do |msg,color|
+ RSpec::Matchers.define :be_colorized do |msg,color|
match do |actual|
actual == colorized_message(msg,color)
end
@@ -436,7 +436,7 @@ def mac?
RbConfig::CONFIG['host_os'] =~ /^darwin/
end
-Spec::Runner.configure do |config|
+RSpec.configure do |config|
config.include(ExitCodeMatchers)
config.include(CommanderInvocationMatchers)
config.include(ColorMatchers)
View
2  spec/wizard_spec_helper.rb
@@ -321,7 +321,7 @@ def setup_different_config
end
end
-Spec::Runner.configure do |config|
+RSpec.configure do |config|
config.include(WizardHelper)
config.include(WizardStepsHelper)
end
View
4 tasks/test.rake
@@ -1,9 +1,9 @@
-require "spec/rake/spectask"
+require "rspec/core/rake_task"
require 'cucumber'
require 'cucumber/rake/task'
desc "Run specs"
-Spec::Rake::SpecTask.new(:spec) do |t|
+RSpec::Core::RakeTask.new(:spec) do |t|
t.verbose = false
end

0 comments on commit 37a104d

Please sign in to comment.
Something went wrong with that request. Please try again.