|
5 | 5 | subject { OmniAuth::Strategies::LinkedIn.new(nil) }
|
6 | 6 |
|
7 | 7 | it 'should add a camelization for itself' do
|
8 |
| - OmniAuth::Utils.camelize('linkedin').should == 'LinkedIn' |
| 8 | + expect(OmniAuth::Utils.camelize('linkedin')).to eq('LinkedIn') |
9 | 9 | end
|
10 | 10 |
|
11 | 11 | describe '#client' do
|
12 | 12 | it 'has correct LinkedIn site' do
|
13 |
| - subject.client.site.should eq('https://api.linkedin.com') |
| 13 | + expect(subject.client.site).to eq('https://api.linkedin.com') |
14 | 14 | end
|
15 | 15 |
|
16 | 16 | it 'has correct authorize url' do
|
17 |
| - subject.client.options[:authorize_url].should eq('https://www.linkedin.com/uas/oauth2/authorization?response_type=code') |
| 17 | + expect(subject.client.options[:authorize_url]).to eq('https://www.linkedin.com/uas/oauth2/authorization?response_type=code') |
18 | 18 | end
|
19 | 19 |
|
20 | 20 | it 'has correct token url' do
|
21 |
| - subject.client.options[:token_url].should eq('https://www.linkedin.com/uas/oauth2/accessToken') |
| 21 | + expect(subject.client.options[:token_url]).to eq('https://www.linkedin.com/uas/oauth2/accessToken') |
22 | 22 | end
|
23 | 23 | end
|
24 | 24 |
|
25 | 25 | describe '#callback_path' do
|
26 | 26 | it 'has the correct callback path' do
|
27 |
| - subject.callback_path.should eq('/auth/linkedin/callback') |
| 27 | + expect(subject.callback_path).to eq('/auth/linkedin/callback') |
28 | 28 | end
|
29 | 29 | end
|
30 | 30 |
|
31 | 31 | describe '#uid' do
|
32 | 32 | before :each do
|
33 |
| - subject.stub(:raw_info) { { 'id' => 'uid' } } |
| 33 | + allow(subject).to receive(:raw_info) { { 'id' => 'uid' } } |
34 | 34 | end
|
35 | 35 |
|
36 | 36 | it 'returns the id from raw_info' do
|
37 |
| - subject.uid.should eq('uid') |
| 37 | + expect(subject.uid).to eq('uid') |
38 | 38 | end
|
39 | 39 | end
|
40 | 40 |
|
41 | 41 | describe '#info' do
|
42 | 42 | before :each do
|
43 |
| - subject.stub(:raw_info) { {} } |
| 43 | + allow(subject).to receive(:raw_info) { {} } |
44 | 44 | end
|
45 | 45 |
|
46 | 46 | context 'and therefore has all the necessary fields' do
|
47 |
| - it { subject.info.should have_key :name } |
48 |
| - it { subject.info.should have_key :email } |
49 |
| - it { subject.info.should have_key :nickname } |
50 |
| - it { subject.info.should have_key :first_name } |
51 |
| - it { subject.info.should have_key :last_name } |
52 |
| - it { subject.info.should have_key :location } |
53 |
| - it { subject.info.should have_key :description } |
54 |
| - it { subject.info.should have_key :image } |
55 |
| - it { subject.info.should have_key :urls } |
| 47 | + it { expect(subject.info).to have_key :name } |
| 48 | + it { expect(subject.info).to have_key :email } |
| 49 | + it { expect(subject.info).to have_key :nickname } |
| 50 | + it { expect(subject.info).to have_key :first_name } |
| 51 | + it { expect(subject.info).to have_key :last_name } |
| 52 | + it { expect(subject.info).to have_key :location } |
| 53 | + it { expect(subject.info).to have_key :description } |
| 54 | + it { expect(subject.info).to have_key :image } |
| 55 | + it { expect(subject.info).to have_key :urls } |
56 | 56 | end
|
57 | 57 | end
|
58 | 58 |
|
59 | 59 | describe '#extra' do
|
60 | 60 | before :each do
|
61 |
| - subject.stub(:raw_info) { { :foo => 'bar' } } |
| 61 | + allow(subject).to receive(:raw_info) { { :foo => 'bar' } } |
62 | 62 | end
|
63 | 63 |
|
64 |
| - it { subject.extra['raw_info'].should eq({ :foo => 'bar' }) } |
| 64 | + it { expect(subject.extra['raw_info']).to eq({ :foo => 'bar' }) } |
65 | 65 | end
|
66 | 66 |
|
67 | 67 | describe '#access_token' do
|
68 | 68 | before :each do
|
69 |
| - subject.stub(:oauth2_access_token) { double('oauth2 access token', :expires_in => 3600, :expires_at => 946688400).as_null_object } |
| 69 | + allow(subject).to receive(:oauth2_access_token) { double('oauth2 access token', :expires_in => 3600, :expires_at => 946688400).as_null_object } |
70 | 70 | end
|
71 | 71 |
|
72 |
| - it { subject.access_token.expires_in.should eq(3600) } |
73 |
| - it { subject.access_token.expires_at.should eq(946688400) } |
| 72 | + it { expect(subject.access_token.expires_in).to eq(3600) } |
| 73 | + it { expect(subject.access_token.expires_at).to eq(946688400) } |
74 | 74 | end
|
75 | 75 |
|
76 | 76 | describe '#raw_info' do
|
77 | 77 | before :each do
|
78 | 78 | access_token = double('access token')
|
79 | 79 | response = double('response', :parsed => { :foo => 'bar' })
|
80 |
| - access_token.should_receive(:get).with("/v1/people/~:(baz,qux)?format=json").and_return(response) |
| 80 | + expect(access_token).to receive(:get).with("/v1/people/~:(baz,qux)?format=json").and_return(response) |
81 | 81 |
|
82 |
| - subject.stub(:option_fields) { ['baz', 'qux'] } |
83 |
| - subject.stub(:access_token) { access_token } |
| 82 | + allow(subject).to receive(:option_fields) { ['baz', 'qux'] } |
| 83 | + allow(subject).to receive(:access_token) { access_token } |
84 | 84 | end
|
85 | 85 |
|
86 | 86 | it 'returns parsed response from access token' do
|
87 |
| - subject.raw_info.should eq({ :foo => 'bar' }) |
| 87 | + expect(subject.raw_info).to eq({ :foo => 'bar' }) |
88 | 88 | end
|
89 | 89 | end
|
90 | 90 |
|
|
95 | 95 | end
|
96 | 96 |
|
97 | 97 | it 'sets default scope' do
|
98 |
| - subject.authorize_params['scope'].should eq('r_basicprofile r_emailaddress') |
| 98 | + expect(subject.authorize_params['scope']).to eq('r_basicprofile r_emailaddress') |
99 | 99 | end
|
100 | 100 | end
|
101 | 101 | end
|
102 | 102 |
|
103 | 103 | describe '#option_fields' do
|
104 | 104 | it 'returns options fields' do
|
105 | 105 | subject.stub(:options => double('options', :fields => ['foo', 'bar']).as_null_object)
|
106 |
| - subject.send(:option_fields).should eq(['foo', 'bar']) |
| 106 | + expect(subject.send(:option_fields)).to eq(['foo', 'bar']) |
107 | 107 | end
|
108 | 108 |
|
109 | 109 | it 'http avatar image by default' do
|
110 | 110 | subject.stub(:options => double('options', :fields => ['picture-url']))
|
111 |
| - subject.options.stub(:[]).with(:secure_image_url).and_return(false) |
112 |
| - subject.send(:option_fields).should eq(['picture-url']) |
| 111 | + allow(subject.options).to receive(:[]).with(:secure_image_url).and_return(false) |
| 112 | + expect(subject.send(:option_fields)).to eq(['picture-url']) |
113 | 113 | end
|
114 | 114 |
|
115 | 115 | it 'https avatar image if secure_image_url truthy' do
|
116 | 116 | subject.stub(:options => double('options', :fields => ['picture-url']))
|
117 |
| - subject.options.stub(:[]).with(:secure_image_url).and_return(true) |
118 |
| - subject.send(:option_fields).should eq(['picture-url;secure=true']) |
| 117 | + allow(subject.options).to receive(:[]).with(:secure_image_url).and_return(true) |
| 118 | + expect(subject.send(:option_fields)).to eq(['picture-url;secure=true']) |
119 | 119 | end
|
120 | 120 | end
|
121 | 121 | end
|
0 commit comments