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,104 +2,106 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe FbGraph::Connections::Checkins, '#checkins' do
|
4
4
|
context 'when included by FbGraph::User' do
|
5
|
-
before do
|
6
|
-
fake_json(:get, 'mattt/checkins', 'users/checkins/mattt_public', :status => [401, 'Unauthorized'])
|
7
|
-
fake_json(:get, 'mattt/checkins?access_token=access_token', 'users/checkins/mattt_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, 'mattt/checkins', 'users/checkins/mattt_public', :status => [401, 'Unauthorized'] do
|
8
|
+
lambda do
|
9
|
+
FbGraph::User.new('mattt').checkins
|
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 checkins as FbGraph::Checkin' do
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
:access_token => 'access_token'
|
24
|
-
|
25
|
-
|
26
|
-
:
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
:
|
38
|
-
:
|
39
|
-
:
|
40
|
-
:
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
17
|
+
mock_graph :get, 'mattt/checkins', 'users/checkins/mattt_private', :params => {
|
18
|
+
:access_token => 'access_token'
|
19
|
+
} do
|
20
|
+
checkins = FbGraph::User.new('mattt', :access_token => 'access_token').checkins
|
21
|
+
checkins.first.should == FbGraph::Checkin.new(
|
22
|
+
'696876187499',
|
23
|
+
:access_token => 'access_token',
|
24
|
+
:from => {
|
25
|
+
:id => '12820552',
|
26
|
+
:name => 'Roger Pincombe'
|
27
|
+
},
|
28
|
+
:tags => {
|
29
|
+
:data => [{
|
30
|
+
:id => '4810308',
|
31
|
+
:name => 'Mattt Thompson'
|
32
|
+
}]
|
33
|
+
},
|
34
|
+
:message => 'Checking out Austin, TX',
|
35
|
+
:place => {
|
36
|
+
:id => '120454134658381',
|
37
|
+
:name => 'Gowalla HQ',
|
38
|
+
:location => {
|
39
|
+
:latitude => 30.26876,
|
40
|
+
:longitude => -97.74962
|
41
|
+
}
|
42
|
+
},
|
43
|
+
:application => {
|
44
|
+
:id => '6628568379',
|
45
|
+
:name => 'Facebook for iPhone'
|
46
|
+
},
|
47
|
+
:created_time => '2010-09-08T00:09:25+0000'
|
48
|
+
)
|
49
|
+
checkins.each do |checkin|
|
50
|
+
checkin.should be_instance_of(FbGraph::Checkin)
|
51
|
+
end
|
51
52
|
end
|
52
53
|
end
|
53
54
|
end
|
54
55
|
end
|
55
56
|
|
56
57
|
context 'when included by FbGraph::Page' do
|
57
|
-
before do
|
58
|
-
fake_json(:get, 'gowalla/checkins', 'pages/checkins/gowalla_public', :status => [401, 'Unauthorized'])
|
59
|
-
fake_json(:get, 'gowalla/checkins?access_token=access_token', 'pages/checkins/gowalla_private')
|
60
|
-
end
|
61
|
-
|
62
58
|
context 'when no access_token given' do
|
63
59
|
it 'should raise FbGraph::Unauthorized' do
|
64
|
-
|
65
|
-
|
66
|
-
|
60
|
+
mock_graph :get, 'gowalla/checkins', 'pages/checkins/gowalla_public', :status => [401, 'Unauthorized'] do
|
61
|
+
lambda do
|
62
|
+
FbGraph::Page.new('gowalla').checkins
|
63
|
+
end.should raise_exception(FbGraph::Unauthorized)
|
64
|
+
end
|
67
65
|
end
|
68
66
|
end
|
69
67
|
|
70
68
|
context 'when access_token is given' do
|
71
69
|
it 'should return checkins as FbGraph::Checkin' do
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
:access_token => 'access_token'
|
76
|
-
|
77
|
-
|
78
|
-
:
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
:
|
90
|
-
:
|
91
|
-
:
|
92
|
-
:
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
70
|
+
mock_graph :get, 'gowalla/checkins', 'pages/checkins/gowalla_private', :params => {
|
71
|
+
:access_token => 'access_token'
|
72
|
+
} do
|
73
|
+
checkins = FbGraph::Page.new('gowalla', :access_token => 'access_token').checkins
|
74
|
+
checkins.first.should == FbGraph::Checkin.new(
|
75
|
+
'696876187499',
|
76
|
+
:access_token => 'access_token',
|
77
|
+
:from => {
|
78
|
+
:id => '12820552',
|
79
|
+
:name => 'Roger Pincombe'
|
80
|
+
},
|
81
|
+
:tags => {
|
82
|
+
:data => [{
|
83
|
+
:id => '4810308',
|
84
|
+
:name => 'Mattt Thompson'
|
85
|
+
}]
|
86
|
+
},
|
87
|
+
:message => 'Checking out Austin, TX',
|
88
|
+
:place => {
|
89
|
+
:id => '120454134658381',
|
90
|
+
:name => 'Gowalla HQ',
|
91
|
+
:location => {
|
92
|
+
:latitude => 30.26876,
|
93
|
+
:longitude => -97.74962
|
94
|
+
}
|
95
|
+
},
|
96
|
+
:application => {
|
97
|
+
:id => '6628568379',
|
98
|
+
:name => 'Facebook for iPhone'
|
99
|
+
},
|
100
|
+
:created_time => '2010-09-08T00:09:25+0000'
|
101
|
+
)
|
102
|
+
checkins.each do |checkin|
|
103
|
+
checkin.should be_instance_of(FbGraph::Checkin)
|
104
|
+
end
|
103
105
|
end
|
104
106
|
end
|
105
107
|
end
|
@@ -107,19 +109,17 @@ describe FbGraph::Connections::Checkins, '#checkins' do
|
|
107
109
|
end
|
108
110
|
|
109
111
|
describe FbGraph::Connections::Checkins, '#checkin!' do
|
110
|
-
before do
|
111
|
-
fake_json :post, 'me/checkins', 'users/checkins/posted'
|
112
|
-
end
|
113
|
-
|
114
112
|
it 'should POST :user_id/checkins' do
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
:
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
113
|
+
mock_graph :post, 'me/checkins', 'users/checkins/posted' do
|
114
|
+
checkin = FbGraph::User.me('token').checkin!(
|
115
|
+
:place => 'place_id',
|
116
|
+
:coordinates => {
|
117
|
+
:latitude => 30.26876,
|
118
|
+
:longitude => -97.74962
|
119
|
+
}.to_json
|
120
|
+
)
|
121
|
+
checkin.identifier.should == '10150090286117277'
|
122
|
+
checkin.place.should == FbGraph::Place.new('place_id')
|
123
|
+
end
|
124
124
|
end
|
125
125
|
end
|
@@ -2,21 +2,22 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe FbGraph::Connections::Comments, '#comments' do
|
4
4
|
context 'when included by FbGraph::Post' do
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
let :post do
|
6
|
+
mock_graph :get, 'no_comments', 'posts/no_comments' do
|
7
|
+
FbGraph::Post.new('no_comments').fetch
|
8
|
+
end
|
8
9
|
end
|
9
10
|
|
10
11
|
it 'should use cached @_comments_ as default' do
|
11
12
|
lambda do
|
12
|
-
|
13
|
-
end.should_not
|
13
|
+
post.comments
|
14
|
+
end.should_not request_to "#{post.identifier}/comments"
|
14
15
|
end
|
15
16
|
|
16
17
|
it 'should ignore cached @_comments_ when options are given' do
|
17
18
|
lambda do
|
18
|
-
|
19
|
-
end.
|
19
|
+
post.comments(:no_cache => true)
|
20
|
+
end.should request_to "#{post.identifier}/comments"
|
20
21
|
end
|
21
22
|
end
|
22
23
|
end
|
@@ -24,40 +25,38 @@ end
|
|
24
25
|
describe FbGraph::Connections::Comments, '#comment!' do
|
25
26
|
context 'when included by FbGraph::Post' do
|
26
27
|
context 'when no access_token given' do
|
27
|
-
before do
|
28
|
-
fake_json(:post, '12345/comments', 'posts/comments/post_without_access_token', :status => [500, 'Internal Server Error'])
|
29
|
-
end
|
30
|
-
|
31
28
|
it 'should raise FbGraph::Exception' do
|
32
|
-
|
33
|
-
|
34
|
-
|
29
|
+
mock_graph :post, '12345/comments', 'posts/comments/post_without_access_token', :status => [500, 'Internal Server Error'] do
|
30
|
+
lambda do
|
31
|
+
FbGraph::Post.new('12345').comment!(:message => 'hello')
|
32
|
+
end.should raise_exception(FbGraph::Exception)
|
33
|
+
end
|
35
34
|
end
|
36
35
|
end
|
37
36
|
|
38
37
|
context 'when invalid access_token is given' do
|
39
|
-
before do
|
40
|
-
fake_json(:post, '12345/comments', 'posts/comments/post_with_invalid_access_token', :status => [500, 'Internal Server Error'])
|
41
|
-
end
|
42
|
-
|
43
38
|
it 'should raise FbGraph::Exception' do
|
44
|
-
|
45
|
-
|
46
|
-
|
39
|
+
mock_graph :post, '12345/comments', 'posts/comments/post_with_invalid_access_token', :status => [500, 'Internal Server Error'] do
|
40
|
+
lambda do
|
41
|
+
FbGraph::Post.new('12345', :access_token => 'invalid').comment!(:message => 'hello')
|
42
|
+
end.should raise_exception(FbGraph::Exception)
|
43
|
+
end
|
47
44
|
end
|
48
45
|
end
|
49
46
|
|
50
47
|
context 'when valid access_token is given' do
|
51
48
|
before do
|
52
|
-
|
49
|
+
|
53
50
|
end
|
54
51
|
|
55
52
|
it 'should return generated comment' do
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
53
|
+
mock_graph :post, '12345/comments', 'posts/comments/post_with_valid_access_token' do
|
54
|
+
comment = FbGraph::Post.new('12345', :access_token => 'valid').comment!(:message => 'hello')
|
55
|
+
comment.identifier.should == '117513961602338_119401698085884_535271'
|
56
|
+
comment.access_token.should == 'valid'
|
57
|
+
comment.message.should == 'hello'
|
58
|
+
comment.access_token.should == 'valid'
|
59
|
+
end
|
61
60
|
end
|
62
61
|
end
|
63
62
|
end
|
@@ -66,36 +65,30 @@ end
|
|
66
65
|
describe FbGraph::Connections::Comments, '#like!' do
|
67
66
|
context 'when included by FbGraph::Post' do
|
68
67
|
context 'when no access_token given' do
|
69
|
-
before do
|
70
|
-
fake_json(:post, '12345/likes', 'posts/likes/post_without_access_token', :status => [500, 'Internal Server Error'])
|
71
|
-
end
|
72
|
-
|
73
68
|
it 'should raise FbGraph::Exception' do
|
74
|
-
|
75
|
-
|
76
|
-
|
69
|
+
mock_graph :post, '12345/likes', 'posts/likes/post_without_access_token', :status => [500, 'Internal Server Error'] do
|
70
|
+
lambda do
|
71
|
+
FbGraph::Post.new('12345').like!
|
72
|
+
end.should raise_exception(FbGraph::Exception)
|
73
|
+
end
|
77
74
|
end
|
78
75
|
end
|
79
76
|
|
80
77
|
context 'when invalid access_token is given' do
|
81
|
-
before do
|
82
|
-
fake_json(:post, '12345/likes', 'posts/likes/post_with_invalid_access_token', :status => [500, 'Internal Server Error'])
|
83
|
-
end
|
84
|
-
|
85
78
|
it 'should raise FbGraph::Exception' do
|
86
|
-
|
87
|
-
|
88
|
-
|
79
|
+
mock_graph :post, '12345/likes', 'posts/likes/post_with_invalid_access_token', :status => [500, 'Internal Server Error'] do
|
80
|
+
lambda do
|
81
|
+
FbGraph::Post.new('12345', :access_token => 'invalid').like!
|
82
|
+
end.should raise_exception(FbGraph::Exception)
|
83
|
+
end
|
89
84
|
end
|
90
85
|
end
|
91
86
|
|
92
87
|
context 'when valid access_token is given' do
|
93
|
-
before do
|
94
|
-
fake_json(:post, '12345/likes', 'posts/likes/post_with_valid_access_token')
|
95
|
-
end
|
96
|
-
|
97
88
|
it 'should return true' do
|
98
|
-
|
89
|
+
mock_graph :post, '12345/likes', 'posts/likes/post_with_valid_access_token' do
|
90
|
+
FbGraph::Post.new('12345', :access_token => 'valid').like!.should be_true
|
91
|
+
end
|
99
92
|
end
|
100
93
|
end
|
101
94
|
end
|
@@ -103,8 +96,8 @@ end
|
|
103
96
|
|
104
97
|
describe FbGraph::Connections::Comments, '#unlike!' do
|
105
98
|
it 'should DELETE /:object_id/likes' do
|
106
|
-
|
99
|
+
mock_graph :delete, '12345/likes', 'true', :params => {:access_token => 'valid'} do
|
107
100
|
FbGraph::Post.new('12345', :access_token => 'valid').unlike!
|
108
|
-
end
|
101
|
+
end
|
109
102
|
end
|
110
103
|
end
|
@@ -2,23 +2,27 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe FbGraph::Connections::Declined, '#declined' do
|
4
4
|
before do
|
5
|
-
|
5
|
+
|
6
6
|
end
|
7
7
|
|
8
8
|
it 'should return declined users as FbGraph::User' do
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
mock_graph :get, 'smartday/declined', 'events/declined/smartday_private', :params => {
|
10
|
+
:access_token => 'access_token'
|
11
|
+
} do
|
12
|
+
users = FbGraph::Event.new('smartday', :access_token => 'access_token').declined
|
13
|
+
users.each do |user|
|
14
|
+
user.should be_instance_of(FbGraph::User)
|
15
|
+
end
|
12
16
|
end
|
13
17
|
end
|
14
18
|
end
|
15
19
|
|
16
20
|
describe FbGraph::Connections::Declined, '#declined!' do
|
17
|
-
before do
|
18
|
-
fake_json(:post, '12345/declined', 'events/declined/post_with_valid_access_token')
|
19
|
-
end
|
20
|
-
|
21
21
|
it 'should return true' do
|
22
|
-
|
22
|
+
mock_graph :post, '12345/declined', 'events/declined/post_with_valid_access_token', :params => {
|
23
|
+
:access_token => 'valid'
|
24
|
+
} do
|
25
|
+
FbGraph::Event.new('12345', :access_token => 'valid').declined!.should be_true
|
26
|
+
end
|
23
27
|
end
|
24
28
|
end
|
@@ -2,32 +2,33 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe FbGraph::Connections::Events, '#events' do
|
4
4
|
context 'when included by FbGraph::User' do
|
5
|
-
before do
|
6
|
-
fake_json(:get, 'matake/events', 'users/events/matake_public', :status => [401, 'Unauthorized'])
|
7
|
-
fake_json(:get, 'matake/events?access_token=access_token', 'users/events/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/events', 'users/events/matake_public', :status => [401, 'Unauthorized'] do
|
8
|
+
lambda do
|
9
|
+
FbGraph::User.new('matake').events
|
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 events as FbGraph::Event' do
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
:access_token => 'access_token'
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
17
|
+
mock_graph :get, 'matake/events', 'users/events/matake_private', :params => {
|
18
|
+
:access_token => 'access_token'
|
19
|
+
} do
|
20
|
+
events = FbGraph::User.new('matake', :access_token => 'access_token').events
|
21
|
+
events.first.should == FbGraph::Event.new(
|
22
|
+
'116600818359630',
|
23
|
+
:access_token => 'access_token',
|
24
|
+
:name => 'The Loyal We @ Rainy Day Bookstore and Cafe',
|
25
|
+
:start_time => '2010-04-29T01:30:00+0000',
|
26
|
+
:end_time => '2010-04-29T04:30:00+0000',
|
27
|
+
:location => 'Nishi Azabu'
|
28
|
+
)
|
29
|
+
events.each do |event|
|
30
|
+
event.should be_instance_of(FbGraph::Event)
|
31
|
+
end
|
31
32
|
end
|
32
33
|
end
|
33
34
|
end
|
@@ -36,20 +37,18 @@ end
|
|
36
37
|
|
37
38
|
describe FbGraph::Connections::Events, '#events!' do
|
38
39
|
context 'when included by FbGraph::User' do
|
39
|
-
before do
|
40
|
-
fake_json(:post, 'matake/events', 'users/events/post_with_valid_access_token')
|
41
|
-
end
|
42
|
-
|
43
40
|
it 'should return generated note' do
|
44
|
-
|
45
|
-
:
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
41
|
+
mock_graph :post, 'matake/events', 'users/events/post_with_valid_access_token' do
|
42
|
+
event = FbGraph::User.new('matake', :access_token => 'valid').event!(
|
43
|
+
:name => 'FbGraph test event',
|
44
|
+
:start_time => Time.utc(2010, 5, 11, 10, 0, 0).to_i,
|
45
|
+
:end_time => Time.utc(2010, 5, 11, 12, 0, 0).to_i
|
46
|
+
)
|
47
|
+
event.name.should == 'FbGraph test event'
|
48
|
+
event.access_token.should == 'valid'
|
49
|
+
event.start_time.should == Time.utc(2010, 5, 11, 10, 0, 0)
|
50
|
+
event.end_time.should == Time.utc(2010, 5, 11, 12, 0, 0)
|
51
|
+
end
|
53
52
|
end
|
54
53
|
end
|
55
54
|
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe FbGraph::Connections::Family, '#family' do
|
4
|
+
context 'when included by FbGraph::User' do
|
5
|
+
context 'when no access_token given' do
|
6
|
+
it 'should raise FbGraph::Unauthorized' do
|
7
|
+
mock_graph :get, 'me/family', 'users/family/family_without_access_token', :status => [401, 'Unauthorized'] do
|
8
|
+
lambda do
|
9
|
+
FbGraph::User.new('me').family
|
10
|
+
end.should raise_exception(FbGraph::Unauthorized)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
context 'when access_token is given' do
|
16
|
+
it 'should return family members as FbGraph::User' do
|
17
|
+
mock_graph :get, 'me/family', 'users/family/me_public', :params => {
|
18
|
+
:access_token => 'access_token'
|
19
|
+
} do
|
20
|
+
users = FbGraph::User.new('me', :access_token => 'access_token').family
|
21
|
+
users.first.should == FbGraph::User.new(
|
22
|
+
'720112389',
|
23
|
+
:access_token => 'access_token',
|
24
|
+
:name => 'TD Lee',
|
25
|
+
:relationship => 'brother'
|
26
|
+
)
|
27
|
+
users.each do |user|
|
28
|
+
user.should be_instance_of(FbGraph::User)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|