/
twitter_spec.rb
56 lines (48 loc) · 1.91 KB
/
twitter_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
require 'spec_helper'
describe OmniAuth::Strategies::Twitter do
subject do
args = ['appid', 'secret', @options || {}].compact
OmniAuth::Strategies::Twitter.new(*args)
end
describe 'client options' do
it 'should have correct name' do
expect(subject.options.name).to eq('twitter')
end
it 'should have correct site' do
expect(subject.options.client_options.site).to eq('https://api.twitter.com')
end
it 'should have correct authorize url' do
expect(subject.options.client_options.authorize_path).to eq('/oauth/authenticate')
end
end
describe 'image_size option' do
context 'when user has an image' do
it 'should return image with size specified' do
@options = { :image_size => 'original' }
subject.stub(:raw_info).and_return(
{ 'profile_image_url' => 'http://twimg0-a.akamaihd.net/sticky/default_profile_images/default_profile_0_normal.png' }
)
expect(subject.info[:image]).to eq('http://twimg0-a.akamaihd.net/sticky/default_profile_images/default_profile_0.png')
end
it 'should return normal image by default' do
subject.stub(:raw_info).and_return(
{ 'profile_image_url' => 'http://twimg0-a.akamaihd.net/sticky/default_profile_images/default_profile_0_normal.png' }
)
expect(subject.info[:image]).to eq('http://twimg0-a.akamaihd.net/sticky/default_profile_images/default_profile_0_normal.png')
end
end
end
describe 'request_phase' do
context 'with no request params set and x_auth_access_type specified' do
before do
subject.options[:request_params] = nil
subject.stub(:session).and_return(
{'omniauth.params' => {'x_auth_access_type' => 'read'}})
subject.stub(:old_request_phase).and_return(:whatever)
end
it 'should not break' do
expect { subject.request_phase }.not_to raise_error
end
end
end
end