|
16 | 16 | end |
17 | 17 |
|
18 | 18 | context '.client' do |
19 | | - it { should respond_to :client } |
| 19 | + it { is_expected.to respond_to :client } |
20 | 20 |
|
21 | 21 | it "should return OAuth2::Client instance" do |
22 | | - github.client.should be_a OAuth2::Client |
| 22 | + expect(github.client).to be_a OAuth2::Client |
23 | 23 | end |
24 | 24 |
|
25 | 25 | it "should assign site from the options hash" do |
26 | | - github.client.site.should == site |
| 26 | + expect(github.client.site).to eq site |
27 | 27 | end |
28 | 28 |
|
29 | 29 | 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" |
31 | 31 | end |
32 | 32 |
|
33 | 33 | 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" |
35 | 35 | end |
36 | 36 | end |
37 | 37 |
|
|
49 | 49 | it "should return authentication token code" do |
50 | 50 | github.client_id = client_id |
51 | 51 | 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 |
54 | 54 | end |
55 | 55 | end |
56 | 56 |
|
57 | 57 | context "authorize_url" do |
58 | 58 | let(:options) { {:client_id => client_id, :client_secret => client_secret} } |
59 | 59 |
|
60 | | - it { should respond_to(:authorize_url) } |
| 60 | + it { is_expected.to respond_to(:authorize_url) } |
61 | 61 |
|
62 | 62 | 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}/ |
64 | 64 | end |
65 | 65 |
|
66 | 66 | 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/ |
68 | 68 | end |
69 | 69 |
|
70 | 70 | 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/ |
72 | 72 | end |
73 | 73 | end |
74 | 74 |
|
|
80 | 80 | to_return(:body => '', :status => 200, :headers => {}) |
81 | 81 | end |
82 | 82 |
|
83 | | - it { should respond_to(:get_token) } |
| 83 | + it { is_expected.to respond_to(:get_token) } |
84 | 84 |
|
85 | 85 | it "should make the authorization request" do |
86 | 86 | expect { |
87 | 87 | 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 |
89 | 89 | }.to raise_error(OAuth2::Error) |
90 | 90 | end |
91 | 91 |
|
|
95 | 95 | end |
96 | 96 |
|
97 | 97 | context ".authenticated?" do |
98 | | - it { should respond_to(:authenticated?) } |
| 98 | + it { is_expected.to respond_to(:authenticated?) } |
99 | 99 |
|
100 | 100 | 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 |
103 | 103 | end |
104 | 104 |
|
105 | 105 | 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 |
108 | 108 | end |
109 | 109 |
|
110 | 110 | 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 |
113 | 113 | end |
114 | 114 | end |
115 | 115 |
|
116 | 116 | context ".basic_authed?" do |
117 | 117 | before do |
118 | | - github.stub(:basic_auth?).and_return false |
| 118 | + allow(github).to receive(:basic_auth?).and_return false |
119 | 119 | end |
120 | 120 |
|
121 | | - it { should respond_to(:basic_authed?) } |
| 121 | + it { is_expected.to respond_to(:basic_authed?) } |
122 | 122 |
|
123 | 123 | 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 |
126 | 126 | end |
127 | 127 |
|
128 | 128 | 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 |
132 | 132 | end |
133 | 133 | end |
134 | 134 |
|
135 | 135 | context "authentication" do |
136 | | - it { should respond_to(:authentication) } |
| 136 | + it { is_expected.to respond_to(:authentication) } |
137 | 137 |
|
138 | 138 | 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 |
141 | 141 | expect(github.authentication).to be_empty |
142 | 142 | end |
143 | 143 |
|
|
0 commit comments