fb_graph 1.7.1 → 1.7.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +21 -0
- data/.rspec +2 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +52 -0
- data/README.rdoc +1 -0
- data/Rakefile +8 -34
- data/VERSION +1 -1
- data/fb_graph.gemspec +15 -433
- data/lib/fb_graph/connections/family.rb +14 -0
- data/lib/fb_graph/connections/permissions.rb +12 -0
- data/lib/fb_graph/page/category_attributes.rb +1 -0
- data/lib/fb_graph/user.rb +4 -1
- data/lib/fb_graph.rb +0 -1
- data/spec/fb_graph/application_spec.rb +8 -14
- data/spec/fb_graph/auth_spec.rb +1 -1
- data/spec/fb_graph/checkin_spec.rb +15 -11
- data/spec/fb_graph/collection_spec.rb +8 -7
- data/spec/fb_graph/connection_spec.rb +36 -25
- data/spec/fb_graph/connections/accounts_spec.rb +30 -26
- data/spec/fb_graph/connections/activities_spec.rb +19 -18
- data/spec/fb_graph/connections/albums_spec.rb +40 -37
- data/spec/fb_graph/connections/app_requests_spec.rb +7 -7
- data/spec/fb_graph/connections/attending_spec.rb +12 -12
- data/spec/fb_graph/connections/books_spec.rb +18 -17
- data/spec/fb_graph/connections/checkins_spec.rb +91 -91
- data/spec/fb_graph/connections/comments_spec.rb +41 -48
- data/spec/fb_graph/connections/declined_spec.rb +13 -9
- data/spec/fb_graph/connections/events_spec.rb +31 -32
- data/spec/fb_graph/connections/family_spec.rb +34 -0
- data/spec/fb_graph/connections/feed_spec.rb +65 -70
- data/spec/fb_graph/connections/former_participants_spec.rb +8 -7
- data/spec/fb_graph/connections/friend_lists_spec.rb +7 -7
- data/spec/fb_graph/connections/friends_spec.rb +29 -24
- data/spec/fb_graph/connections/games_spec.rb +15 -15
- data/spec/fb_graph/connections/groups_spec.rb +17 -16
- data/spec/fb_graph/connections/home_spec.rb +40 -35
- data/spec/fb_graph/connections/insights_spec.rb +74 -70
- data/spec/fb_graph/connections/interests_spec.rb +7 -7
- data/spec/fb_graph/connections/invited_spec.rb +7 -7
- data/spec/fb_graph/connections/likes_spec.rb +23 -19
- data/spec/fb_graph/connections/links_spec.rb +17 -19
- data/spec/fb_graph/connections/maybe_spec.rb +10 -12
- data/spec/fb_graph/connections/members_spec.rb +7 -7
- data/spec/fb_graph/connections/messages_spec.rb +8 -7
- data/spec/fb_graph/connections/movies_spec.rb +7 -7
- data/spec/fb_graph/connections/music_spec.rb +7 -7
- data/spec/fb_graph/connections/noreply_spec.rb +7 -7
- data/spec/fb_graph/connections/notes_spec.rb +18 -16
- data/spec/fb_graph/connections/participants_spec.rb +8 -7
- data/spec/fb_graph/connections/permissions_spec.rb +18 -0
- data/spec/fb_graph/connections/photos_spec.rb +24 -24
- data/spec/fb_graph/connections/posts_spec.rb +23 -26
- data/spec/fb_graph/connections/senders_spec.rb +8 -7
- data/spec/fb_graph/connections/statuses_spec.rb +45 -43
- data/spec/fb_graph/connections/subscriptions_spec.rb +7 -7
- data/spec/fb_graph/connections/tagged_spec.rb +30 -33
- data/spec/fb_graph/connections/television_spec.rb +7 -7
- data/spec/fb_graph/connections/test_users_spec.rb +13 -9
- data/spec/fb_graph/connections/threads_spec.rb +7 -7
- data/spec/fb_graph/connections/videos_spec.rb +7 -7
- data/spec/fb_graph/page/local_business_spec.rb +4 -4
- data/spec/fb_graph/page/movie_spec.rb +4 -4
- data/spec/fb_graph/page/music_spec.rb +4 -4
- data/spec/fb_graph/page/person_spec.rb +4 -4
- data/spec/fb_graph/page/product_spec.rb +4 -4
- data/spec/fb_graph/page_spec.rb +8 -16
- data/spec/fb_graph/post_spec.rb +50 -46
- data/spec/fb_graph/query/core_spec.rb +39 -51
- data/spec/fb_graph/searchable_spec.rb +13 -9
- data/spec/fb_graph/test_user_spec.rb +5 -11
- data/spec/fb_graph/user_spec.rb +96 -91
- data/spec/helpers/webmock_helper.rb +71 -0
- data/spec/{fake_json → mock_json}/albums/photos/matake_private.json +0 -0
- data/spec/{fake_json → mock_json}/albums/photos/post_with_valid_access_token.json +0 -0
- data/spec/{fake_json → mock_json}/applications/feed/public.json +0 -0
- data/spec/{fake_json → mock_json}/applications/subscriptions/fb_graph_private.json +0 -0
- data/spec/{fake_json → mock_json}/applications/test_users/created.json +0 -0
- data/spec/{fake_json → mock_json}/applications/test_users/private.json +0 -0
- data/spec/{fake_json → mock_json}/checkins/search_private.json +0 -0
- data/spec/{fake_json → mock_json}/checkins/search_public.json +0 -0
- data/spec/{fake_json → mock_json}/events/attending/post_with_valid_access_token.json +0 -0
- data/spec/{fake_json → mock_json}/events/attending/smartday_private.json +0 -0
- data/spec/{fake_json → mock_json}/events/declined/post_with_valid_access_token.json +0 -0
- data/spec/{fake_json → mock_json}/events/declined/smartday_private.json +0 -0
- data/spec/{fake_json → mock_json}/events/invited/smartday_private.json +0 -0
- data/spec/{fake_json → mock_json}/events/maybe/post_with_valid_access_token.json +0 -0
- data/spec/{fake_json → mock_json}/events/maybe/smartday_private.json +0 -0
- data/spec/{fake_json → mock_json}/events/noreply/smartday_private.json +0 -0
- data/spec/{fake_json → mock_json}/groups/members/emacs_private.json +0 -0
- data/spec/{fake_json → mock_json}/pages/categories/local_business.json +0 -0
- data/spec/{fake_json → mock_json}/pages/categories/movie.json +0 -0
- data/spec/{fake_json → mock_json}/pages/categories/music.json +0 -0
- data/spec/{fake_json → mock_json}/pages/categories/person.json +0 -0
- data/spec/{fake_json → mock_json}/pages/categories/product.json +0 -0
- data/spec/{fake_json → mock_json}/pages/checkins/gowalla_private.json +0 -0
- data/spec/{fake_json → mock_json}/pages/checkins/gowalla_public.json +0 -0
- data/spec/{fake_json → mock_json}/pages/insights/FbGraph_private.json +0 -0
- data/spec/{fake_json → mock_json}/pages/insights/FbGraph_public.json +0 -0
- data/spec/{fake_json → mock_json}/pages/insights/page_like_adds/FbGraph_private.json +0 -0
- data/spec/{fake_json → mock_json}/pages/insights/page_like_adds/day/FbGraph_private.json +0 -0
- data/spec/{fake_json → mock_json}/pages/notes/post_with_valid_access_token.json +0 -0
- data/spec/{fake_json → mock_json}/pages/platform_private.json +0 -0
- data/spec/{fake_json → mock_json}/pages/platform_public.json +0 -0
- data/spec/{fake_json → mock_json}/pages/search_fb_graph.json +0 -0
- data/spec/{fake_json → mock_json}/pages/search_google.json +0 -0
- data/spec/{fake_json → mock_json}/pages/statuses/platform_private.json +0 -0
- data/spec/{fake_json → mock_json}/pages/statuses/platform_public.json +0 -0
- data/spec/{fake_json → mock_json}/posts/comments/post_with_invalid_access_token.json +0 -0
- data/spec/{fake_json → mock_json}/posts/comments/post_with_valid_access_token.json +0 -0
- data/spec/{fake_json → mock_json}/posts/comments/post_without_access_token.json +0 -0
- data/spec/{fake_json → mock_json}/posts/likes/post_with_invalid_access_token.json +0 -0
- data/spec/{fake_json → mock_json}/posts/likes/post_with_valid_access_token.json +0 -0
- data/spec/{fake_json → mock_json}/posts/likes/post_without_access_token.json +0 -0
- data/spec/{fake_json → mock_json}/posts/no_comments.json +0 -0
- data/spec/{fake_json → mock_json}/posts/platform_private.json +0 -0
- data/spec/{fake_json → mock_json}/posts/platform_public.json +0 -0
- data/spec/{fake_json → mock_json}/posts/to_application.json +0 -0
- data/spec/{fake_json → mock_json}/posts/to_event.json +0 -0
- data/spec/{fake_json → mock_json}/posts/to_group.json +0 -0
- data/spec/{fake_json → mock_json}/query/user/with_invalid_token.json +0 -0
- data/spec/{fake_json → mock_json}/query/user/with_valid_token.json +0 -0
- data/spec/{fake_json → mock_json}/query/user/without_token.json +0 -0
- data/spec/{fake_json → mock_json}/statuses/with_likes.json +0 -0
- data/spec/{fake_json → mock_json}/thread/former_participants/private.json +0 -0
- data/spec/{fake_json → mock_json}/thread/messages/private.json +0 -0
- data/spec/{fake_json → mock_json}/thread/participants/private.json +0 -0
- data/spec/{fake_json → mock_json}/thread/senders/private.json +0 -0
- data/spec/{fake_json → mock_json}/token_response.json +0 -0
- data/spec/{fake_json → mock_json}/true.json +0 -0
- data/spec/{fake_json → mock_json}/users/accounts/matake_private.json +0 -0
- data/spec/{fake_json → mock_json}/users/accounts/matake_private_with_manage_pages_permission.json +0 -0
- data/spec/{fake_json → mock_json}/users/accounts/matake_public.json +0 -0
- data/spec/{fake_json → mock_json}/users/activities/arjun_private.json +0 -0
- data/spec/{fake_json → mock_json}/users/activities/arjun_public.json +0 -0
- data/spec/{fake_json → mock_json}/users/albums/matake_private.json +0 -0
- data/spec/{fake_json → mock_json}/users/albums/matake_public.json +0 -0
- data/spec/{fake_json → mock_json}/users/albums/post_with_valid_access_token.json +0 -0
- data/spec/{fake_json → mock_json}/users/app_requests/me_private.json +0 -0
- data/spec/{fake_json → mock_json}/users/arjun_private.json +0 -0
- data/spec/{fake_json → mock_json}/users/arjun_public.json +0 -0
- data/spec/{fake_json → mock_json}/users/books/matake_private.json +0 -0
- data/spec/{fake_json → mock_json}/users/books/matake_public.json +0 -0
- data/spec/{fake_json → mock_json}/users/checkins/mattt_private.json +0 -0
- data/spec/{fake_json → mock_json}/users/checkins/mattt_public.json +0 -0
- data/spec/{fake_json → mock_json}/users/checkins/posted.json +0 -0
- data/spec/{fake_json → mock_json}/users/events/matake_private.json +0 -0
- data/spec/{fake_json → mock_json}/users/events/matake_public.json +0 -0
- data/spec/{fake_json → mock_json}/users/events/post_with_valid_access_token.json +0 -0
- data/spec/mock_json/users/family/family_without_access_token.json +6 -0
- data/spec/mock_json/users/family/me_public.json +19 -0
- data/spec/{fake_json → mock_json}/users/feed/arjun_private.json +0 -0
- data/spec/{fake_json → mock_json}/users/feed/arjun_public.json +0 -0
- data/spec/{fake_json → mock_json}/users/feed/post_with_invalid_access_token.json +0 -0
- data/spec/{fake_json → mock_json}/users/feed/post_with_valid_access_token.json +0 -0
- data/spec/{fake_json → mock_json}/users/feed/post_without_access_token.json +0 -0
- data/spec/{fake_json → mock_json}/users/friend_lists/matake.json +0 -0
- data/spec/{fake_json → mock_json}/users/friends/arjun_private.json +0 -0
- data/spec/{fake_json → mock_json}/users/friends/arjun_public.json +0 -0
- data/spec/{fake_json → mock_json}/users/friends/me_private.json +0 -0
- data/spec/{fake_json → mock_json}/users/friends/me_public.json +0 -0
- data/spec/{fake_json → mock_json}/users/games/matake_private.json +0 -0
- data/spec/{fake_json → mock_json}/users/groups/matake_private.json +0 -0
- data/spec/{fake_json → mock_json}/users/groups/matake_public.json +0 -0
- data/spec/{fake_json → mock_json}/users/home/arjun_private.json +0 -0
- data/spec/{fake_json → mock_json}/users/home/arjun_public.json +0 -0
- data/spec/{fake_json → mock_json}/users/home/me_private.json +0 -0
- data/spec/{fake_json → mock_json}/users/home/me_private_next.json +0 -0
- data/spec/{fake_json → mock_json}/users/home/me_private_previous.json +0 -0
- data/spec/{fake_json → mock_json}/users/home/me_public.json +0 -0
- data/spec/{fake_json → mock_json}/users/interests/matake_private.json +0 -0
- data/spec/{fake_json → mock_json}/users/likes/arjun_private.json +0 -0
- data/spec/{fake_json → mock_json}/users/likes/arjun_public.json +0 -0
- data/spec/{fake_json → mock_json}/users/links/matake_private.json +0 -0
- data/spec/{fake_json → mock_json}/users/links/post_with_valid_access_token.json +0 -0
- data/spec/{fake_json → mock_json}/users/me_private.json +0 -0
- data/spec/{fake_json → mock_json}/users/me_public.json +0 -0
- data/spec/{fake_json → mock_json}/users/movies/matake_private.json +0 -0
- data/spec/{fake_json → mock_json}/users/music/matake_private.json +0 -0
- data/spec/{fake_json → mock_json}/users/notes/matake_private.json +0 -0
- data/spec/mock_json/users/permissions/me_private.json +70 -0
- data/spec/{fake_json → mock_json}/users/posts/arjun_private.json +0 -0
- data/spec/{fake_json → mock_json}/users/posts/arjun_public.json +0 -0
- data/spec/{fake_json → mock_json}/users/statuses/arjun_private.json +0 -0
- data/spec/{fake_json → mock_json}/users/statuses/arjun_public.json +0 -0
- data/spec/{fake_json → mock_json}/users/tagged/arjun_private.json +0 -0
- data/spec/{fake_json → mock_json}/users/tagged/arjun_public.json +0 -0
- data/spec/{fake_json → mock_json}/users/television/matake_private.json +0 -0
- data/spec/{fake_json → mock_json}/users/threads/me_private.json +0 -0
- data/spec/{fake_json → mock_json}/users/videos/kirk_private.json +0 -0
- data/spec/spec_helper.rb +2 -7
- metadata +267 -128
- data/.rspec-tm +0 -1
- data/spec/helpers/fake_json_helper.rb +0 -37
- data/spec/spec.opts +0 -3
@@ -2,62 +2,63 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe FbGraph::Connections::Feed, '#feed' do
|
4
4
|
context 'when included by FbGraph::User' do
|
5
|
-
before do
|
6
|
-
fake_json(:get, 'arjun/feed', 'users/feed/arjun_public')
|
7
|
-
fake_json(:get, 'arjun/feed?access_token=access_token', 'users/feed/arjun_private')
|
8
|
-
end
|
9
|
-
|
10
5
|
context 'when no access_token given' do
|
11
6
|
it 'should return public posts on the user\'s wall as FbGraph::Post' do
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
:
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
:
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
7
|
+
mock_graph :get, 'arjun/feed', 'users/feed/arjun_public' do
|
8
|
+
posts = FbGraph::User.new('arjun').feed
|
9
|
+
posts.first.should == FbGraph::Post.new(
|
10
|
+
'7901103_121392141207495',
|
11
|
+
:from => {
|
12
|
+
:id => '7901103',
|
13
|
+
:name => 'Arjun Banker'
|
14
|
+
},
|
15
|
+
:picture => 'http://external.ak.fbcdn.net/safe_image.php?d=d2cc5beedaa401ba54eccc9014647285&w=130&h=130&url=http%3A%2F%2Fimages.ted.com%2Fimages%2Fted%2F269_389x292.jpg',
|
16
|
+
:link => 'http://www.ted.com/talks/wade_davis_on_endangered_cultures.html',
|
17
|
+
:name => 'Wade Davis on endangered cultures | Video on TED.com',
|
18
|
+
:caption => 'www.ted.com',
|
19
|
+
:description => 'TED Talks With stunning photos and stories, National Geographic Explorer Wade Davis celebrates the extraordinary diversity of the world\'s indigenous cultures, which are disappearing from the planet at an alarming rate.',
|
20
|
+
:icon => 'http://static.ak.fbcdn.net/rsrc.php/z9XZ8/hash/976ulj6z.gif',
|
21
|
+
:created_time => '2010-04-25T04:05:32+0000',
|
22
|
+
:updated_time => '2010-04-25T04:05:32+0000',
|
23
|
+
:privacy => {
|
24
|
+
:value => 'EVERYONE'
|
25
|
+
}
|
26
|
+
)
|
27
|
+
posts.each do |post|
|
28
|
+
post.should be_instance_of(FbGraph::Post)
|
29
|
+
end
|
33
30
|
end
|
34
31
|
end
|
35
32
|
end
|
36
33
|
|
37
34
|
context 'when access_token is given' do
|
38
35
|
it 'should return posts on the user\'s wall as FbGraph::Post' do
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
:access_token => 'access_token'
|
43
|
-
|
44
|
-
|
45
|
-
:
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
:
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
36
|
+
mock_graph :get, 'arjun/feed', 'users/feed/arjun_private', :params => {
|
37
|
+
:access_token => 'access_token'
|
38
|
+
} do
|
39
|
+
posts = FbGraph::User.new('arjun').feed(:access_token => 'access_token')
|
40
|
+
posts.first.should == FbGraph::Post.new(
|
41
|
+
'7901103_121392141207495',
|
42
|
+
:access_token => 'access_token',
|
43
|
+
:from => {
|
44
|
+
:id => '7901103',
|
45
|
+
:name => 'Arjun Banker'
|
46
|
+
},
|
47
|
+
:picture => 'http://external.ak.fbcdn.net/safe_image.php?d=d2cc5beedaa401ba54eccc9014647285&w=130&h=130&url=http%3A%2F%2Fimages.ted.com%2Fimages%2Fted%2F269_389x292.jpg',
|
48
|
+
:link => 'http://www.ted.com/talks/wade_davis_on_endangered_cultures.html',
|
49
|
+
:name => 'Wade Davis on endangered cultures | Video on TED.com',
|
50
|
+
:caption => 'www.ted.com',
|
51
|
+
:description => 'TED Talks With stunning photos and stories, National Geographic Explorer Wade Davis celebrates the extraordinary diversity of the world\'s indigenous cultures, which are disappearing from the planet at an alarming rate.',
|
52
|
+
:icon => 'http://static.ak.fbcdn.net/rsrc.php/z9XZ8/hash/976ulj6z.gif',
|
53
|
+
:created_time => '2010-04-25T04:05:32+0000',
|
54
|
+
:updated_time => '2010-04-25T04:05:32+0000',
|
55
|
+
:privacy => {
|
56
|
+
:value => 'EVERYONE'
|
57
|
+
}
|
58
|
+
)
|
59
|
+
posts.each do |post|
|
60
|
+
post.should be_instance_of(FbGraph::Post)
|
61
|
+
end
|
61
62
|
end
|
62
63
|
end
|
63
64
|
end
|
@@ -67,39 +68,33 @@ end
|
|
67
68
|
describe FbGraph::Connections::Feed, '#feed!' do
|
68
69
|
context 'when included by FbGraph::User' do
|
69
70
|
context 'when no access_token given' do
|
70
|
-
before do
|
71
|
-
fake_json(:post, 'matake/feed', 'users/feed/post_without_access_token', :status => [500, 'Internal Server Error'])
|
72
|
-
end
|
73
|
-
|
74
71
|
it 'should raise FbGraph::Exception' do
|
75
|
-
|
76
|
-
|
77
|
-
|
72
|
+
mock_graph :post, 'matake/feed', 'users/feed/post_without_access_token', :status => [500, 'Internal Server Error'] do
|
73
|
+
lambda do
|
74
|
+
FbGraph::User.new('matake').feed!(:message => 'hello')
|
75
|
+
end.should raise_exception(FbGraph::Exception)
|
76
|
+
end
|
78
77
|
end
|
79
78
|
end
|
80
79
|
|
81
80
|
context 'when invalid access_token is given' do
|
82
|
-
before do
|
83
|
-
fake_json(:post, 'matake/feed', 'users/feed/post_with_invalid_access_token', :status => [500, 'Internal Server Error'])
|
84
|
-
end
|
85
|
-
|
86
81
|
it 'should raise FbGraph::Exception' do
|
87
|
-
|
88
|
-
|
89
|
-
|
82
|
+
mock_graph :post, 'matake/feed', 'users/feed/post_with_invalid_access_token', :status => [500, 'Internal Server Error'] do
|
83
|
+
lambda do
|
84
|
+
FbGraph::User.new('matake', :access_token => 'invalid').feed!(:message => 'hello')
|
85
|
+
end.should raise_exception(FbGraph::Exception)
|
86
|
+
end
|
90
87
|
end
|
91
88
|
end
|
92
89
|
|
93
90
|
context 'when valid access_token is given' do
|
94
|
-
before do
|
95
|
-
fake_json(:post, 'matake/feed', 'users/feed/post_with_valid_access_token')
|
96
|
-
end
|
97
|
-
|
98
91
|
it 'should return generated post' do
|
99
|
-
post
|
100
|
-
|
101
|
-
|
102
|
-
|
92
|
+
mock_graph :post, 'matake/feed', 'users/feed/post_with_valid_access_token' do
|
93
|
+
post = FbGraph::User.new('matake', :access_token => 'valid').feed!(:message => 'hello')
|
94
|
+
post.identifier.should == '579612276_401071652276'
|
95
|
+
post.message.should == 'hello'
|
96
|
+
post.access_token.should == 'valid'
|
97
|
+
end
|
103
98
|
end
|
104
99
|
end
|
105
100
|
end
|
@@ -1,10 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe FbGraph::Connections::FormerParticipants, '#former_participants' do
|
4
|
-
before do
|
5
|
-
fake_json(:get, '12345/former_participants?access_token=access_token&no_cache=true', 'thread/former_participants/private')
|
6
|
-
end
|
7
|
-
|
8
4
|
it 'should use cached contents as default' do
|
9
5
|
lambda do
|
10
6
|
FbGraph::Thread.new(12345, :access_token => 'access_token').former_participants
|
@@ -18,9 +14,14 @@ describe FbGraph::Connections::FormerParticipants, '#former_participants' do
|
|
18
14
|
end
|
19
15
|
|
20
16
|
it 'should return former_participants as FbGraph::User' do
|
21
|
-
|
22
|
-
|
23
|
-
|
17
|
+
mock_graph :get, '12345/former_participants', 'thread/former_participants/private', :params => {
|
18
|
+
:access_token => 'access_token',
|
19
|
+
:no_cache => 'true'
|
20
|
+
} do
|
21
|
+
former_participants = FbGraph::Thread.new(12345, :access_token => 'access_token').former_participants(:no_cache => true)
|
22
|
+
former_participants.each do |former_participant|
|
23
|
+
former_participant.should be_instance_of(FbGraph::User)
|
24
|
+
end
|
24
25
|
end
|
25
26
|
end
|
26
27
|
end
|
@@ -1,14 +1,14 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe FbGraph::Connections::FriendLists, '#friend_lists' do
|
4
|
-
before do
|
5
|
-
fake_json(:get, 'matake/friendlists?access_token=access_token', 'users/friend_lists/matake')
|
6
|
-
end
|
7
|
-
|
8
4
|
it 'should return videos as FbGraph::FriendList' do
|
9
|
-
|
10
|
-
|
11
|
-
|
5
|
+
mock_graph :get, 'matake/friendlists', 'users/friend_lists/matake', :params => {
|
6
|
+
:access_token => 'access_token'
|
7
|
+
} do
|
8
|
+
friend_lists = FbGraph::User.new('matake', :access_token => 'access_token').friend_lists
|
9
|
+
friend_lists.each do |friend_list|
|
10
|
+
friend_list.should be_instance_of(FbGraph::FriendList)
|
11
|
+
end
|
12
12
|
end
|
13
13
|
end
|
14
14
|
end
|
@@ -2,47 +2,52 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe FbGraph::Connections::Friends, '#friends' do
|
4
4
|
context 'when included by FbGraph::User' do
|
5
|
-
before do
|
6
|
-
fake_json(:get, 'me/friends', 'users/friends/me_public', :status => [401, 'Unauthorized'])
|
7
|
-
fake_json(:get, 'me/friends?access_token=access_token', 'users/friends/me_private')
|
8
|
-
fake_json(:get, 'arjun/friends', 'users/friends/arjun_public', :status => [401, 'Unauthorized'])
|
9
|
-
fake_json(:get, 'arjun/friends?access_token=access_token', 'users/friends/arjun_private', :status => [401, 'Unauthorized'])
|
10
|
-
end
|
11
|
-
|
12
5
|
context 'when no access_token given' do
|
13
6
|
it 'should raise FbGraph::Unauthorized' do
|
14
|
-
|
15
|
-
|
16
|
-
|
7
|
+
mock_graph :get, 'arjun/friends', 'users/friends/arjun_public', :status => [401, 'Unauthorized'] do
|
8
|
+
lambda do
|
9
|
+
FbGraph::User.new('arjun').friends
|
10
|
+
end.should raise_exception(FbGraph::Unauthorized)
|
11
|
+
end
|
17
12
|
end
|
18
13
|
end
|
19
14
|
|
20
15
|
context 'when identifier is not me' do
|
21
16
|
it 'should raise FbGraph::Unauthorized' do
|
22
|
-
|
23
|
-
|
24
|
-
|
17
|
+
mock_graph :get, 'arjun/friends', 'users/friends/arjun_private', :params => {
|
18
|
+
:access_token => 'access_token'
|
19
|
+
}, :status => [401, 'Unauthorized'] do
|
20
|
+
lambda do
|
21
|
+
FbGraph::User.new('arjun', :access_token => 'access_token').friends
|
22
|
+
end.should raise_exception(FbGraph::Unauthorized)
|
23
|
+
end
|
25
24
|
end
|
26
25
|
end
|
27
26
|
|
28
27
|
context 'when identifier is me and no access_token is given' do
|
29
28
|
it 'should raise FbGraph::Unauthorized' do
|
30
|
-
|
31
|
-
|
32
|
-
|
29
|
+
mock_graph :get, 'me/friends', 'users/friends/me_public', :status => [401, 'Unauthorized'] do
|
30
|
+
lambda do
|
31
|
+
FbGraph::User.new('me').friends
|
32
|
+
end.should raise_exception(FbGraph::Unauthorized)
|
33
|
+
end
|
33
34
|
end
|
34
35
|
end
|
35
36
|
|
36
37
|
context 'when identifier is me and access_token is given' do
|
37
38
|
it 'should return friends as FbGraph::User' do
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
:access_token => 'access_token'
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
39
|
+
mock_graph :get, 'me/friends', 'users/friends/me_private', :params => {
|
40
|
+
:access_token => 'access_token'
|
41
|
+
} do
|
42
|
+
users = FbGraph::User.new('me', :access_token => 'access_token').friends
|
43
|
+
users.first.should == FbGraph::User.new(
|
44
|
+
'6401',
|
45
|
+
:access_token => 'access_token',
|
46
|
+
:name => 'Kirk McMurray'
|
47
|
+
)
|
48
|
+
users.each do |user|
|
49
|
+
user.should be_instance_of(FbGraph::User)
|
50
|
+
end
|
46
51
|
end
|
47
52
|
end
|
48
53
|
end
|
@@ -1,22 +1,22 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe FbGraph::Connections::Activities, '#activities' do
|
4
|
-
before do
|
5
|
-
fake_json(:get, 'matake/games?access_token=access_token', 'users/games/matake_private')
|
6
|
-
end
|
7
|
-
|
8
4
|
it 'should return games as FbGraph::Page' do
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
'
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
5
|
+
mock_graph :get, 'matake/games', 'users/games/matake_private', :params => {
|
6
|
+
:access_token => 'access_token'
|
7
|
+
} do
|
8
|
+
games = FbGraph::User.new('matake', :access_token => 'access_token').games
|
9
|
+
games.class.should == FbGraph::Connection
|
10
|
+
games.first.should == FbGraph::Page.new(
|
11
|
+
'101392683235776',
|
12
|
+
:access_token => 'access_token',
|
13
|
+
:name => 'FarmVille Cows',
|
14
|
+
:category => 'Game',
|
15
|
+
:created_time => '2011-01-05T13:37:40+0000'
|
16
|
+
)
|
17
|
+
games.each do |game|
|
18
|
+
game.should be_instance_of(FbGraph::Page)
|
19
|
+
end
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
@@ -2,29 +2,30 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe FbGraph::Connections::Groups, '#groups' do
|
4
4
|
context 'when included by FbGraph::User' do
|
5
|
-
before do
|
6
|
-
fake_json(:get, 'matake/groups', 'users/groups/matake_public', :status => [401, 'Unauthorized'])
|
7
|
-
fake_json(:get, 'matake/groups?access_token=access_token', 'users/groups/matake_private')
|
8
|
-
end
|
9
|
-
|
10
5
|
context 'when no access_token given' do
|
11
6
|
it 'should raise FbGraph::Unauthorized' do
|
12
|
-
|
13
|
-
|
14
|
-
|
7
|
+
mock_graph :get, 'matake/groups', 'users/groups/matake_public', :status => [401, 'Unauthorized'] do
|
8
|
+
lambda do
|
9
|
+
FbGraph::User.new('matake').groups
|
10
|
+
end.should raise_exception(FbGraph::Unauthorized)
|
11
|
+
end
|
15
12
|
end
|
16
13
|
end
|
17
14
|
|
18
15
|
context 'when access_token is given' do
|
19
16
|
it 'should return groups as FbGraph::Group' do
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
:access_token => 'access_token'
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
17
|
+
mock_graph :get, 'matake/groups', 'users/groups/matake_private', :params => {
|
18
|
+
:access_token => 'access_token'
|
19
|
+
} do
|
20
|
+
groups = FbGraph::User.new('matake', :access_token => 'access_token').groups
|
21
|
+
groups.first.should == FbGraph::Group.new(
|
22
|
+
'115286585902',
|
23
|
+
:access_token => 'access_token',
|
24
|
+
:name => 'iPhone 3G S'
|
25
|
+
)
|
26
|
+
groups.each do |group|
|
27
|
+
group.should be_instance_of(FbGraph::Group)
|
28
|
+
end
|
28
29
|
end
|
29
30
|
end
|
30
31
|
end
|
@@ -3,58 +3,63 @@ require 'spec_helper'
|
|
3
3
|
|
4
4
|
describe FbGraph::Connections::Home, '#home' do
|
5
5
|
context 'when included by FbGraph::User' do
|
6
|
-
before do
|
7
|
-
fake_json(:get, 'me/home', 'users/home/me_public', :status => [401, 'Unauthorized'])
|
8
|
-
fake_json(:get, 'me/home?access_token=access_token', 'users/home/me_private')
|
9
|
-
fake_json(:get, 'arjun/home', 'users/home/arjun_public', :status => [400, 'BadRequest'])
|
10
|
-
fake_json(:get, 'arjun/home?access_token=access_token', 'users/home/arjun_private', :status => [400, 'BadRequest'])
|
11
|
-
end
|
12
|
-
|
13
6
|
context 'when no access_token given' do
|
14
7
|
it 'should raise FbGraph::Exception' do
|
15
|
-
|
16
|
-
|
17
|
-
|
8
|
+
mock_graph :get, 'arjun/home', 'users/home/arjun_public', :status => [400, 'BadRequest'] do
|
9
|
+
lambda do
|
10
|
+
FbGraph::User.new('arjun').home
|
11
|
+
end.should raise_exception(FbGraph::Exception)
|
12
|
+
end
|
18
13
|
end
|
19
14
|
end
|
20
15
|
|
21
16
|
context 'when identifier is not me' do
|
22
17
|
it 'should raise FbGraph::Exception' do
|
23
|
-
|
24
|
-
|
25
|
-
|
18
|
+
mock_graph :get, 'arjun/home', 'users/home/arjun_private', :params => {
|
19
|
+
:access_token => 'access_token'
|
20
|
+
}, :status => [400, 'BadRequest'] do
|
21
|
+
lambda do
|
22
|
+
FbGraph::User.new('arjun', :access_token => 'access_token').home
|
23
|
+
end.should raise_exception(FbGraph::Exception)
|
24
|
+
end
|
26
25
|
end
|
27
26
|
end
|
28
27
|
|
29
28
|
context 'when identifier is me and no access_token is given' do
|
30
29
|
it 'should raise FbGraph::Unauthorized' do
|
31
|
-
|
32
|
-
|
33
|
-
|
30
|
+
mock_graph :get, 'me/home', 'users/home/me_public', :status => [401, 'Unauthorized'] do
|
31
|
+
lambda do
|
32
|
+
FbGraph::User.new('me').home
|
33
|
+
end.should raise_exception(FbGraph::Unauthorized)
|
34
|
+
end
|
34
35
|
end
|
35
36
|
end
|
36
37
|
|
37
38
|
context 'when identifier is me and access_token is given' do
|
38
39
|
it 'should return public posts in the user\'s news feed as FbGraph::Post' do
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
:access_token => 'access_token'
|
43
|
-
|
44
|
-
|
45
|
-
:
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
:
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
40
|
+
mock_graph :get, 'me/home', 'users/home/me_private', :params => {
|
41
|
+
:access_token => 'access_token'
|
42
|
+
} do
|
43
|
+
posts = FbGraph::User.new('me', :access_token => 'access_token').home
|
44
|
+
posts.first.should == FbGraph::Post.new(
|
45
|
+
'634033380_112599768777073',
|
46
|
+
:access_token => 'access_token',
|
47
|
+
:from => {
|
48
|
+
:id => '634033380',
|
49
|
+
:name => 'nishikokura hironobu'
|
50
|
+
},
|
51
|
+
:message => "こちらこそありがとうございました!僕はctrl+無変換ですwRT @_eskm: @pandeiro245 こないだの日曜はありがとうございました!面白い内容でした。ちなみにfnrirってCapsLockで起動ですが、英数変換と同じボタンでどうしてます?起動を違うボタンに変更",
|
52
|
+
:icon => 'http://photos-h.ak.fbcdn.net/photos-ak-sf2p/v43/23/2231777543/app_2_2231777543_2528.gif',
|
53
|
+
:attribution => 'Twitter',
|
54
|
+
:created_time => '2010-04-27T13:06:14+0000',
|
55
|
+
:updated_time => '2010-04-27T13:06:14+0000',
|
56
|
+
:privacy => {
|
57
|
+
:value => 'EVERYONE'
|
58
|
+
}
|
59
|
+
)
|
60
|
+
posts.each do |post|
|
61
|
+
post.should be_instance_of(FbGraph::Post)
|
62
|
+
end
|
58
63
|
end
|
59
64
|
end
|
60
65
|
end
|