evri_rpx 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +5 -0
- data/CHANGELOG.markdown +10 -0
- data/LICENSE +21 -0
- data/README.markdown +144 -0
- data/Rakefile +73 -0
- data/VERSION +1 -0
- data/certs/cacert.pem +3154 -0
- data/evri_rpx.gemspec +82 -0
- data/lib/evri/rpx.rb +4 -0
- data/lib/evri/rpx/contact.rb +18 -0
- data/lib/evri/rpx/contact_list.rb +27 -0
- data/lib/evri/rpx/credentials.rb +65 -0
- data/lib/evri/rpx/mappings.rb +19 -0
- data/lib/evri/rpx/session.rb +161 -0
- data/lib/evri/rpx/user.rb +105 -0
- data/lib/evri_rpx.rb +13 -0
- data/spec/evri/rpx/contact_list_spec.rb +39 -0
- data/spec/evri/rpx/contact_spec.rb +19 -0
- data/spec/evri/rpx/credentials_spec.rb +98 -0
- data/spec/evri/rpx/mappings_spec.rb +21 -0
- data/spec/evri/rpx/session_spec.rb +154 -0
- data/spec/evri/rpx/user_spec.rb +336 -0
- data/spec/fixtures/contacts/bob_johnson.json +9 -0
- data/spec/fixtures/credentials/dbalatero_facebook.json +32 -0
- data/spec/fixtures/credentials/dbalatero_twitter.json +19 -0
- data/spec/fixtures/credentials/dbalatero_windowslive.json +15 -0
- data/spec/fixtures/mappings/identifiers.json +7 -0
- data/spec/fixtures/session/all_mappings.json +12 -0
- data/spec/fixtures/session/get_contacts.json +63 -0
- data/spec/fixtures/session/map.json +3 -0
- data/spec/fixtures/session/normal_error.json +7 -0
- data/spec/fixtures/session/service_down_error.json +7 -0
- data/spec/fixtures/session/unmap.json +3 -0
- data/spec/fixtures/user/dbalatero_facebook.json +31 -0
- data/spec/fixtures/user/dbalatero_gmail.json +20 -0
- data/spec/fixtures/user/dbalatero_twitter.json +19 -0
- data/spec/fixtures/user/dbalatero_windows_live.json +15 -0
- data/spec/fixtures/user/dbalatero_yahoo.json +17 -0
- data/spec/spec_helper.rb +20 -0
- metadata +101 -0
data/lib/evri_rpx.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__)))
|
2
|
+
|
3
|
+
require 'json'
|
4
|
+
require 'net/http'
|
5
|
+
require 'net/https'
|
6
|
+
|
7
|
+
require 'evri/rpx'
|
8
|
+
require 'evri/rpx/contact'
|
9
|
+
require 'evri/rpx/contact_list'
|
10
|
+
require 'evri/rpx/credentials'
|
11
|
+
require 'evri/rpx/mappings'
|
12
|
+
require 'evri/rpx/session'
|
13
|
+
require 'evri/rpx/user'
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'spec_helper'))
|
2
|
+
|
3
|
+
describe Evri::RPX::ContactList do
|
4
|
+
before(:all) do
|
5
|
+
@list = Evri::RPX::ContactList.new(json_fixture('session/get_contacts.json'))
|
6
|
+
end
|
7
|
+
|
8
|
+
describe "total_results" do
|
9
|
+
it "should return the total results for a user's contact list" do
|
10
|
+
@list.total_results.should == 5
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "start_index" do
|
15
|
+
it "should return the start index used in pagination" do
|
16
|
+
@list.start_index.should == 1
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "items_per_page" do
|
21
|
+
it "should return the items per page, for pagination" do
|
22
|
+
@list.items_per_page.should == 5
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe "contacts" do
|
27
|
+
it "should return an array of Contact objects" do
|
28
|
+
@list.contacts.each do |contact|
|
29
|
+
contact.should be_a_kind_of(Evri::RPX::Contact)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should include Bob Johnson" do
|
34
|
+
@list.contacts.select { |contact|
|
35
|
+
contact.display_name == 'Bob Johnson'
|
36
|
+
}.should_not be_nil
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'spec_helper'))
|
2
|
+
|
3
|
+
describe Evri::RPX::Contact do
|
4
|
+
before(:all) do
|
5
|
+
@contact = Evri::RPX::Contact.new(json_fixture('contacts/bob_johnson.json'))
|
6
|
+
end
|
7
|
+
|
8
|
+
describe "display_name" do
|
9
|
+
it "should be the correct display name in the response" do
|
10
|
+
@contact.display_name.should == 'Bob Johnson'
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "emails" do
|
15
|
+
it "should return a list of emails for a given user" do
|
16
|
+
@contact.emails.should == ['bob@example.com']
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,98 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'spec_helper'))
|
2
|
+
|
3
|
+
describe Evri::RPX::Credentials do
|
4
|
+
describe "parsing OAuth (twitter) credentials" do
|
5
|
+
before(:all) do
|
6
|
+
json = json_fixture('credentials/dbalatero_twitter.json')
|
7
|
+
@credentials = Evri::RPX::Credentials.new(json['accessCredentials'])
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "oauth?" do
|
11
|
+
it "should be true" do
|
12
|
+
@credentials.oauth?.should be_true
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "type" do
|
17
|
+
it "should be OAuth" do
|
18
|
+
@credentials.type.should == 'OAuth'
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "oauth_token" do
|
23
|
+
it "should be the oauth token given" do
|
24
|
+
@credentials.oauth_token.should == '35834683-jBU3o-snip'
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "oauth_token_secret" do
|
29
|
+
it "should be the secret given" do
|
30
|
+
@credentials.oauth_token_secret.should == '2GjoAgV5-snip'
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "parsing Windows Live credentials" do
|
36
|
+
before(:all) do
|
37
|
+
json = json_fixture('credentials/dbalatero_windowslive.json')
|
38
|
+
@credentials = Evri::RPX::Credentials.new(json['accessCredentials'])
|
39
|
+
end
|
40
|
+
|
41
|
+
describe "windows_live?" do
|
42
|
+
it "should be true" do
|
43
|
+
@credentials.windows_live?.should be_true
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe "type" do
|
48
|
+
it "should be WindowsLive" do
|
49
|
+
@credentials.type.should == 'WindowsLive'
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe "windows_live_eact" do
|
54
|
+
it "should be the eact field given" do
|
55
|
+
@credentials.windows_live_eact.should == 'eact%3DJvtJUb4%252Bx1InXqjglTBWX-snip'
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
|
61
|
+
describe "parsing Facebook credentials" do
|
62
|
+
before(:all) do
|
63
|
+
json = json_fixture('credentials/dbalatero_facebook.json')
|
64
|
+
@credentials = Evri::RPX::Credentials.new(json['accessCredentials'])
|
65
|
+
end
|
66
|
+
|
67
|
+
describe "facebook?" do
|
68
|
+
it "should be true" do
|
69
|
+
@credentials.facebook?.should be_true
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
describe "type" do
|
74
|
+
it "should be Facebook" do
|
75
|
+
@credentials.type.should == 'Facebook'
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
describe "facebook_session_key" do
|
80
|
+
it "should be the session key given" do
|
81
|
+
@credentials.facebook_session_key.should == '2.7kr3H8W-snip'
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
describe "facebook_uid" do
|
86
|
+
it "should be the UID given" do
|
87
|
+
@credentials.facebook_uid.should == '10701789'
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
describe "facebook_expires" do
|
92
|
+
it "should be the correct Time object" do
|
93
|
+
@credentials.facebook_expires.should == Time.at(1245196800)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
end
|
98
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'spec_helper'))
|
2
|
+
|
3
|
+
describe Evri::RPX::Mappings do
|
4
|
+
describe "identifiers" do
|
5
|
+
it "should return the identifiers present in the response" do
|
6
|
+
json = json_fixture('mappings/identifiers.json')
|
7
|
+
mappings = Evri::RPX::Mappings.new(json)
|
8
|
+
mappings.identifiers.should include("http://brian.myopenid.com/")
|
9
|
+
mappings.identifiers.should include("http://brianellin.com/")
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "raw/json" do
|
14
|
+
it "should return the raw JSON that was passed to the constructor" do
|
15
|
+
json = {}
|
16
|
+
mappings = Evri::RPX::Mappings.new(json)
|
17
|
+
mappings.raw.should == json
|
18
|
+
mappings.json.should == json
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,154 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'spec_helper'))
|
2
|
+
|
3
|
+
describe Evri::RPX::Session do
|
4
|
+
before(:all) do
|
5
|
+
@session = Evri::RPX::Session.new('fake_api_key')
|
6
|
+
end
|
7
|
+
|
8
|
+
describe "api_key" do
|
9
|
+
it "should return the current API key" do
|
10
|
+
@session.api_key.should == 'fake_api_key'
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "auth_info" do
|
15
|
+
after(:each) do
|
16
|
+
FakeWeb.clean_registry
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should raise an APICallError if RPX returns an error message" do
|
20
|
+
FakeWeb.register_uri(:get,
|
21
|
+
'https://rpxnow.com:443/api/v2/auth_info',
|
22
|
+
:file => fixture_path('session/normal_error.json'),
|
23
|
+
:status => ['400', 'Bad Request'])
|
24
|
+
lambda {
|
25
|
+
@session.auth_info('errortoken')
|
26
|
+
}.should raise_error(Evri::RPX::Session::APICallError)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should raise ServiceUnavailableError if the service is not available" do
|
30
|
+
FakeWeb.register_uri(:get,
|
31
|
+
'https://rpxnow.com:443/api/v2/auth_info',
|
32
|
+
:file => fixture_path('session/service_down_error.json'),
|
33
|
+
:status => ['404', 'Not Found'])
|
34
|
+
lambda {
|
35
|
+
@session.auth_info('errortoken')
|
36
|
+
}.should raise_error(Evri::RPX::Session::ServiceUnavailableError)
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should return a User object for a mapping" do
|
40
|
+
FakeWeb.register_uri(:get,
|
41
|
+
'https://rpxnow.com:443/api/v2/auth_info',
|
42
|
+
:file => fixture_path('user/dbalatero_gmail.json'))
|
43
|
+
|
44
|
+
result = @session.auth_info('mytoken')
|
45
|
+
result.should be_a_kind_of(Evri::RPX::User)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe "all_mappings" do
|
50
|
+
it "should return a set of identifiers to mappings" do
|
51
|
+
FakeWeb.register_uri(:get,
|
52
|
+
'https://rpxnow.com:443/api/v2/all_mappings',
|
53
|
+
:file => fixture_path('session/all_mappings.json'))
|
54
|
+
result = @session.all_mappings
|
55
|
+
result['1'].should == ['http://cygnus.myopenid.com/']
|
56
|
+
result['2'].should == ['http://brianellin.com/', 'http://brian.myopenid.com/']
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe "get_contacts" do
|
61
|
+
before(:each) do
|
62
|
+
FakeWeb.register_uri(:get,
|
63
|
+
'https://rpxnow.com:443/api/v2/get_contacts',
|
64
|
+
:file => fixture_path('session/get_contacts.json'))
|
65
|
+
end
|
66
|
+
|
67
|
+
after(:each) do
|
68
|
+
FakeWeb.clean_registry
|
69
|
+
end
|
70
|
+
|
71
|
+
it "should return a contacts list for a identifier string" do
|
72
|
+
result = @session.get_contacts('http://brian.myopenid.com/')
|
73
|
+
result.should be_a_kind_of(Evri::RPX::ContactList)
|
74
|
+
|
75
|
+
result.contacts.should have(6).things
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should return a contacts list for a user string" do
|
79
|
+
user = mock('user')
|
80
|
+
user.should_receive(:identifier).and_return('http://brian.myopenid.com/')
|
81
|
+
|
82
|
+
result = @session.get_contacts(user)
|
83
|
+
result.should be_a_kind_of(Evri::RPX::ContactList)
|
84
|
+
|
85
|
+
result.contacts.should have(6).things
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
describe "map" do
|
90
|
+
before(:each) do
|
91
|
+
FakeWeb.register_uri(:get,
|
92
|
+
'https://rpxnow.com:443/api/v2/map',
|
93
|
+
:file => fixture_path('session/map.json'))
|
94
|
+
end
|
95
|
+
|
96
|
+
it "should take in a User object as the second parameter" do
|
97
|
+
user = mock('user')
|
98
|
+
user.should_receive(:identifier).and_return('https://www.facebook.com/dbalatero')
|
99
|
+
|
100
|
+
result = @session.map(user, 50)
|
101
|
+
result.should be_true
|
102
|
+
end
|
103
|
+
|
104
|
+
it "should take in a identifier string as the second parameter" do
|
105
|
+
result = @session.map('https://www.facebook.com/dbalatero', 50)
|
106
|
+
result.should be_true
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
describe "mappings" do
|
111
|
+
it "should return a Mappings object" do
|
112
|
+
FakeWeb.register_uri(:get,
|
113
|
+
'https://rpxnow.com:443/api/v2/mappings',
|
114
|
+
:file => fixture_path('mappings/identifiers.json'))
|
115
|
+
|
116
|
+
result = @session.mappings('dbalatero')
|
117
|
+
result.should be_a_kind_of(Evri::RPX::Mappings)
|
118
|
+
result.identifiers.should_not be_empty
|
119
|
+
end
|
120
|
+
|
121
|
+
it "should take a User object in" do
|
122
|
+
FakeWeb.register_uri(:get,
|
123
|
+
'https://rpxnow.com:443/api/v2/mappings',
|
124
|
+
:file => fixture_path('mappings/identifiers.json'))
|
125
|
+
user = mock('user')
|
126
|
+
user.should_receive(:primary_key).and_return('dbalatero')
|
127
|
+
|
128
|
+
result = @session.mappings(user)
|
129
|
+
result.should be_a_kind_of(Evri::RPX::Mappings)
|
130
|
+
result.identifiers.should_not be_empty
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
describe "unmap" do
|
135
|
+
before(:each) do
|
136
|
+
FakeWeb.register_uri(:get,
|
137
|
+
'https://rpxnow.com:443/api/v2/unmap',
|
138
|
+
:file => fixture_path('session/unmap.json'))
|
139
|
+
end
|
140
|
+
|
141
|
+
it "should take a string as the identifier" do
|
142
|
+
result = @session.unmap('https://www.facebook.com/dbalatero', 50)
|
143
|
+
result.should be_true
|
144
|
+
end
|
145
|
+
|
146
|
+
it "should take a User as the identifier" do
|
147
|
+
user = mock('user')
|
148
|
+
user.should_receive(:identifier).and_return('https://www.facebook.com/dbalatero')
|
149
|
+
|
150
|
+
result = @session.unmap(user, 50)
|
151
|
+
result.should be_true
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
@@ -0,0 +1,336 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'spec_helper'))
|
2
|
+
|
3
|
+
describe Evri::RPX::User do
|
4
|
+
describe "initialize" do
|
5
|
+
it "should not accept any JSON hash that doesn't have profile data in it" do
|
6
|
+
lambda {
|
7
|
+
Evri::RPX::User.new({})
|
8
|
+
}.should raise_error(Evri::RPX::User::InvalidUserJsonError)
|
9
|
+
|
10
|
+
lambda {
|
11
|
+
Evri::RPX::User.new(nil)
|
12
|
+
}.should raise_error(Evri::RPX::User::InvalidUserJsonError)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "other?" do
|
17
|
+
it "should return true if the provider_name is Other" do
|
18
|
+
user = Evri::RPX::User.new({ 'profile' => {} })
|
19
|
+
user.should_receive(:provider_name).and_return('Other')
|
20
|
+
|
21
|
+
user.other?.should be_true
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "raw / json methods" do
|
26
|
+
it "should return the raw JSON that was passed to the constructor" do
|
27
|
+
json = { 'profile' => { 'email' => 'foo@bar.com' } }
|
28
|
+
user = Evri::RPX::User.new(json)
|
29
|
+
user.raw.should == json
|
30
|
+
user.json.should == json
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "parsing Twitter logins" do
|
35
|
+
before(:all) do
|
36
|
+
json = json_fixture('user/dbalatero_twitter.json')
|
37
|
+
@user = Evri::RPX::User.new(json)
|
38
|
+
end
|
39
|
+
|
40
|
+
describe "name" do
|
41
|
+
it "should be equal to the formatted name" do
|
42
|
+
@user.name.should == 'David Balatero'
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe "photo" do
|
47
|
+
it "should be a valid photo" do
|
48
|
+
@user.photo.should =~ /http:\/\/s3\.amazonaws\.com/
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe "display_name" do
|
53
|
+
it "should be the displayName in the JSON" do
|
54
|
+
@user.display_name.should == 'David Balatero'
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe 'profile_url' do
|
59
|
+
it "should point to the user's Twitter page" do
|
60
|
+
@user.profile_url.should == 'http://twitter.com/dbalatero'
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe 'username' do
|
65
|
+
it "should be the user's Twitter username" do
|
66
|
+
@user.username.should == 'dbalatero'
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
describe 'primary_key' do
|
71
|
+
it "should be nil" do
|
72
|
+
@user.primary_key.should be_nil
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe 'identifier' do
|
77
|
+
it "should be the identifier that Twitter gives" do
|
78
|
+
@user.identifier.should =~ /user_id=35834683/
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
describe "twitter?" do
|
83
|
+
it "should be true for Twitter responses" do
|
84
|
+
@user.twitter?.should be_true
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
describe "credentials" do
|
89
|
+
it "should not be nil" do
|
90
|
+
@user.credentials.should_not be_nil
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
describe 'provider_name' do
|
95
|
+
it 'should be Twitter' do
|
96
|
+
@user.provider_name.should == 'Twitter'
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
# Google logins
|
102
|
+
describe "parsing Google logins" do
|
103
|
+
before(:all) do
|
104
|
+
json = json_fixture('user/dbalatero_gmail.json')
|
105
|
+
@user = Evri::RPX::User.new(json)
|
106
|
+
end
|
107
|
+
|
108
|
+
describe "name" do
|
109
|
+
it "should be equal to the formatted name" do
|
110
|
+
@user.name.should == 'David Balatero'
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
describe "photo" do
|
115
|
+
it "should be nil" do
|
116
|
+
@user.photo.should be_nil
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
describe "display_name" do
|
121
|
+
it "should be the displayName in the JSON" do
|
122
|
+
@user.display_name.should == 'dbalatero'
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
describe 'profile_url' do
|
127
|
+
it "should be nil" do
|
128
|
+
@user.profile_url.should be_nil
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
describe 'username' do
|
133
|
+
it "should be the user's Google username" do
|
134
|
+
@user.username.should == 'dbalatero'
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
describe 'primary_key' do
|
139
|
+
it "should be set to the correct mapping" do
|
140
|
+
@user.primary_key.should == 'DavidBalateroTestRPXX'
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
describe 'identifier' do
|
145
|
+
it "should be the identifier that Twitter gives" do
|
146
|
+
@user.identifier.should =~ /https:\/\/www.google.com\/accounts/
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
describe "google?" do
|
151
|
+
it "should be true for Google responses" do
|
152
|
+
@user.google?.should be_true
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
describe "credentials" do
|
157
|
+
it "should be nil" do
|
158
|
+
@user.credentials.should be_nil
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
describe 'provider_name' do
|
163
|
+
it 'should be Google' do
|
164
|
+
@user.provider_name.should == 'Google'
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
describe "email" do
|
169
|
+
it "should be set to dbalatero@gmail.com" do
|
170
|
+
@user.email.should == 'dbalatero@gmail.com'
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
# Facebook logins
|
176
|
+
describe "parsing Facebook logins" do
|
177
|
+
before(:all) do
|
178
|
+
json = json_fixture('user/dbalatero_facebook.json')
|
179
|
+
@user = Evri::RPX::User.new(json)
|
180
|
+
end
|
181
|
+
|
182
|
+
describe "name" do
|
183
|
+
it "should be equal to the formatted name" do
|
184
|
+
@user.name.should == 'David Balatero'
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
describe "photo" do
|
189
|
+
it "should be a Facebook profile picture." do
|
190
|
+
@user.photo.should_not be_nil
|
191
|
+
@user.photo.should =~ /http:\/\/profile\.ak\.facebook\.com/
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
describe "display_name" do
|
196
|
+
it "should be the displayName in the JSON" do
|
197
|
+
@user.display_name.should == 'David Balatero'
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
describe 'profile_url' do
|
202
|
+
it "should be the correct Facebook profile URL" do
|
203
|
+
@user.profile_url.should == 'http://www.facebook.com/profile.php?id=10701789'
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
describe 'username' do
|
208
|
+
it "should be the user's Google username" do
|
209
|
+
@user.username.should == 'DavidBalatero'
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
213
|
+
describe 'identifier' do
|
214
|
+
it "should be the identifier that Twitter gives" do
|
215
|
+
@user.identifier.should == 'http://www.facebook.com/profile.php?id=10701789'
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
describe "facebook?" do
|
220
|
+
it "should be true for Google responses" do
|
221
|
+
@user.facebook?.should be_true
|
222
|
+
end
|
223
|
+
end
|
224
|
+
|
225
|
+
describe "credentials" do
|
226
|
+
it "should be set" do
|
227
|
+
@user.credentials.should_not be_nil
|
228
|
+
end
|
229
|
+
end
|
230
|
+
|
231
|
+
describe 'provider_name' do
|
232
|
+
it 'should be Facebook' do
|
233
|
+
@user.provider_name.should == 'Facebook'
|
234
|
+
end
|
235
|
+
end
|
236
|
+
end
|
237
|
+
|
238
|
+
# Yahoo logins
|
239
|
+
describe "parsing Yahoo logins" do
|
240
|
+
before(:all) do
|
241
|
+
json = json_fixture('user/dbalatero_yahoo.json')
|
242
|
+
@user = Evri::RPX::User.new(json)
|
243
|
+
end
|
244
|
+
|
245
|
+
describe "name" do
|
246
|
+
it "should be equal to the formatted name" do
|
247
|
+
@user.name.should == 'David Balatero'
|
248
|
+
end
|
249
|
+
end
|
250
|
+
|
251
|
+
describe "photo" do
|
252
|
+
it "should be nil" do
|
253
|
+
@user.photo.should be_nil
|
254
|
+
end
|
255
|
+
end
|
256
|
+
|
257
|
+
describe "display_name" do
|
258
|
+
it "should be the displayName in the JSON" do
|
259
|
+
@user.display_name.should == 'David Balatero'
|
260
|
+
end
|
261
|
+
end
|
262
|
+
|
263
|
+
describe 'profile_url' do
|
264
|
+
it "should be nil" do
|
265
|
+
@user.profile_url.should be_nil
|
266
|
+
end
|
267
|
+
end
|
268
|
+
|
269
|
+
describe 'username' do
|
270
|
+
it "should be the user's Yahoo username" do
|
271
|
+
@user.username.should == 'David'
|
272
|
+
end
|
273
|
+
end
|
274
|
+
|
275
|
+
describe 'primary_key' do
|
276
|
+
it "should be nil" do
|
277
|
+
@user.primary_key.should == 'David'
|
278
|
+
end
|
279
|
+
end
|
280
|
+
|
281
|
+
describe 'identifier' do
|
282
|
+
it "should be the identifier that Yahoo gives" do
|
283
|
+
@user.identifier.should =~ /https:\/\/me\.yahoo\.com/
|
284
|
+
end
|
285
|
+
end
|
286
|
+
|
287
|
+
describe 'email' do
|
288
|
+
it "should be dbalatero@yahoo.com" do
|
289
|
+
@user.email.should == 'dbalatero@yahoo.com'
|
290
|
+
end
|
291
|
+
end
|
292
|
+
|
293
|
+
describe "yahoo?" do
|
294
|
+
it "should be true for Yahoo responses" do
|
295
|
+
@user.yahoo?.should be_true
|
296
|
+
end
|
297
|
+
end
|
298
|
+
|
299
|
+
describe "credentials" do
|
300
|
+
it "should be nil" do
|
301
|
+
@user.credentials.should be_nil
|
302
|
+
end
|
303
|
+
end
|
304
|
+
|
305
|
+
describe 'provider_name' do
|
306
|
+
it 'should be Yahoo' do
|
307
|
+
@user.provider_name.should == 'Yahoo!'
|
308
|
+
end
|
309
|
+
end
|
310
|
+
end
|
311
|
+
|
312
|
+
describe "parsing Windows Live logins" do
|
313
|
+
before(:all) do
|
314
|
+
json = json_fixture('user/dbalatero_windows_live.json')
|
315
|
+
@user = Evri::RPX::User.new(json)
|
316
|
+
end
|
317
|
+
|
318
|
+
describe "windows_live?" do
|
319
|
+
it "should be true" do
|
320
|
+
@user.windows_live?.should be_true
|
321
|
+
end
|
322
|
+
end
|
323
|
+
|
324
|
+
describe "credentials" do
|
325
|
+
it "should not be nil" do
|
326
|
+
@user.credentials.should_not be_nil
|
327
|
+
end
|
328
|
+
end
|
329
|
+
|
330
|
+
describe "email" do
|
331
|
+
it "should be correct" do
|
332
|
+
@user.email.should == 'dbalatero16@hotmail.com'
|
333
|
+
end
|
334
|
+
end
|
335
|
+
end
|
336
|
+
end
|