Merge pull request #96 from arunagw/ry-add-email-in-response
add email in response closes #95
Rashmi Yadav
8 years ago
15 | 15 |
{
|
16 | 16 |
:nickname => raw_info['screen_name'],
|
17 | 17 |
:name => raw_info['name'],
|
|
18 |
:email => raw_info["email"],
|
18 | 19 |
:location => raw_info['location'],
|
19 | 20 |
:image => image_url,
|
20 | 21 |
:description => raw_info['description'],
|
|
30 | 31 |
end
|
31 | 32 |
|
32 | 33 |
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)
|
34 | 35 |
rescue ::Errno::ETIMEDOUT
|
35 | 36 |
raise ::Timeout::Error
|
36 | 37 |
end
|
22 | 22 |
|
23 | 23 |
it 'should have correct authorize url' do
|
24 | 24 |
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']}")
|
25 | 56 |
end
|
26 | 57 |
end
|
27 | 58 |
|
|
112 | 143 |
end
|
113 | 144 |
end
|
114 | 145 |
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
|