fb_graph 1.7.5 → 1.8.0.alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile.lock +4 -2
- data/VERSION +1 -1
- data/fb_graph.gemspec +2 -1
- data/lib/fb_graph/album.rb +0 -9
- data/lib/fb_graph/connections/picture.rb +3 -2
- data/lib/fb_graph/node.rb +23 -33
- data/lib/fb_graph/query.rb +6 -10
- data/lib/fb_graph.rb +1 -0
- data/spec/fb_graph/album_spec.rb +54 -75
- data/spec/fb_graph/app_request_spec.rb +2 -2
- data/spec/fb_graph/checkin_spec.rb +2 -3
- data/spec/fb_graph/collection_spec.rb +1 -3
- data/spec/fb_graph/connection_spec.rb +6 -12
- data/spec/fb_graph/connections/accounts_spec.rb +2 -6
- data/spec/fb_graph/connections/activities_spec.rb +1 -3
- data/spec/fb_graph/connections/albums_spec.rb +2 -5
- data/spec/fb_graph/connections/app_requests_spec.rb +1 -3
- data/spec/fb_graph/connections/attending_spec.rb +2 -6
- data/spec/fb_graph/connections/books_spec.rb +1 -3
- data/spec/fb_graph/connections/checkins_spec.rb +2 -6
- data/spec/fb_graph/connections/comments_spec.rb +1 -1
- data/spec/fb_graph/connections/declined_spec.rb +2 -6
- data/spec/fb_graph/connections/events_spec.rb +1 -3
- data/spec/fb_graph/connections/family_spec.rb +1 -3
- data/spec/fb_graph/connections/feed_spec.rb +1 -3
- data/spec/fb_graph/connections/former_participants_spec.rb +1 -2
- data/spec/fb_graph/connections/friend_lists_spec.rb +1 -3
- data/spec/fb_graph/connections/friends_spec.rb +2 -6
- data/spec/fb_graph/connections/games_spec.rb +1 -3
- data/spec/fb_graph/connections/groups_spec.rb +1 -3
- data/spec/fb_graph/connections/home_spec.rb +2 -6
- data/spec/fb_graph/connections/insights_spec.rb +3 -9
- data/spec/fb_graph/connections/interests_spec.rb +1 -3
- data/spec/fb_graph/connections/invited_spec.rb +1 -3
- data/spec/fb_graph/connections/likes_spec.rb +4 -8
- data/spec/fb_graph/connections/links_spec.rb +1 -3
- data/spec/fb_graph/connections/maybe_spec.rb +1 -3
- data/spec/fb_graph/connections/members_spec.rb +1 -3
- data/spec/fb_graph/connections/messages_spec.rb +1 -4
- data/spec/fb_graph/connections/movies_spec.rb +1 -3
- data/spec/fb_graph/connections/music_spec.rb +1 -3
- data/spec/fb_graph/connections/noreply_spec.rb +1 -3
- data/spec/fb_graph/connections/notes_spec.rb +2 -5
- data/spec/fb_graph/connections/participants_spec.rb +1 -4
- data/spec/fb_graph/connections/permissions_spec.rb +1 -3
- data/spec/fb_graph/connections/photos_spec.rb +1 -3
- data/spec/fb_graph/connections/senders_spec.rb +1 -4
- data/spec/fb_graph/connections/statuses_spec.rb +2 -6
- data/spec/fb_graph/connections/subscriptions_spec.rb +3 -5
- data/spec/fb_graph/connections/television_spec.rb +1 -3
- data/spec/fb_graph/connections/test_users_spec.rb +1 -3
- data/spec/fb_graph/connections/threads_spec.rb +1 -3
- data/spec/fb_graph/connections/videos_spec.rb +1 -3
- data/spec/fb_graph/node_spec.rb +31 -28
- data/spec/fb_graph/post_spec.rb +2 -6
- data/spec/fb_graph/query/core_spec.rb +0 -10
- data/spec/fb_graph/test_user_spec.rb +5 -5
- data/spec/fb_graph/user_spec.rb +2 -6
- data/spec/helpers/webmock_helper.rb +14 -10
- data/spec/mock_json/users/home/me_private.json +2 -2
- metadata +26 -15
@@ -14,8 +14,7 @@ describe FbGraph::Connections::FormerParticipants, '#former_participants' do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
it 'should return former_participants as FbGraph::User' do
|
17
|
-
mock_graph :get, '12345/former_participants', 'thread/former_participants/private', :params => {
|
18
|
-
:access_token => 'access_token',
|
17
|
+
mock_graph :get, '12345/former_participants', 'thread/former_participants/private', :access_token => 'access_token', :params => {
|
19
18
|
:no_cache => 'true'
|
20
19
|
} do
|
21
20
|
former_participants = FbGraph::Thread.new(12345, :access_token => 'access_token').former_participants(:no_cache => true)
|
@@ -2,9 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe FbGraph::Connections::FriendLists, '#friend_lists' do
|
4
4
|
it 'should return videos as FbGraph::FriendList' do
|
5
|
-
mock_graph :get, 'matake/friendlists', 'users/friend_lists/matake', :
|
6
|
-
:access_token => 'access_token'
|
7
|
-
} do
|
5
|
+
mock_graph :get, 'matake/friendlists', 'users/friend_lists/matake', :access_token => 'access_token' do
|
8
6
|
friend_lists = FbGraph::User.new('matake', :access_token => 'access_token').friend_lists
|
9
7
|
friend_lists.each do |friend_list|
|
10
8
|
friend_list.should be_instance_of(FbGraph::FriendList)
|
@@ -14,9 +14,7 @@ describe FbGraph::Connections::Friends, '#friends' do
|
|
14
14
|
|
15
15
|
context 'when identifier is not me' do
|
16
16
|
it 'should raise FbGraph::Unauthorized' do
|
17
|
-
mock_graph :get, 'arjun/friends', 'users/friends/arjun_private', :
|
18
|
-
:access_token => 'access_token'
|
19
|
-
}, :status => [401, 'Unauthorized'] do
|
17
|
+
mock_graph :get, 'arjun/friends', 'users/friends/arjun_private', :access_token => 'access_token', :status => [401, 'Unauthorized'] do
|
20
18
|
lambda do
|
21
19
|
FbGraph::User.new('arjun', :access_token => 'access_token').friends
|
22
20
|
end.should raise_exception(FbGraph::Unauthorized)
|
@@ -36,9 +34,7 @@ describe FbGraph::Connections::Friends, '#friends' do
|
|
36
34
|
|
37
35
|
context 'when identifier is me and access_token is given' do
|
38
36
|
it 'should return friends as FbGraph::User' do
|
39
|
-
mock_graph :get, 'me/friends', 'users/friends/me_private', :
|
40
|
-
:access_token => 'access_token'
|
41
|
-
} do
|
37
|
+
mock_graph :get, 'me/friends', 'users/friends/me_private', :access_token => 'access_token' do
|
42
38
|
users = FbGraph::User.new('me', :access_token => 'access_token').friends
|
43
39
|
users.first.should == FbGraph::User.new(
|
44
40
|
'6401',
|
@@ -2,9 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe FbGraph::Connections::Activities, '#activities' do
|
4
4
|
it 'should return games as FbGraph::Page' do
|
5
|
-
mock_graph :get, 'matake/games', 'users/games/matake_private', :
|
6
|
-
:access_token => 'access_token'
|
7
|
-
} do
|
5
|
+
mock_graph :get, 'matake/games', 'users/games/matake_private', :access_token => 'access_token' do
|
8
6
|
games = FbGraph::User.new('matake', :access_token => 'access_token').games
|
9
7
|
games.class.should == FbGraph::Connection
|
10
8
|
games.first.should == FbGraph::Page.new(
|
@@ -14,9 +14,7 @@ describe FbGraph::Connections::Groups, '#groups' do
|
|
14
14
|
|
15
15
|
context 'when access_token is given' do
|
16
16
|
it 'should return groups as FbGraph::Group' do
|
17
|
-
mock_graph :get, 'matake/groups', 'users/groups/matake_private', :
|
18
|
-
:access_token => 'access_token'
|
19
|
-
} do
|
17
|
+
mock_graph :get, 'matake/groups', 'users/groups/matake_private', :access_token => 'access_token' do
|
20
18
|
groups = FbGraph::User.new('matake', :access_token => 'access_token').groups
|
21
19
|
groups.first.should == FbGraph::Group.new(
|
22
20
|
'115286585902',
|
@@ -15,9 +15,7 @@ describe FbGraph::Connections::Home, '#home' do
|
|
15
15
|
|
16
16
|
context 'when identifier is not me' do
|
17
17
|
it 'should raise FbGraph::Exception' do
|
18
|
-
mock_graph :get, 'arjun/home', 'users/home/arjun_private', :
|
19
|
-
:access_token => 'access_token'
|
20
|
-
}, :status => [400, 'BadRequest'] do
|
18
|
+
mock_graph :get, 'arjun/home', 'users/home/arjun_private', :access_token => 'access_token', :status => [400, 'BadRequest'] do
|
21
19
|
lambda do
|
22
20
|
FbGraph::User.new('arjun', :access_token => 'access_token').home
|
23
21
|
end.should raise_exception(FbGraph::Exception)
|
@@ -37,9 +35,7 @@ describe FbGraph::Connections::Home, '#home' do
|
|
37
35
|
|
38
36
|
context 'when identifier is me and access_token is given' do
|
39
37
|
it 'should return public posts in the user\'s news feed as FbGraph::Post' do
|
40
|
-
mock_graph :get, 'me/home', 'users/home/me_private', :
|
41
|
-
:access_token => 'access_token'
|
42
|
-
} do
|
38
|
+
mock_graph :get, 'me/home', 'users/home/me_private', :access_token => 'access_token' do
|
43
39
|
posts = FbGraph::User.new('me', :access_token => 'access_token').home
|
44
40
|
posts.first.should == FbGraph::Post.new(
|
45
41
|
'634033380_112599768777073',
|
@@ -15,9 +15,7 @@ describe FbGraph::Connections::Insights, '#insights' do
|
|
15
15
|
|
16
16
|
context 'when access_token is given' do
|
17
17
|
it 'should return insights as FbGraph::Insight' do
|
18
|
-
mock_graph :get, 'FbGraph/insights', 'pages/insights/FbGraph_private', :
|
19
|
-
:access_token => 'access_token'
|
20
|
-
} do
|
18
|
+
mock_graph :get, 'FbGraph/insights', 'pages/insights/FbGraph_private', :access_token => 'access_token' do
|
21
19
|
insights = FbGraph::Page.new('FbGraph').insights(:access_token => 'access_token')
|
22
20
|
insights.class.should == FbGraph::Connection
|
23
21
|
insights.first.should == FbGraph::Insight.new(
|
@@ -40,9 +38,7 @@ describe FbGraph::Connections::Insights, '#insights' do
|
|
40
38
|
|
41
39
|
context 'when metrics is given' do
|
42
40
|
it 'should treat metrics as connection scope' do
|
43
|
-
mock_graph :get, 'FbGraph/insights/page_like_adds', 'pages/insights/page_like_adds/FbGraph_private', :
|
44
|
-
:access_token => 'access_token'
|
45
|
-
} do
|
41
|
+
mock_graph :get, 'FbGraph/insights/page_like_adds', 'pages/insights/page_like_adds/FbGraph_private', :access_token => 'access_token' do
|
46
42
|
insights = FbGraph::Page.new('FbGraph').insights(:access_token => 'access_token', :metrics => :page_like_adds)
|
47
43
|
insights.options.should == {
|
48
44
|
:connection_scope => 'page_like_adds',
|
@@ -69,9 +65,7 @@ describe FbGraph::Connections::Insights, '#insights' do
|
|
69
65
|
end
|
70
66
|
|
71
67
|
it 'should support period also' do
|
72
|
-
mock_graph :get, 'FbGraph/insights/page_like_adds/day', 'pages/insights/page_like_adds/day/FbGraph_private', :
|
73
|
-
:access_token => 'access_token'
|
74
|
-
} do
|
68
|
+
mock_graph :get, 'FbGraph/insights/page_like_adds/day', 'pages/insights/page_like_adds/day/FbGraph_private', :access_token => 'access_token' do
|
75
69
|
insights = FbGraph::Page.new('FbGraph').insights(:access_token => 'access_token', :metrics => :page_like_adds, :period => :day)
|
76
70
|
insights.options.should == {
|
77
71
|
:connection_scope => 'page_like_adds/day',
|
@@ -2,9 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe FbGraph::Connections::Interests, '#interests' do
|
4
4
|
it 'should return interests pages as FbGraph::Page' do
|
5
|
-
mock_graph :get, 'matake/interests', 'users/interests/matake_private', :
|
6
|
-
:access_token => 'access_token'
|
7
|
-
} do
|
5
|
+
mock_graph :get, 'matake/interests', 'users/interests/matake_private', :access_token => 'access_token' do
|
8
6
|
pages = FbGraph::User.new('matake', :access_token => 'access_token').interests
|
9
7
|
pages.each do |page|
|
10
8
|
page.should be_instance_of(FbGraph::Page)
|
@@ -2,9 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe FbGraph::Connections::Invited, '#invited' do
|
4
4
|
it 'should return invited users as FbGraph::User' do
|
5
|
-
mock_graph :get, 'smartday/invited', 'events/invited/smartday_private', :
|
6
|
-
:access_token => 'access_token'
|
7
|
-
} do
|
5
|
+
mock_graph :get, 'smartday/invited', 'events/invited/smartday_private', :access_token => 'access_token' do
|
8
6
|
users = FbGraph::Event.new('smartday', :access_token => 'access_token').invited
|
9
7
|
users.each do |user|
|
10
8
|
user.should be_instance_of(FbGraph::User)
|
@@ -15,9 +15,7 @@ describe FbGraph::Connections::Likes, '#likes' do
|
|
15
15
|
|
16
16
|
context 'when access_token is given' do
|
17
17
|
it 'should return liked pages as FbGraph::Page' do
|
18
|
-
mock_graph :get, 'arjun/likes', 'users/likes/arjun_private', :
|
19
|
-
:access_token => 'access_token'
|
20
|
-
} do
|
18
|
+
mock_graph :get, 'arjun/likes', 'users/likes/arjun_private', :access_token => 'access_token' do
|
21
19
|
likes = FbGraph::User.new('arjun', :access_token => 'access_token').likes
|
22
20
|
likes.first.should == FbGraph::Page.new(
|
23
21
|
'378209722137',
|
@@ -36,9 +34,7 @@ describe FbGraph::Connections::Likes, '#likes' do
|
|
36
34
|
context 'when included by FbGraph::Status' do
|
37
35
|
context 'when cached collection exists' do
|
38
36
|
before do
|
39
|
-
mock_graph :get, 'with_likes', 'statuses/with_likes', :
|
40
|
-
:access_token => 'access_token'
|
41
|
-
} do
|
37
|
+
mock_graph :get, 'with_likes', 'statuses/with_likes', :access_token => 'access_token' do
|
42
38
|
@status = FbGraph::Status.new('with_likes').fetch(:access_token => 'access_token')
|
43
39
|
end
|
44
40
|
end
|
@@ -59,10 +55,10 @@ describe FbGraph::Connections::Likes, '#likes' do
|
|
59
55
|
it 'should access to Graph API' do
|
60
56
|
lambda do
|
61
57
|
@status.likes(:no_cache => true) # :no_cache has no meaning, just putting some value as options
|
62
|
-
end.should request_to('115838235152172/likes?
|
58
|
+
end.should request_to('115838235152172/likes?no_cache=true')
|
63
59
|
lambda do
|
64
60
|
@status.likes(:limit => 10)
|
65
|
-
end.should request_to('115838235152172/likes?
|
61
|
+
end.should request_to('115838235152172/likes?limit=10')
|
66
62
|
end
|
67
63
|
|
68
64
|
context 'when next/previous are obviously blank' do
|
@@ -3,9 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe FbGraph::Connections::Links, '#links' do
|
4
4
|
context 'when included by FbGraph::User' do
|
5
5
|
it 'should return notes as FbGraph::Link' do
|
6
|
-
mock_graph :get, 'matake/links', 'users/links/matake_private', :
|
7
|
-
:access_token => 'access_token'
|
8
|
-
} do
|
6
|
+
mock_graph :get, 'matake/links', 'users/links/matake_private', :access_token => 'access_token' do
|
9
7
|
links = FbGraph::User.new('matake', :access_token => 'access_token').links
|
10
8
|
links.each do |link|
|
11
9
|
link.should be_instance_of(FbGraph::Link)
|
@@ -2,9 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe FbGraph::Connections::Maybe, '#maybe' do
|
4
4
|
it 'should return maybe users as FbGraph::User' do
|
5
|
-
mock_graph :get, 'smartday/maybe', 'events/maybe/smartday_private', :
|
6
|
-
:access_token => 'access_token'
|
7
|
-
} do
|
5
|
+
mock_graph :get, 'smartday/maybe', 'events/maybe/smartday_private', :access_token => 'access_token' do
|
8
6
|
users = FbGraph::Event.new('smartday', :access_token => 'access_token').maybe
|
9
7
|
users.each do |user|
|
10
8
|
user.should be_instance_of(FbGraph::User)
|
@@ -2,9 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe FbGraph::Connections::Friends, '#friends' do
|
4
4
|
it 'should return members as FbGraph::User' do
|
5
|
-
mock_graph :get, 'emacs/members', 'groups/members/emacs_private', :
|
6
|
-
:access_token => 'access_token'
|
7
|
-
} do
|
5
|
+
mock_graph :get, 'emacs/members', 'groups/members/emacs_private', :access_token => 'access_token' do
|
8
6
|
users = FbGraph::Group.new('emacs', :access_token => 'access_token').members
|
9
7
|
users.each do |user|
|
10
8
|
user.should be_instance_of(FbGraph::User)
|
@@ -14,10 +14,7 @@ describe FbGraph::Connections::Messages, '#messages' do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
it 'should return threads as FbGraph::Message' do
|
17
|
-
mock_graph :get, '12345/messages', 'thread/messages/private', :params => {
|
18
|
-
:access_token => 'access_token',
|
19
|
-
:no_cache => 'true'
|
20
|
-
} do
|
17
|
+
mock_graph :get, '12345/messages', 'thread/messages/private', :params => {:no_cache => 'true'}, :access_token => 'access_token' do
|
21
18
|
messages = FbGraph::Thread.new(12345, :access_token => 'access_token').messages(:no_cache => true)
|
22
19
|
messages.each do |message|
|
23
20
|
message.should be_instance_of(FbGraph::Message)
|
@@ -2,9 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe FbGraph::Connections::Movies, '#movies' do
|
4
4
|
it 'should return movies pages as FbGraph::Page' do
|
5
|
-
mock_graph :get, 'matake/movies', 'users/movies/matake_private', :
|
6
|
-
:access_token => 'access_token'
|
7
|
-
} do
|
5
|
+
mock_graph :get, 'matake/movies', 'users/movies/matake_private', :access_token => 'access_token' do
|
8
6
|
pages = FbGraph::User.new('matake', :access_token => 'access_token').movies
|
9
7
|
pages.each do |page|
|
10
8
|
page.should be_instance_of(FbGraph::Page)
|
@@ -2,9 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe FbGraph::Connections::Music, '#music' do
|
4
4
|
it 'should return music pages as FbGraph::Page' do
|
5
|
-
mock_graph :get, 'matake/music', 'users/music/matake_private', :
|
6
|
-
:access_token => 'access_token'
|
7
|
-
} do
|
5
|
+
mock_graph :get, 'matake/music', 'users/music/matake_private', :access_token => 'access_token' do
|
8
6
|
pages = FbGraph::User.new('matake', :access_token => 'access_token').music
|
9
7
|
pages.each do |page|
|
10
8
|
page.should be_instance_of(FbGraph::Page)
|
@@ -2,9 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe FbGraph::Connections::Noreply, '#noreply' do
|
4
4
|
it 'should return noreply users as FbGraph::User' do
|
5
|
-
mock_graph :get, 'smartday/noreply', 'events/noreply/smartday_private', :
|
6
|
-
:access_token => 'access_token'
|
7
|
-
} do
|
5
|
+
mock_graph :get, 'smartday/noreply', 'events/noreply/smartday_private', :access_token => 'access_token' do
|
8
6
|
users = FbGraph::Event.new('smartday', :access_token => 'access_token').noreply
|
9
7
|
users.each do |user|
|
10
8
|
user.should be_instance_of(FbGraph::User)
|
@@ -3,9 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe FbGraph::Connections::Notes, '#notes' do
|
4
4
|
context 'when included by FbGraph::User' do
|
5
5
|
it 'should return notes as FbGraph::Note' do
|
6
|
-
mock_graph :get, 'matake/notes', 'users/notes/matake_private', :
|
7
|
-
:access_token => 'access_token'
|
8
|
-
} do
|
6
|
+
mock_graph :get, 'matake/notes', 'users/notes/matake_private', :access_token => 'access_token' do
|
9
7
|
notes = FbGraph::User.new('matake', :access_token => 'access_token').notes
|
10
8
|
notes.each do |note|
|
11
9
|
note.should be_instance_of(FbGraph::Note)
|
@@ -19,10 +17,9 @@ describe FbGraph::Connections::Notes, '#note!' do
|
|
19
17
|
context 'when included by FbGraph::Page' do
|
20
18
|
it 'should return generated note' do
|
21
19
|
mock_graph :post, '12345/notes', 'pages/notes/post_with_valid_access_token', :params => {
|
22
|
-
:access_token => 'valid',
|
23
20
|
:subject => 'test',
|
24
21
|
:message => 'hello'
|
25
|
-
} do
|
22
|
+
}, :access_token => 'valid' do
|
26
23
|
note = FbGraph::Page.new('12345', :access_token => 'valid').note!(:subject => 'test', :message => 'hello')
|
27
24
|
note.identifier.should == 396664845100
|
28
25
|
note.subject.should == 'test'
|
@@ -14,10 +14,7 @@ describe FbGraph::Connections::Participants, '#participants' do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
it 'should return participants as FbGraph::User' do
|
17
|
-
mock_graph :get, '12345/participants', 'thread/participants/private', :params => {
|
18
|
-
:access_token => 'access_token',
|
19
|
-
:no_cache => 'true'
|
20
|
-
} do
|
17
|
+
mock_graph :get, '12345/participants', 'thread/participants/private', :params => {:no_cache => 'true'}, :access_token => 'access_token' do
|
21
18
|
participants = FbGraph::Thread.new(12345, :access_token => 'access_token').participants(:no_cache => true)
|
22
19
|
participants.each do |participant|
|
23
20
|
participant.should be_instance_of(FbGraph::User)
|
@@ -2,9 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe FbGraph::Connections::Permissions, '#permissions' do
|
4
4
|
let :permissions do
|
5
|
-
mock_graph :get, 'me/permissions', 'users/permissions/me_private', :
|
6
|
-
:access_token => 'access_token'
|
7
|
-
} do
|
5
|
+
mock_graph :get, 'me/permissions', 'users/permissions/me_private', :access_token => 'access_token' do
|
8
6
|
FbGraph::User.me('access_token').permissions
|
9
7
|
end
|
10
8
|
end
|
@@ -3,9 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe FbGraph::Connections::Photos, '#photos' do
|
4
4
|
context 'when included by FbGraph::Album' do
|
5
5
|
it 'should return photos as FbGraph::Photo' do
|
6
|
-
mock_graph :get, '12345/photos', 'albums/photos/matake_private', :
|
7
|
-
:access_token => 'access_token'
|
8
|
-
} do
|
6
|
+
mock_graph :get, '12345/photos', 'albums/photos/matake_private', :access_token => 'access_token' do
|
9
7
|
photos = FbGraph::Album.new('12345', :access_token => 'access_token').photos
|
10
8
|
photos.each do |photo|
|
11
9
|
photo.should be_instance_of(FbGraph::Photo)
|
@@ -14,10 +14,7 @@ describe FbGraph::Connections::Senders, '#senders' do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
it 'should return senders as FbGraph::User' do
|
17
|
-
mock_graph :get, '12345/senders', 'thread/senders/private', :params => {
|
18
|
-
:access_token => 'access_token',
|
19
|
-
:no_cache => 'true'
|
20
|
-
} do
|
17
|
+
mock_graph :get, '12345/senders', 'thread/senders/private', :params => {:no_cache => 'true'}, :access_token => 'access_token' do
|
21
18
|
senders = FbGraph::Thread.new(12345, :access_token => 'access_token').senders(:no_cache => true)
|
22
19
|
senders.each do |sender|
|
23
20
|
sender.should be_instance_of(FbGraph::User)
|
@@ -15,9 +15,7 @@ describe FbGraph::Connections::Statuses, '#statuses' do
|
|
15
15
|
|
16
16
|
context 'when access_token is given' do
|
17
17
|
it 'should return statuses as FbGraph::Status' do
|
18
|
-
mock_graph :get, 'arjun/statuses', 'users/statuses/arjun_private', :
|
19
|
-
:access_token => 'access_token'
|
20
|
-
} do
|
18
|
+
mock_graph :get, 'arjun/statuses', 'users/statuses/arjun_private', :access_token => 'access_token' do
|
21
19
|
statuses = FbGraph::User.new('arjun', :access_token => 'access_token').statuses
|
22
20
|
statuses.first.should == FbGraph::Status.new(
|
23
21
|
'113559395341627',
|
@@ -50,9 +48,7 @@ describe FbGraph::Connections::Statuses, '#statuses' do
|
|
50
48
|
|
51
49
|
context 'when access_token is given' do
|
52
50
|
it 'should return statuses as FbGraph::Status' do
|
53
|
-
mock_graph :get, 'platform/statuses', 'pages/statuses/platform_private', :
|
54
|
-
:access_token => 'access_token'
|
55
|
-
} do
|
51
|
+
mock_graph :get, 'platform/statuses', 'pages/statuses/platform_private', :access_token => 'access_token' do
|
56
52
|
statuses = FbGraph::Page.new('platform', :access_token => 'access_token').statuses
|
57
53
|
statuses.first.should == FbGraph::Status.new(
|
58
54
|
'111081598927600',
|
@@ -4,9 +4,7 @@ describe FbGraph::Connections::Subscriptions, '#subscriptions' do
|
|
4
4
|
context 'when included by FbGraph::Application' do
|
5
5
|
context 'when access_token is given' do
|
6
6
|
it 'should return liked pages as FbGraph::Page' do
|
7
|
-
mock_graph :get, 'fb_graph/subscriptions', 'applications/subscriptions/fb_graph_private', :
|
8
|
-
:access_token => 'access_token'
|
9
|
-
} do
|
7
|
+
mock_graph :get, 'fb_graph/subscriptions', 'applications/subscriptions/fb_graph_private', :access_token => 'access_token' do
|
10
8
|
subscriptions = FbGraph::Application.new('fb_graph', :access_token => 'access_token').subscriptions
|
11
9
|
subscriptions.each do |subscription|
|
12
10
|
subscription.should be_instance_of(FbGraph::Subscription)
|
@@ -40,10 +38,10 @@ describe FbGraph::Connections::Subscriptions, '#unsubscribe!' do
|
|
40
38
|
end
|
41
39
|
|
42
40
|
it 'should DELETE /:app_id/subscriptions' do
|
43
|
-
|
41
|
+
mock_graph :delete, 'fb_graph/subscriptions', 'true', :params => {:object => 'user'}, :access_token => 'access_token' do
|
44
42
|
@app.unsubscribe!(
|
45
43
|
:object => 'user'
|
46
44
|
)
|
47
|
-
end
|
45
|
+
end
|
48
46
|
end
|
49
47
|
end
|
@@ -2,9 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe FbGraph::Connections::Television, '#television' do
|
4
4
|
it 'should return television pages as FbGraph::Page' do
|
5
|
-
mock_graph :get, 'matake/television', 'users/television/matake_private', :
|
6
|
-
:access_token => 'access_token'
|
7
|
-
} do
|
5
|
+
mock_graph :get, 'matake/television', 'users/television/matake_private', :access_token => 'access_token' do
|
8
6
|
pages = FbGraph::User.new('matake', :access_token => 'access_token').television
|
9
7
|
pages.each do |page|
|
10
8
|
page.should be_instance_of(FbGraph::Page)
|
@@ -15,9 +15,7 @@ describe FbGraph::Connections::TestUsers, '#test_users' do
|
|
15
15
|
|
16
16
|
context 'when access_token is given' do
|
17
17
|
it 'should return test_users as FbGraph::TestUser' do
|
18
|
-
mock_graph :get, 'client_id/accounts/test-users', 'applications/test_users/private', :
|
19
|
-
:access_token => 'access_token'
|
20
|
-
} do
|
18
|
+
mock_graph :get, 'client_id/accounts/test-users', 'applications/test_users/private', :access_token => 'access_token' do
|
21
19
|
@app.access_token = 'access_token'
|
22
20
|
test_users = @app.test_users
|
23
21
|
test_users.each do |test_user|
|
@@ -2,9 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe FbGraph::Connections::Threads, '#threads' do
|
4
4
|
it 'should return threads as FbGraph::Thread' do
|
5
|
-
mock_graph :get, 'me/threads', 'users/threads/me_private', :
|
6
|
-
:access_token => 'access_token'
|
7
|
-
} do
|
5
|
+
mock_graph :get, 'me/threads', 'users/threads/me_private', :access_token => 'access_token' do
|
8
6
|
threads = FbGraph::User.me('access_token').threads
|
9
7
|
threads.each do |thread|
|
10
8
|
thread.should be_instance_of(FbGraph::Thread)
|
@@ -2,9 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe FbGraph::Connections::Videos, '#videos' do
|
4
4
|
it 'should return videos as FbGraph::Video' do
|
5
|
-
mock_graph :get, 'kirk/videos', 'users/videos/kirk_private', :
|
6
|
-
:access_token => 'access_token'
|
7
|
-
} do
|
5
|
+
mock_graph :get, 'kirk/videos', 'users/videos/kirk_private', :access_token => 'access_token' do
|
8
6
|
videos = FbGraph::User.new('kirk', :access_token => 'access_token').videos
|
9
7
|
videos.each do |video|
|
10
8
|
video.should be_instance_of(FbGraph::Video)
|
data/spec/fb_graph/node_spec.rb
CHANGED
@@ -1,51 +1,54 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe FbGraph::Node
|
3
|
+
describe FbGraph::Node do
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
describe '.new' do
|
6
|
+
it 'should setup endpoint' do
|
7
|
+
FbGraph::Node.new('matake').endpoint.should == File.join(FbGraph::ROOT_URL, 'matake')
|
8
|
+
end
|
8
9
|
|
9
|
-
|
10
|
-
|
10
|
+
it 'should support access_token option' do
|
11
|
+
FbGraph::Node.new('matake', :access_token => 'access_token').access_token.should == 'access_token'
|
12
|
+
end
|
11
13
|
end
|
12
14
|
|
13
|
-
|
15
|
+
describe '#build_params' do
|
16
|
+
it 'should make all values to JSON or String' do
|
17
|
+
client = Rack::OAuth2::Client.new(:identifier => 'client_id', :secret => 'client_secret')
|
18
|
+
node = FbGraph::Node.new('identifier')
|
19
|
+
params = node.send :build_params, {:hash => {:a => :b}, :array => [:a, :b], :integer => 123}
|
20
|
+
params[:hash].should == '{"a":"b"}'
|
21
|
+
params[:array].should == '["a","b"]'
|
22
|
+
params[:integer].should == '123'
|
23
|
+
end
|
14
24
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
params[:array].should == '["a","b"]'
|
22
|
-
end
|
25
|
+
it 'should support Rack::OAuth2::AccessToken as self.access_token' do
|
26
|
+
client = Rack::OAuth2::Client.new(:identifier => 'client_id', :secret => 'client_secret')
|
27
|
+
node = FbGraph::Node.new('identifier', :access_token => Rack::OAuth2::AccessToken::Legacy.new(:access_token => 'token'))
|
28
|
+
params = node.send :build_params, {}
|
29
|
+
params[:oauth_token].should == 'token'
|
30
|
+
end
|
23
31
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
32
|
+
it 'should support OAuth2::AccessToken as options[:access_token]' do
|
33
|
+
client = Rack::OAuth2::Client.new(:identifier => 'client_id', :secret => 'client_secret')
|
34
|
+
node = FbGraph::Node.new('identifier')
|
35
|
+
params = node.send :build_params, {:access_token => Rack::OAuth2::AccessToken::Legacy.new(:access_token => 'token')}
|
36
|
+
params[:oauth_token].should == 'token'
|
37
|
+
end
|
29
38
|
end
|
30
39
|
|
31
|
-
it 'should support OAuth2::AccessToken as options[:access_token]' do
|
32
|
-
client = Rack::OAuth2::Client.new(:identifier => 'client_id', :secret => 'client_secret')
|
33
|
-
node = FbGraph::Node.new('identifier')
|
34
|
-
params = node.send :stringfy_params, {:access_token => Rack::OAuth2::AccessToken::Legacy.new(:access_token => 'token')}
|
35
|
-
params[:access_token].should == 'token'
|
36
|
-
end
|
37
40
|
end
|
38
41
|
|
39
42
|
describe FbGraph::Node, '#handle_response' do
|
40
43
|
it 'should handle null/false response' do
|
41
44
|
node = FbGraph::Node.new('identifier')
|
42
45
|
null_response = node.send :handle_response do
|
43
|
-
|
46
|
+
HTTP::Message.new_response 'null'
|
44
47
|
end
|
45
48
|
null_response.should be_nil
|
46
49
|
lambda do
|
47
50
|
node.send :handle_response do
|
48
|
-
|
51
|
+
HTTP::Message.new_response 'false'
|
49
52
|
end
|
50
53
|
end.should raise_error(
|
51
54
|
FbGraph::NotFound,
|
data/spec/fb_graph/post_spec.rb
CHANGED
@@ -119,9 +119,7 @@ describe FbGraph::Post, '#fetch' do
|
|
119
119
|
|
120
120
|
context 'when access_token given' do
|
121
121
|
it 'shold get all attributes and comments' do
|
122
|
-
mock_graph :get, 'platform', 'posts/platform_private', :
|
123
|
-
:access_token => 'access_token'
|
124
|
-
} do
|
122
|
+
mock_graph :get, 'platform', 'posts/platform_private', :access_token => 'access_token' do
|
125
123
|
post = FbGraph::Post.fetch('platform', :access_token => 'access_token')
|
126
124
|
post.identifier.should == '19292868552_118464504835613'
|
127
125
|
post.from.should == FbGraph::Page.new(
|
@@ -173,9 +171,7 @@ describe FbGraph::Post, '#to' do
|
|
173
171
|
|
174
172
|
context 'when include Group' do
|
175
173
|
let :post do
|
176
|
-
mock_graph :get, 'to_group', 'posts/to_group', :
|
177
|
-
:access_token => 'access_token'
|
178
|
-
} do
|
174
|
+
mock_graph :get, 'to_group', 'posts/to_group', :access_token => 'access_token' do
|
179
175
|
FbGraph::Post.fetch('to_group', :access_token => 'access_token')
|
180
176
|
end
|
181
177
|
end
|
@@ -10,16 +10,6 @@ describe FbGraph::Query do
|
|
10
10
|
query.query.should == raw_query
|
11
11
|
query.access_token.should == 'access_token'
|
12
12
|
end
|
13
|
-
|
14
|
-
it 'should setup proper endpoint' do
|
15
|
-
endpoint = query.send :build_endpoint
|
16
|
-
params = {
|
17
|
-
:query => raw_query,
|
18
|
-
:format => :json,
|
19
|
-
:access_token => 'access_token'
|
20
|
-
}
|
21
|
-
endpoint.should == "#{FbGraph::Query::ENDPOINT}?#{params.to_query}"
|
22
|
-
end
|
23
13
|
end
|
24
14
|
|
25
15
|
describe '.fetch' do
|
@@ -28,8 +28,8 @@ describe FbGraph::TestUser, '.friend!' do
|
|
28
28
|
end
|
29
29
|
|
30
30
|
it 'should POST twice' do
|
31
|
-
mock_graph :post, '111/friends/222', 'true' do
|
32
|
-
mock_graph :post, '222/friends/111', 'true' do
|
31
|
+
mock_graph :post, '111/friends/222', 'true', :access_token => 'token1' do
|
32
|
+
mock_graph :post, '222/friends/111', 'true', :access_token => 'token2' do
|
33
33
|
@u1.friend! @u2
|
34
34
|
end
|
35
35
|
end
|
@@ -39,12 +39,12 @@ end
|
|
39
39
|
|
40
40
|
describe FbGraph::TestUser, '.destroy' do
|
41
41
|
before do
|
42
|
-
@user = FbGraph::TestUser.new(111, :access_token => '
|
42
|
+
@user = FbGraph::TestUser.new(111, :access_token => 'access_token')
|
43
43
|
end
|
44
44
|
|
45
45
|
it 'should DELETE /user_id' do
|
46
|
-
|
46
|
+
mock_graph :delete, '111', 'true', :access_token => 'access_token' do
|
47
47
|
@user.destroy
|
48
|
-
end
|
48
|
+
end
|
49
49
|
end
|
50
50
|
end
|
data/spec/fb_graph/user_spec.rb
CHANGED
@@ -46,9 +46,7 @@ describe FbGraph::User, '.fetch' do
|
|
46
46
|
|
47
47
|
context 'when access_token given' do
|
48
48
|
it 'should get current user profile' do
|
49
|
-
mock_graph :get, 'me', 'users/me_private', :
|
50
|
-
:access_token => 'access_token'
|
51
|
-
} do
|
49
|
+
mock_graph :get, 'me', 'users/me_private', :access_token => 'access_token' do
|
52
50
|
user = FbGraph::User.me('access_token').fetch
|
53
51
|
user.interested_in.should == ['female']
|
54
52
|
user.meeting_for.should == ['Friendship', 'Networking']
|
@@ -81,9 +79,7 @@ describe FbGraph::User, '.fetch' do
|
|
81
79
|
|
82
80
|
context 'when access_token given' do
|
83
81
|
it 'should get public + private profile' do
|
84
|
-
mock_graph :get, 'arjun', 'users/arjun_private', :
|
85
|
-
:access_token => 'access_token'
|
86
|
-
} do
|
82
|
+
mock_graph :get, 'arjun', 'users/arjun_private', :access_token => 'access_token' do
|
87
83
|
user = FbGraph::User.fetch('arjun', :access_token => 'access_token')
|
88
84
|
|
89
85
|
# public
|