Permalink
Browse files

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

…mized tests pass correctly

Make randomization the default.
  • Loading branch information...
1 parent 4b43d44 commit 37a104d9526f5ac2a9d38072f658c31ec660cf6f @smarterclayton smarterclayton committed Mar 29, 2013
View
1 .rspec
@@ -0,0 +1 @@
+--color --order random
View
@@ -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
@@ -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
@@ -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
@@ -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,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
@@ -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,15 +154,15 @@
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
end
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,15 +172,15 @@
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
let(:arguments) { ['alias', 'remove', 'mock_app_0', 'www.foo.bar' ] }
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,20 +249,20 @@
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
let(:arguments) { ['alias', 'delete-cert', 'mock_app_0', 'www.foo.bar', '--confirm'] }
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,22 +273,22 @@
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
let(:arguments) { ['alias', 'list', 'mock_app_0'] }
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 }
Oops, something went wrong.

0 comments on commit 37a104d

Please sign in to comment.