Skip to content

Commit e39fcca

Browse files
authored
Update from RSpec v2 to v3 (piotrmurach#364)
1 parent 2872bbb commit e39fcca

233 files changed

Lines changed: 818 additions & 819 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ rvm:
88
- 2.2.9
99
- 2.3.6
1010
- 2.4.3
11-
- 2.5.0
11+
- 2.5.8
12+
- 2.6.6
13+
- 2.7.1
1214
- ruby-head
1315
- jruby-9000
1416
- jruby-head
@@ -17,7 +19,5 @@ matrix:
1719
- rvm: ruby-head
1820
- rvm: jruby-head
1921
fast_finish: true
20-
branches:
21-
only: master
2222
notifications:
2323
email: false

features/step_definitions/common_steps.rb

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,45 +20,45 @@
2020
else
2121
raise ArgumentError 'Expected boolean type!'
2222
end
23-
@response.should == expected
23+
expect(@response).to eq expected
2424
end
2525

2626
Then /^the response status should be (.*)$/ do |expected_response|
27-
@response.status.should eql expected_response.to_i
27+
expect(@response.status).to eql expected_response.to_i
2828
end
2929

3030
Then /^the response should be (.*)$/ do |expected_response|
3131
expected_response = case expected_response
3232
when /false/
33-
@response.should be_false
33+
expect(@response).to be false
3434
when /true/
35-
@response.should be_true
35+
expect(@response).to be true
3636
when /\d+/
37-
@response.should eql expected_response.to_i
37+
expect(@response).to eql expected_response.to_i
3838
when /empty/
39-
@response.should be_empty
39+
expect(@response).to be_empty
4040
else
41-
@response.should eql expected_response
41+
expect(@response).to eql expected_response
4242
end
4343
end
4444

4545
Then /^the response type should be (.*)$/ do |type|
4646
case type.downcase
4747
when 'json'
48-
@response.headers.content_type.should =~ /application\/json/
48+
expect(@response.headers.content_type).to match /application\/json/
4949
when 'html'
50-
@response.headers.content_type.should =~ /text\/html/
50+
expect(@response.headers.content_type).to match /text\/html/
5151
when 'raw'
52-
@response.headers.content_type.should =~ /raw/
52+
expect(@response.headers.content_type).to match /raw/
5353
end
5454
end
5555

5656
Then /^the response should have (\d+) items$/ do |size|
57-
@response.size.should eql size.to_i
57+
expect(@response.size).to eql size.to_i
5858
end
5959

6060
Then /^the response should not be empty$/ do
61-
@response.should_not be_empty
61+
expect(@response).to_not be_empty
6262
end
6363

6464
Then /^the response should in (.*) contain (.*)$/ do |attr, item|
@@ -75,7 +75,7 @@
7575
Then /^the response should contain (.*)$/ do |item|
7676
case @response.body
7777
when Array
78-
@response.body.should include item
78+
expect(@response.body).to include item
7979
end
8080
end
8181

@@ -86,7 +86,7 @@
8686
Then /^the response (.*) link should contain:$/ do |type, table|
8787
table.hashes.each do |attributes|
8888
attributes.each do |key, val|
89-
@response.links.send(:"#{type}").should match /#{key}=#{val}/
89+
expect(@response.links.send(:"#{type}")).to match /#{key}=#{val}/
9090
end
9191
end
9292
end
@@ -97,8 +97,8 @@
9797

9898
Then /^the response (.*) item (.*) should be (.*)$/ do |action, field, result|
9999
if action == 'first'
100-
@response.first.send(field).should eql result
100+
expect(@response.first.send(field)).to eql result
101101
else
102-
@response.last.send(field).should eql result
102+
expect(@response.last.send(field)).to eql result
103103
end
104104
end

features/step_definitions/github_api_steps.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
end
4040

4141
When /^I will have access to "([^"]*)" API$/ do |api|
42-
@response.class.to_s.should match api
42+
expect(@response.class.to_s).to match api
4343
end
4444

4545
When /^I want(?: to|) (.*) (?:resource|resources)$/ do |method|
@@ -99,7 +99,7 @@
9999
end
100100

101101
Then /^this collection should include first page$/ do
102-
@pages.flatten.map(&:name).should include @response.first.name
102+
expect(@pages.flatten.map(&:name)).to include @response.first.name
103103
end
104104

105105
Then /^request should fail with "([^"]*)"$/ do |exception|

github_api.gemspec

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,11 @@ Gem::Specification.new do |gem|
2323
gem.add_dependency 'oauth2', '~> 1.0'
2424
gem.add_dependency 'descendants_tracker', '~> 0.0.4'
2525

26-
gem.add_development_dependency 'bundler', '>= 1.5.0', '< 2.0'
26+
gem.add_development_dependency 'bundler', '>= 1.5.0', '< 3'
2727
gem.add_development_dependency 'rake', '< 11.0'
2828
gem.add_development_dependency 'cucumber', '~> 2.1'
29-
gem.add_development_dependency 'rspec', '~> 2.14.1'
29+
gem.add_development_dependency 'rspec', '~> 3'
30+
gem.add_development_dependency 'rspec-its','~> 1'
3031
gem.add_development_dependency 'vcr', '~> 3.0.3'
3132
gem.add_development_dependency 'webmock', '~> 3.0.1'
3233
end

spec/github/authorization_spec.rb

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,22 @@
1616
end
1717

1818
context '.client' do
19-
it { should respond_to :client }
19+
it { is_expected.to respond_to :client }
2020

2121
it "should return OAuth2::Client instance" do
22-
github.client.should be_a OAuth2::Client
22+
expect(github.client).to be_a OAuth2::Client
2323
end
2424

2525
it "should assign site from the options hash" do
26-
github.client.site.should == site
26+
expect(github.client.site).to eq site
2727
end
2828

2929
it "should assign 'authorize_url" do
30-
github.client.authorize_url.should == "#{site}login/oauth/authorize"
30+
expect(github.client.authorize_url).to eq "#{site}login/oauth/authorize"
3131
end
3232

3333
it "should assign 'token_url" do
34-
github.client.token_url.should == "#{site}login/oauth/access_token"
34+
expect(github.client.token_url).to eq "#{site}login/oauth/access_token"
3535
end
3636
end
3737

@@ -49,26 +49,26 @@
4949
it "should return authentication token code" do
5050
github.client_id = client_id
5151
github.client_secret = client_secret
52-
github.client.stub(:auth_code).and_return code
53-
github.auth_code.should == code
52+
allow(github.client).to receive(:auth_code).and_return code
53+
expect(github.auth_code).to eq code
5454
end
5555
end
5656

5757
context "authorize_url" do
5858
let(:options) { {:client_id => client_id, :client_secret => client_secret} }
5959

60-
it { should respond_to(:authorize_url) }
60+
it { is_expected.to respond_to(:authorize_url) }
6161

6262
it "should return address containing client_id" do
63-
github.authorize_url.should =~ /client_id=#{client_id}/
63+
expect(github.authorize_url).to match /client_id=#{client_id}/
6464
end
6565

6666
it "should return address containing scopes" do
67-
github.authorize_url(:scope => 'user').should =~ /scope=user/
67+
expect(github.authorize_url(:scope => 'user')).to match /scope=user/
6868
end
6969

7070
it "should return address containing redirect_uri" do
71-
github.authorize_url(:redirect_uri => 'http://localhost').should =~ /redirect_uri/
71+
expect(github.authorize_url(:redirect_uri => 'http://localhost')).to match /redirect_uri/
7272
end
7373
end
7474

@@ -80,12 +80,12 @@
8080
to_return(:body => '', :status => 200, :headers => {})
8181
end
8282

83-
it { should respond_to(:get_token) }
83+
it { is_expected.to respond_to(:get_token) }
8484

8585
it "should make the authorization request" do
8686
expect {
8787
github.get_token code
88-
a_request(:post, "https://github.com/login/oauth/access_token").should have_been_made
88+
a_request(:post, expect("https://github.com/login/oauth/access_token")).to have_been_made
8989
}.to raise_error(OAuth2::Error)
9090
end
9191

@@ -95,49 +95,49 @@
9595
end
9696

9797
context ".authenticated?" do
98-
it { should respond_to(:authenticated?) }
98+
it { is_expected.to respond_to(:authenticated?) }
9999

100100
it "should return false if falied on basic authentication" do
101-
github.stub(:basic_authed?).and_return false
102-
expect(github.authenticated?).to be_false
101+
allow(github).to receive(:basic_authed?).and_return false
102+
expect(github.authenticated?).to be false
103103
end
104104

105105
it "should return true if basic authentication performed" do
106-
github.stub(:basic_authed?).and_return true
107-
github.authenticated?.should be_true
106+
allow(github).to receive(:basic_authed?).and_return true
107+
expect(github.authenticated?).to be true
108108
end
109109

110110
it "should return true if basic authentication performed" do
111-
github.stub(:oauth_token?).and_return true
112-
github.authenticated?.should be_true
111+
allow(github).to receive(:oauth_token?).and_return true
112+
expect(github.authenticated?).to be true
113113
end
114114
end
115115

116116
context ".basic_authed?" do
117117
before do
118-
github.stub(:basic_auth?).and_return false
118+
allow(github).to receive(:basic_auth?).and_return false
119119
end
120120

121-
it { should respond_to(:basic_authed?) }
121+
it { is_expected.to respond_to(:basic_authed?) }
122122

123123
it "should return false if login is missing" do
124-
github.stub(:login?).and_return false
125-
github.basic_authed?.should be_false
124+
allow(github).to receive(:login?).and_return false
125+
expect(github.basic_authed?).to be false
126126
end
127127

128128
it "should return true if login && password provided" do
129-
github.stub(:login?).and_return true
130-
github.stub(:password?).and_return true
131-
expect(github.basic_authed?).to be_true
129+
allow(github).to receive(:login?).and_return true
130+
allow(github).to receive(:password?).and_return true
131+
expect(github.basic_authed?).to be true
132132
end
133133
end
134134

135135
context "authentication" do
136-
it { should respond_to(:authentication) }
136+
it { is_expected.to respond_to(:authentication) }
137137

138138
it "should return empty hash if no basic authentication params available" do
139-
github.stub(:login?).and_return false
140-
github.stub(:basic_auth?).and_return false
139+
allow(github).to receive(:login?).and_return false
140+
allow(github).to receive(:basic_auth?).and_return false
141141
expect(github.authentication).to be_empty
142142
end
143143

spec/github/client/authorizations/app/check_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
it "checks resource successfully" do
2424
subject.check client_id, access_token
25-
a_get(request_path, host).should have_been_made
25+
expect(a_get(request_path, host)).to have_been_made
2626
end
2727

2828
it "fails without client_id" do
@@ -41,12 +41,12 @@
4141

4242
it "returns the resource" do
4343
authorization = subject.check client_id, access_token
44-
authorization.should be_a Github::ResponseWrapper
44+
expect(authorization).to be_a Github::ResponseWrapper
4545
end
4646

4747
it "gets the authorization information" do
4848
authorization = subject.check client_id, access_token
49-
authorization.token.should == 'abc123'
49+
expect(authorization.token).to eq 'abc123'
5050
end
5151
end
5252

@@ -60,7 +60,7 @@
6060

6161
it "returns nil" do
6262
authorization = subject.check client_id, access_token
63-
authorization.should be_nil
63+
expect(authorization).to be_nil
6464
end
6565
end
6666
end # check

spec/github/client/authorizations/app/create_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
it "creates resource successfully" do
2626
subject.create client_id
27-
a_put(request_path, host).should have_been_made
27+
expect(a_put(request_path, host)).to have_been_made
2828
end
2929

3030
it "fails without client_id" do
@@ -33,12 +33,12 @@
3333

3434
it "returns the resource" do
3535
authorization = subject.create client_id
36-
authorization.should be_a Github::ResponseWrapper
36+
expect(authorization).to be_a Github::ResponseWrapper
3737
end
3838

3939
it "gets the authorization information" do
4040
authorization = subject.create client_id
41-
authorization.token.should == 'abc123'
41+
expect(authorization.token).to eq 'abc123'
4242
end
4343
end
4444
end # create

spec/github/client/authorizations/app/delete_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
it "revokes resource successfully" do
2828
subject.delete client_id
29-
a_delete(request_path, host).should have_been_made
29+
expect(a_delete(request_path, host)).to have_been_made
3030
end
3131

3232
it_should_behave_like 'request failure' do
@@ -42,12 +42,12 @@
4242

4343
it "revokes resource successfully" do
4444
subject.delete client_id, access_token
45-
a_delete(request_path, host).should have_been_made
45+
expect(a_delete(request_path, host)).to have_been_made
4646
end
4747

4848
it "revokes resource successfully with access token as parameter" do
4949
subject.delete client_id, access_token: access_token
50-
a_delete(request_path, host).should have_been_made
50+
expect(a_delete(request_path, host)).to have_been_made
5151
end
5252

5353
it_should_behave_like 'request failure' do

spec/github/client/authorizations/create_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@
2626

2727
it "creates resource successfully" do
2828
subject.create inputs
29-
a_post(request_path, host).with(body: inputs).should have_been_made
29+
expect(a_post(request_path, host).with(body: inputs)).to have_been_made
3030
end
3131

3232
it "returns the resource" do
3333
authorization = subject.create inputs
34-
authorization.should be_a Github::ResponseWrapper
34+
expect(authorization).to be_a Github::ResponseWrapper
3535
end
3636

3737
it "fails without a note parameter" do
@@ -43,7 +43,7 @@
4343

4444
it "gets the authorization information" do
4545
authorization = subject.create inputs
46-
authorization.token.should == 'abc123'
46+
expect(authorization.token).to eq 'abc123'
4747
end
4848
end
4949

spec/github/client/authorizations/delete_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
it "deletes resource successfully" do
2828
subject.delete authorization_id
29-
a_delete(request_path, host).should have_been_made
29+
expect(a_delete(request_path, host)).to have_been_made
3030
end
3131

3232
it_should_behave_like 'request failure' do

0 commit comments

Comments
 (0)