Codebase list ruby-omniauth-twitter / 81bf3ec
Merge pull request #96 from arunagw/ry-add-email-in-response add email in response closes #95 Rashmi Yadav 8 years ago
2 changed file(s) with 46 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
1515 {
1616 :nickname => raw_info['screen_name'],
1717 :name => raw_info['name'],
18 :email => raw_info["email"],
1819 :location => raw_info['location'],
1920 :image => image_url,
2021 :description => raw_info['description'],
3031 end
3132
3233 def raw_info
33 @raw_info ||= JSON.load(access_token.get('/1.1/account/verify_credentials.json?include_entities=false&skip_status=true').body)
34 @raw_info ||= JSON.load(access_token.get('/1.1/account/verify_credentials.json?include_entities=false&skip_status=true&include_email=true').body)
3435 rescue ::Errno::ETIMEDOUT
3536 raise ::Timeout::Error
3637 end
2222
2323 it 'should have correct authorize url' do
2424 expect(subject.options.client_options.authorize_path).to eq('/oauth/authenticate')
25 end
26 end
27
28 describe 'info' do
29 before do
30 allow(subject).to receive(:raw_info).and_return(raw_info_hash)
31 end
32
33 it 'should returns the nickname' do
34 expect(subject.info[:nickname]).to eq(raw_info_hash['screen_name'])
35 end
36
37 it 'should returns the name' do
38 expect(subject.info[:name]).to eq(raw_info_hash['name'])
39 end
40
41 it 'should returns the email' do
42 expect(subject.info[:email]).to eq(raw_info_hash['email'])
43 end
44
45 it 'should returns the location' do
46 expect(subject.info[:location]).to eq(raw_info_hash['location'])
47 end
48
49 it 'should returns the description' do
50 expect(subject.info[:description]).to eq(raw_info_hash['description'])
51 end
52
53 it 'should returns the urls' do
54 expect(subject.info[:urls]['Website']).to eq(raw_info_hash['url'])
55 expect(subject.info[:urls]['Twitter']).to eq("https://twitter.com/#{raw_info_hash['screen_name']}")
2556 end
2657 end
2758
112143 end
113144 end
114145 end
146
147 private
148
149 def raw_info_hash
150 {
151 'screen_name' => 'foo',
152 'name' => 'Foo Bar',
153 'email' => 'foo@example.com',
154 'location' => 'India',
155 'description' => 'Developer',
156 'url' => 'example.com/foobar'
157 }
158 end