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.
Files changed (194) hide show
  1. data/.gitignore +21 -0
  2. data/.rspec +2 -0
  3. data/Gemfile +2 -0
  4. data/Gemfile.lock +52 -0
  5. data/README.rdoc +1 -0
  6. data/Rakefile +8 -34
  7. data/VERSION +1 -1
  8. data/fb_graph.gemspec +15 -433
  9. data/lib/fb_graph/connections/family.rb +14 -0
  10. data/lib/fb_graph/connections/permissions.rb +12 -0
  11. data/lib/fb_graph/page/category_attributes.rb +1 -0
  12. data/lib/fb_graph/user.rb +4 -1
  13. data/lib/fb_graph.rb +0 -1
  14. data/spec/fb_graph/application_spec.rb +8 -14
  15. data/spec/fb_graph/auth_spec.rb +1 -1
  16. data/spec/fb_graph/checkin_spec.rb +15 -11
  17. data/spec/fb_graph/collection_spec.rb +8 -7
  18. data/spec/fb_graph/connection_spec.rb +36 -25
  19. data/spec/fb_graph/connections/accounts_spec.rb +30 -26
  20. data/spec/fb_graph/connections/activities_spec.rb +19 -18
  21. data/spec/fb_graph/connections/albums_spec.rb +40 -37
  22. data/spec/fb_graph/connections/app_requests_spec.rb +7 -7
  23. data/spec/fb_graph/connections/attending_spec.rb +12 -12
  24. data/spec/fb_graph/connections/books_spec.rb +18 -17
  25. data/spec/fb_graph/connections/checkins_spec.rb +91 -91
  26. data/spec/fb_graph/connections/comments_spec.rb +41 -48
  27. data/spec/fb_graph/connections/declined_spec.rb +13 -9
  28. data/spec/fb_graph/connections/events_spec.rb +31 -32
  29. data/spec/fb_graph/connections/family_spec.rb +34 -0
  30. data/spec/fb_graph/connections/feed_spec.rb +65 -70
  31. data/spec/fb_graph/connections/former_participants_spec.rb +8 -7
  32. data/spec/fb_graph/connections/friend_lists_spec.rb +7 -7
  33. data/spec/fb_graph/connections/friends_spec.rb +29 -24
  34. data/spec/fb_graph/connections/games_spec.rb +15 -15
  35. data/spec/fb_graph/connections/groups_spec.rb +17 -16
  36. data/spec/fb_graph/connections/home_spec.rb +40 -35
  37. data/spec/fb_graph/connections/insights_spec.rb +74 -70
  38. data/spec/fb_graph/connections/interests_spec.rb +7 -7
  39. data/spec/fb_graph/connections/invited_spec.rb +7 -7
  40. data/spec/fb_graph/connections/likes_spec.rb +23 -19
  41. data/spec/fb_graph/connections/links_spec.rb +17 -19
  42. data/spec/fb_graph/connections/maybe_spec.rb +10 -12
  43. data/spec/fb_graph/connections/members_spec.rb +7 -7
  44. data/spec/fb_graph/connections/messages_spec.rb +8 -7
  45. data/spec/fb_graph/connections/movies_spec.rb +7 -7
  46. data/spec/fb_graph/connections/music_spec.rb +7 -7
  47. data/spec/fb_graph/connections/noreply_spec.rb +7 -7
  48. data/spec/fb_graph/connections/notes_spec.rb +18 -16
  49. data/spec/fb_graph/connections/participants_spec.rb +8 -7
  50. data/spec/fb_graph/connections/permissions_spec.rb +18 -0
  51. data/spec/fb_graph/connections/photos_spec.rb +24 -24
  52. data/spec/fb_graph/connections/posts_spec.rb +23 -26
  53. data/spec/fb_graph/connections/senders_spec.rb +8 -7
  54. data/spec/fb_graph/connections/statuses_spec.rb +45 -43
  55. data/spec/fb_graph/connections/subscriptions_spec.rb +7 -7
  56. data/spec/fb_graph/connections/tagged_spec.rb +30 -33
  57. data/spec/fb_graph/connections/television_spec.rb +7 -7
  58. data/spec/fb_graph/connections/test_users_spec.rb +13 -9
  59. data/spec/fb_graph/connections/threads_spec.rb +7 -7
  60. data/spec/fb_graph/connections/videos_spec.rb +7 -7
  61. data/spec/fb_graph/page/local_business_spec.rb +4 -4
  62. data/spec/fb_graph/page/movie_spec.rb +4 -4
  63. data/spec/fb_graph/page/music_spec.rb +4 -4
  64. data/spec/fb_graph/page/person_spec.rb +4 -4
  65. data/spec/fb_graph/page/product_spec.rb +4 -4
  66. data/spec/fb_graph/page_spec.rb +8 -16
  67. data/spec/fb_graph/post_spec.rb +50 -46
  68. data/spec/fb_graph/query/core_spec.rb +39 -51
  69. data/spec/fb_graph/searchable_spec.rb +13 -9
  70. data/spec/fb_graph/test_user_spec.rb +5 -11
  71. data/spec/fb_graph/user_spec.rb +96 -91
  72. data/spec/helpers/webmock_helper.rb +71 -0
  73. data/spec/{fake_json → mock_json}/albums/photos/matake_private.json +0 -0
  74. data/spec/{fake_json → mock_json}/albums/photos/post_with_valid_access_token.json +0 -0
  75. data/spec/{fake_json → mock_json}/applications/feed/public.json +0 -0
  76. data/spec/{fake_json → mock_json}/applications/subscriptions/fb_graph_private.json +0 -0
  77. data/spec/{fake_json → mock_json}/applications/test_users/created.json +0 -0
  78. data/spec/{fake_json → mock_json}/applications/test_users/private.json +0 -0
  79. data/spec/{fake_json → mock_json}/checkins/search_private.json +0 -0
  80. data/spec/{fake_json → mock_json}/checkins/search_public.json +0 -0
  81. data/spec/{fake_json → mock_json}/events/attending/post_with_valid_access_token.json +0 -0
  82. data/spec/{fake_json → mock_json}/events/attending/smartday_private.json +0 -0
  83. data/spec/{fake_json → mock_json}/events/declined/post_with_valid_access_token.json +0 -0
  84. data/spec/{fake_json → mock_json}/events/declined/smartday_private.json +0 -0
  85. data/spec/{fake_json → mock_json}/events/invited/smartday_private.json +0 -0
  86. data/spec/{fake_json → mock_json}/events/maybe/post_with_valid_access_token.json +0 -0
  87. data/spec/{fake_json → mock_json}/events/maybe/smartday_private.json +0 -0
  88. data/spec/{fake_json → mock_json}/events/noreply/smartday_private.json +0 -0
  89. data/spec/{fake_json → mock_json}/groups/members/emacs_private.json +0 -0
  90. data/spec/{fake_json → mock_json}/pages/categories/local_business.json +0 -0
  91. data/spec/{fake_json → mock_json}/pages/categories/movie.json +0 -0
  92. data/spec/{fake_json → mock_json}/pages/categories/music.json +0 -0
  93. data/spec/{fake_json → mock_json}/pages/categories/person.json +0 -0
  94. data/spec/{fake_json → mock_json}/pages/categories/product.json +0 -0
  95. data/spec/{fake_json → mock_json}/pages/checkins/gowalla_private.json +0 -0
  96. data/spec/{fake_json → mock_json}/pages/checkins/gowalla_public.json +0 -0
  97. data/spec/{fake_json → mock_json}/pages/insights/FbGraph_private.json +0 -0
  98. data/spec/{fake_json → mock_json}/pages/insights/FbGraph_public.json +0 -0
  99. data/spec/{fake_json → mock_json}/pages/insights/page_like_adds/FbGraph_private.json +0 -0
  100. data/spec/{fake_json → mock_json}/pages/insights/page_like_adds/day/FbGraph_private.json +0 -0
  101. data/spec/{fake_json → mock_json}/pages/notes/post_with_valid_access_token.json +0 -0
  102. data/spec/{fake_json → mock_json}/pages/platform_private.json +0 -0
  103. data/spec/{fake_json → mock_json}/pages/platform_public.json +0 -0
  104. data/spec/{fake_json → mock_json}/pages/search_fb_graph.json +0 -0
  105. data/spec/{fake_json → mock_json}/pages/search_google.json +0 -0
  106. data/spec/{fake_json → mock_json}/pages/statuses/platform_private.json +0 -0
  107. data/spec/{fake_json → mock_json}/pages/statuses/platform_public.json +0 -0
  108. data/spec/{fake_json → mock_json}/posts/comments/post_with_invalid_access_token.json +0 -0
  109. data/spec/{fake_json → mock_json}/posts/comments/post_with_valid_access_token.json +0 -0
  110. data/spec/{fake_json → mock_json}/posts/comments/post_without_access_token.json +0 -0
  111. data/spec/{fake_json → mock_json}/posts/likes/post_with_invalid_access_token.json +0 -0
  112. data/spec/{fake_json → mock_json}/posts/likes/post_with_valid_access_token.json +0 -0
  113. data/spec/{fake_json → mock_json}/posts/likes/post_without_access_token.json +0 -0
  114. data/spec/{fake_json → mock_json}/posts/no_comments.json +0 -0
  115. data/spec/{fake_json → mock_json}/posts/platform_private.json +0 -0
  116. data/spec/{fake_json → mock_json}/posts/platform_public.json +0 -0
  117. data/spec/{fake_json → mock_json}/posts/to_application.json +0 -0
  118. data/spec/{fake_json → mock_json}/posts/to_event.json +0 -0
  119. data/spec/{fake_json → mock_json}/posts/to_group.json +0 -0
  120. data/spec/{fake_json → mock_json}/query/user/with_invalid_token.json +0 -0
  121. data/spec/{fake_json → mock_json}/query/user/with_valid_token.json +0 -0
  122. data/spec/{fake_json → mock_json}/query/user/without_token.json +0 -0
  123. data/spec/{fake_json → mock_json}/statuses/with_likes.json +0 -0
  124. data/spec/{fake_json → mock_json}/thread/former_participants/private.json +0 -0
  125. data/spec/{fake_json → mock_json}/thread/messages/private.json +0 -0
  126. data/spec/{fake_json → mock_json}/thread/participants/private.json +0 -0
  127. data/spec/{fake_json → mock_json}/thread/senders/private.json +0 -0
  128. data/spec/{fake_json → mock_json}/token_response.json +0 -0
  129. data/spec/{fake_json → mock_json}/true.json +0 -0
  130. data/spec/{fake_json → mock_json}/users/accounts/matake_private.json +0 -0
  131. data/spec/{fake_json → mock_json}/users/accounts/matake_private_with_manage_pages_permission.json +0 -0
  132. data/spec/{fake_json → mock_json}/users/accounts/matake_public.json +0 -0
  133. data/spec/{fake_json → mock_json}/users/activities/arjun_private.json +0 -0
  134. data/spec/{fake_json → mock_json}/users/activities/arjun_public.json +0 -0
  135. data/spec/{fake_json → mock_json}/users/albums/matake_private.json +0 -0
  136. data/spec/{fake_json → mock_json}/users/albums/matake_public.json +0 -0
  137. data/spec/{fake_json → mock_json}/users/albums/post_with_valid_access_token.json +0 -0
  138. data/spec/{fake_json → mock_json}/users/app_requests/me_private.json +0 -0
  139. data/spec/{fake_json → mock_json}/users/arjun_private.json +0 -0
  140. data/spec/{fake_json → mock_json}/users/arjun_public.json +0 -0
  141. data/spec/{fake_json → mock_json}/users/books/matake_private.json +0 -0
  142. data/spec/{fake_json → mock_json}/users/books/matake_public.json +0 -0
  143. data/spec/{fake_json → mock_json}/users/checkins/mattt_private.json +0 -0
  144. data/spec/{fake_json → mock_json}/users/checkins/mattt_public.json +0 -0
  145. data/spec/{fake_json → mock_json}/users/checkins/posted.json +0 -0
  146. data/spec/{fake_json → mock_json}/users/events/matake_private.json +0 -0
  147. data/spec/{fake_json → mock_json}/users/events/matake_public.json +0 -0
  148. data/spec/{fake_json → mock_json}/users/events/post_with_valid_access_token.json +0 -0
  149. data/spec/mock_json/users/family/family_without_access_token.json +6 -0
  150. data/spec/mock_json/users/family/me_public.json +19 -0
  151. data/spec/{fake_json → mock_json}/users/feed/arjun_private.json +0 -0
  152. data/spec/{fake_json → mock_json}/users/feed/arjun_public.json +0 -0
  153. data/spec/{fake_json → mock_json}/users/feed/post_with_invalid_access_token.json +0 -0
  154. data/spec/{fake_json → mock_json}/users/feed/post_with_valid_access_token.json +0 -0
  155. data/spec/{fake_json → mock_json}/users/feed/post_without_access_token.json +0 -0
  156. data/spec/{fake_json → mock_json}/users/friend_lists/matake.json +0 -0
  157. data/spec/{fake_json → mock_json}/users/friends/arjun_private.json +0 -0
  158. data/spec/{fake_json → mock_json}/users/friends/arjun_public.json +0 -0
  159. data/spec/{fake_json → mock_json}/users/friends/me_private.json +0 -0
  160. data/spec/{fake_json → mock_json}/users/friends/me_public.json +0 -0
  161. data/spec/{fake_json → mock_json}/users/games/matake_private.json +0 -0
  162. data/spec/{fake_json → mock_json}/users/groups/matake_private.json +0 -0
  163. data/spec/{fake_json → mock_json}/users/groups/matake_public.json +0 -0
  164. data/spec/{fake_json → mock_json}/users/home/arjun_private.json +0 -0
  165. data/spec/{fake_json → mock_json}/users/home/arjun_public.json +0 -0
  166. data/spec/{fake_json → mock_json}/users/home/me_private.json +0 -0
  167. data/spec/{fake_json → mock_json}/users/home/me_private_next.json +0 -0
  168. data/spec/{fake_json → mock_json}/users/home/me_private_previous.json +0 -0
  169. data/spec/{fake_json → mock_json}/users/home/me_public.json +0 -0
  170. data/spec/{fake_json → mock_json}/users/interests/matake_private.json +0 -0
  171. data/spec/{fake_json → mock_json}/users/likes/arjun_private.json +0 -0
  172. data/spec/{fake_json → mock_json}/users/likes/arjun_public.json +0 -0
  173. data/spec/{fake_json → mock_json}/users/links/matake_private.json +0 -0
  174. data/spec/{fake_json → mock_json}/users/links/post_with_valid_access_token.json +0 -0
  175. data/spec/{fake_json → mock_json}/users/me_private.json +0 -0
  176. data/spec/{fake_json → mock_json}/users/me_public.json +0 -0
  177. data/spec/{fake_json → mock_json}/users/movies/matake_private.json +0 -0
  178. data/spec/{fake_json → mock_json}/users/music/matake_private.json +0 -0
  179. data/spec/{fake_json → mock_json}/users/notes/matake_private.json +0 -0
  180. data/spec/mock_json/users/permissions/me_private.json +70 -0
  181. data/spec/{fake_json → mock_json}/users/posts/arjun_private.json +0 -0
  182. data/spec/{fake_json → mock_json}/users/posts/arjun_public.json +0 -0
  183. data/spec/{fake_json → mock_json}/users/statuses/arjun_private.json +0 -0
  184. data/spec/{fake_json → mock_json}/users/statuses/arjun_public.json +0 -0
  185. data/spec/{fake_json → mock_json}/users/tagged/arjun_private.json +0 -0
  186. data/spec/{fake_json → mock_json}/users/tagged/arjun_public.json +0 -0
  187. data/spec/{fake_json → mock_json}/users/television/matake_private.json +0 -0
  188. data/spec/{fake_json → mock_json}/users/threads/me_private.json +0 -0
  189. data/spec/{fake_json → mock_json}/users/videos/kirk_private.json +0 -0
  190. data/spec/spec_helper.rb +2 -7
  191. metadata +267 -128
  192. data/.rspec-tm +0 -1
  193. data/spec/helpers/fake_json_helper.rb +0 -37
  194. data/spec/spec.opts +0 -3
@@ -3,94 +3,98 @@ require 'spec_helper'
3
3
  describe FbGraph::Connections::Insights, '#insights' do
4
4
 
5
5
  context 'when included by FbGraph::Page' do
6
- before do
7
- fake_json(:get, 'FbGraph/insights', 'pages/insights/FbGraph_public', :status => [401, 'Unauthorized'])
8
- fake_json(:get, 'FbGraph/insights?access_token=access_token', 'pages/insights/FbGraph_private')
9
- end
10
-
11
6
  context 'when no access_token given' do
12
7
  it 'should raise FbGraph::Unauthorized' do
13
- lambda do
14
- FbGraph::Page.new('FbGraph').insights
15
- end.should raise_exception(FbGraph::Unauthorized)
8
+ mock_graph :get, 'FbGraph/insights', 'pages/insights/FbGraph_public', :status => [401, 'Unauthorized'] do
9
+ lambda do
10
+ FbGraph::Page.new('FbGraph').insights
11
+ end.should raise_exception(FbGraph::Unauthorized)
12
+ end
16
13
  end
17
14
  end
18
15
 
19
16
  context 'when access_token is given' do
20
17
  it 'should return insights as FbGraph::Insight' do
21
- insights = FbGraph::Page.new('FbGraph').insights(:access_token => 'access_token')
22
- insights.class.should == FbGraph::Connection
23
- insights.first.should == FbGraph::Insight.new(
24
- '117513961602338/insights/page_fan_adds_unique/day',
25
- :access_token => 'access_token',
26
- :name => 'page_fan_adds_unique',
27
- :description => 'Daily New Likes of your Page (Unique Users)',
28
- :period => 'day',
29
- :values => [{
30
- :value => 1,
31
- :end_time => '2010-11-27T08:00:00+0000'
32
- }]
33
- )
34
- insights.each do |insight|
35
- insight.should be_instance_of(FbGraph::Insight)
18
+ mock_graph :get, 'FbGraph/insights', 'pages/insights/FbGraph_private', :params => {
19
+ :access_token => 'access_token'
20
+ } do
21
+ insights = FbGraph::Page.new('FbGraph').insights(:access_token => 'access_token')
22
+ insights.class.should == FbGraph::Connection
23
+ insights.first.should == FbGraph::Insight.new(
24
+ '117513961602338/insights/page_fan_adds_unique/day',
25
+ :access_token => 'access_token',
26
+ :name => 'page_fan_adds_unique',
27
+ :description => 'Daily New Likes of your Page (Unique Users)',
28
+ :period => 'day',
29
+ :values => [{
30
+ :value => 1,
31
+ :end_time => '2010-11-27T08:00:00+0000'
32
+ }]
33
+ )
34
+ insights.each do |insight|
35
+ insight.should be_instance_of(FbGraph::Insight)
36
+ end
36
37
  end
37
38
  end
38
39
  end
39
40
 
40
41
  context 'when metrics is given' do
41
- before do
42
- fake_json(:get, 'FbGraph/insights/page_like_adds?access_token=access_token', 'pages/insights/page_like_adds/FbGraph_private')
43
- fake_json(:get, 'FbGraph/insights/page_like_adds/day?access_token=access_token', 'pages/insights/page_like_adds/day/FbGraph_private')
44
- end
45
-
46
42
  it 'should treat metrics as connection scope' do
47
- insights = FbGraph::Page.new('FbGraph').insights(:access_token => 'access_token', :metrics => :page_like_adds)
48
- insights.options.should == {
49
- :connection_scope => 'page_like_adds',
43
+ mock_graph :get, 'FbGraph/insights/page_like_adds', 'pages/insights/page_like_adds/FbGraph_private', :params => {
50
44
  :access_token => 'access_token'
51
- }
52
- insights.first.should == FbGraph::Insight.new(
53
- '117513961602338/insights/page_like_adds/day',
54
- :access_token => 'access_token',
55
- :name => 'page_like_adds',
56
- :description => 'Daily Likes of your Page\'s content (Total Count)',
57
- :period => 'day',
58
- :values => [{
59
- :value => 0,
60
- :end_time => '2010-12-09T08:00:00+0000'
61
- }, {
62
- :value => 0,
63
- :end_time => '2010-12-10T08:00:00+0000'
64
- }, {
65
- :value => 0,
66
- :end_time => '2010-12-11T08:00:00+0000'
67
- }]
68
- )
45
+ } do
46
+ insights = FbGraph::Page.new('FbGraph').insights(:access_token => 'access_token', :metrics => :page_like_adds)
47
+ insights.options.should == {
48
+ :connection_scope => 'page_like_adds',
49
+ :access_token => 'access_token'
50
+ }
51
+ insights.first.should == FbGraph::Insight.new(
52
+ '117513961602338/insights/page_like_adds/day',
53
+ :access_token => 'access_token',
54
+ :name => 'page_like_adds',
55
+ :description => 'Daily Likes of your Page\'s content (Total Count)',
56
+ :period => 'day',
57
+ :values => [{
58
+ :value => 0,
59
+ :end_time => '2010-12-09T08:00:00+0000'
60
+ }, {
61
+ :value => 0,
62
+ :end_time => '2010-12-10T08:00:00+0000'
63
+ }, {
64
+ :value => 0,
65
+ :end_time => '2010-12-11T08:00:00+0000'
66
+ }]
67
+ )
68
+ end
69
69
  end
70
70
 
71
71
  it 'should support period also' do
72
- insights = FbGraph::Page.new('FbGraph').insights(:access_token => 'access_token', :metrics => :page_like_adds, :period => :day)
73
- insights.options.should == {
74
- :connection_scope => 'page_like_adds/day',
72
+ mock_graph :get, 'FbGraph/insights/page_like_adds/day', 'pages/insights/page_like_adds/day/FbGraph_private', :params => {
75
73
  :access_token => 'access_token'
76
- }
77
- insights.first.should == FbGraph::Insight.new(
78
- '117513961602338/insights/page_like_adds/day',
79
- :access_token => 'access_token',
80
- :name => 'page_like_adds',
81
- :description => 'Daily Likes of your Page\'s content (Total Count)',
82
- :period => 'day',
83
- :values => [{
84
- :value => 1,
85
- :end_time => '2010-12-09T08:00:00+0000'
86
- }, {
87
- :value => 1,
88
- :end_time => '2010-12-10T08:00:00+0000'
89
- }, {
90
- :value => 1,
91
- :end_time => '2010-12-11T08:00:00+0000'
92
- }]
93
- )
74
+ } do
75
+ insights = FbGraph::Page.new('FbGraph').insights(:access_token => 'access_token', :metrics => :page_like_adds, :period => :day)
76
+ insights.options.should == {
77
+ :connection_scope => 'page_like_adds/day',
78
+ :access_token => 'access_token'
79
+ }
80
+ insights.first.should == FbGraph::Insight.new(
81
+ '117513961602338/insights/page_like_adds/day',
82
+ :access_token => 'access_token',
83
+ :name => 'page_like_adds',
84
+ :description => 'Daily Likes of your Page\'s content (Total Count)',
85
+ :period => 'day',
86
+ :values => [{
87
+ :value => 1,
88
+ :end_time => '2010-12-09T08:00:00+0000'
89
+ }, {
90
+ :value => 1,
91
+ :end_time => '2010-12-10T08:00:00+0000'
92
+ }, {
93
+ :value => 1,
94
+ :end_time => '2010-12-11T08:00:00+0000'
95
+ }]
96
+ )
97
+ end
94
98
  end
95
99
  end
96
100
  end
@@ -1,14 +1,14 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe FbGraph::Connections::Interests, '#interests' do
4
- before do
5
- fake_json(:get, 'matake/interests?access_token=access_token', 'users/interests/matake_private')
6
- end
7
-
8
4
  it 'should return interests pages as FbGraph::Page' do
9
- pages = FbGraph::User.new('matake', :access_token => 'access_token').interests
10
- pages.each do |page|
11
- page.should be_instance_of(FbGraph::Page)
5
+ mock_graph :get, 'matake/interests', 'users/interests/matake_private', :params => {
6
+ :access_token => 'access_token'
7
+ } do
8
+ pages = FbGraph::User.new('matake', :access_token => 'access_token').interests
9
+ pages.each do |page|
10
+ page.should be_instance_of(FbGraph::Page)
11
+ end
12
12
  end
13
13
  end
14
14
  end
@@ -1,14 +1,14 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe FbGraph::Connections::Invited, '#invited' do
4
- before do
5
- fake_json(:get, 'smartday/invited?access_token=access_token', 'events/invited/smartday_private')
6
- end
7
-
8
4
  it 'should return invited users as FbGraph::User' do
9
- users = FbGraph::Event.new('smartday', :access_token => 'access_token').invited
10
- users.each do |user|
11
- user.should be_instance_of(FbGraph::User)
5
+ mock_graph :get, 'smartday/invited', 'events/invited/smartday_private', :params => {
6
+ :access_token => 'access_token'
7
+ } do
8
+ users = FbGraph::Event.new('smartday', :access_token => 'access_token').invited
9
+ users.each do |user|
10
+ user.should be_instance_of(FbGraph::User)
11
+ end
12
12
  end
13
13
  end
14
14
  end
@@ -3,30 +3,31 @@ require 'spec_helper'
3
3
 
4
4
  describe FbGraph::Connections::Likes, '#likes' do
5
5
  context 'when included by FbGraph::User' do
6
- before do
7
- fake_json(:get, 'arjun/likes', 'users/likes/arjun_public', :status => [401, 'Unauthorized'])
8
- fake_json(:get, 'arjun/likes?access_token=access_token', 'users/likes/arjun_private')
9
- end
10
-
11
6
  context 'when no access_token given' do
12
7
  it 'should raise FbGraph::Unauthorized' do
13
- lambda do
14
- FbGraph::User.new('arjun').likes
15
- end.should raise_exception(FbGraph::Unauthorized)
8
+ mock_graph :get, 'arjun/likes', 'users/likes/arjun_public', :status => [401, 'Unauthorized'] do
9
+ lambda do
10
+ FbGraph::User.new('arjun').likes
11
+ end.should raise_exception(FbGraph::Unauthorized)
12
+ end
16
13
  end
17
14
  end
18
15
 
19
16
  context 'when access_token is given' do
20
17
  it 'should return liked pages as FbGraph::Page' do
21
- likes = FbGraph::User.new('arjun', :access_token => 'access_token').likes
22
- likes.first.should == FbGraph::Page.new(
23
- '378209722137',
24
- :access_token => 'access_token',
25
- :name => 'Doing Things at the Last Minute',
26
- :category => '活動'
27
- )
28
- likes.each do |like|
29
- like.should be_instance_of(FbGraph::Page)
18
+ mock_graph :get, 'arjun/likes', 'users/likes/arjun_private', :params => {
19
+ :access_token => 'access_token'
20
+ } do
21
+ likes = FbGraph::User.new('arjun', :access_token => 'access_token').likes
22
+ likes.first.should == FbGraph::Page.new(
23
+ '378209722137',
24
+ :access_token => 'access_token',
25
+ :name => 'Doing Things at the Last Minute',
26
+ :category => '活動'
27
+ )
28
+ likes.each do |like|
29
+ like.should be_instance_of(FbGraph::Page)
30
+ end
30
31
  end
31
32
  end
32
33
  end
@@ -35,8 +36,11 @@ describe FbGraph::Connections::Likes, '#likes' do
35
36
  context 'when included by FbGraph::Status' do
36
37
  context 'when cached collection exists' do
37
38
  before do
38
- fake_json(:get, 'with_likes?access_token=access_token', 'statuses/with_likes')
39
- @status = FbGraph::Status.new('with_likes').fetch(:access_token => 'access_token')
39
+ mock_graph :get, 'with_likes', 'statuses/with_likes', :params => {
40
+ :access_token => 'access_token'
41
+ } do
42
+ @status = FbGraph::Status.new('with_likes').fetch(:access_token => 'access_token')
43
+ end
40
44
  end
41
45
 
42
46
  context 'when no options given' do
@@ -2,14 +2,14 @@ require 'spec_helper'
2
2
 
3
3
  describe FbGraph::Connections::Links, '#links' do
4
4
  context 'when included by FbGraph::User' do
5
- before do
6
- fake_json(:get, 'matake/links?access_token=access_token', 'users/links/matake_private')
7
- end
8
-
9
5
  it 'should return notes as FbGraph::Link' do
10
- links = FbGraph::User.new('matake', :access_token => 'access_token').links
11
- links.each do |link|
12
- link.should be_instance_of(FbGraph::Link)
6
+ mock_graph :get, 'matake/links', 'users/links/matake_private', :params => {
7
+ :access_token => 'access_token'
8
+ } do
9
+ links = FbGraph::User.new('matake', :access_token => 'access_token').links
10
+ links.each do |link|
11
+ link.should be_instance_of(FbGraph::Link)
12
+ end
13
13
  end
14
14
  end
15
15
  end
@@ -17,19 +17,17 @@ end
17
17
 
18
18
  describe FbGraph::Connections::Links, '#link!' do
19
19
  context 'when included by FbGraph::User' do
20
- before do
21
- fake_json(:post, 'matake/links', 'users/links/post_with_valid_access_token')
22
- end
23
-
24
20
  it 'should return generated link' do
25
- link = FbGraph::User.new('matake', :access_token => 'valid').link!(
26
- :link => 'http://github.com/nov/fb_graph',
27
- :message => 'A Ruby wrapper for Facebook Graph API.'
28
- )
29
- link.identifier.should == 120765121284251
30
- link.link.should == 'http://github.com/nov/fb_graph'
31
- link.message.should == 'A Ruby wrapper for Facebook Graph API.'
32
- link.access_token.should == 'valid'
21
+ mock_graph :post, 'matake/links', 'users/links/post_with_valid_access_token' do
22
+ link = FbGraph::User.new('matake', :access_token => 'valid').link!(
23
+ :link => 'http://github.com/nov/fb_graph',
24
+ :message => 'A Ruby wrapper for Facebook Graph API.'
25
+ )
26
+ link.identifier.should == 120765121284251
27
+ link.link.should == 'http://github.com/nov/fb_graph'
28
+ link.message.should == 'A Ruby wrapper for Facebook Graph API.'
29
+ link.access_token.should == 'valid'
30
+ end
33
31
  end
34
32
  end
35
33
  end
@@ -1,24 +1,22 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe FbGraph::Connections::Maybe, '#maybe' do
4
- before do
5
- fake_json(:get, 'smartday/maybe?access_token=access_token', 'events/maybe/smartday_private')
6
- end
7
-
8
4
  it 'should return maybe users as FbGraph::User' do
9
- users = FbGraph::Event.new('smartday', :access_token => 'access_token').maybe
10
- users.each do |user|
11
- user.should be_instance_of(FbGraph::User)
5
+ mock_graph :get, 'smartday/maybe', 'events/maybe/smartday_private', :params => {
6
+ :access_token => 'access_token'
7
+ } do
8
+ users = FbGraph::Event.new('smartday', :access_token => 'access_token').maybe
9
+ users.each do |user|
10
+ user.should be_instance_of(FbGraph::User)
11
+ end
12
12
  end
13
13
  end
14
14
  end
15
15
 
16
16
  describe FbGraph::Connections::Maybe, '#maybe!' do
17
- before do
18
- fake_json(:post, '12345/maybe', 'events/maybe/post_with_valid_access_token')
19
- end
20
-
21
17
  it 'should return true' do
22
- FbGraph::Event.new('12345', :access_token => 'valid').maybe!.should be_true
18
+ mock_graph :post, '12345/maybe', 'events/maybe/post_with_valid_access_token' do
19
+ FbGraph::Event.new('12345', :access_token => 'valid').maybe!.should be_true
20
+ end
23
21
  end
24
22
  end
@@ -1,14 +1,14 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe FbGraph::Connections::Friends, '#friends' do
4
- before do
5
- fake_json(:get, 'emacs/members?access_token=access_token', 'groups/members/emacs_private')
6
- end
7
-
8
4
  it 'should return members as FbGraph::User' do
9
- users = FbGraph::Group.new('emacs', :access_token => 'access_token').members
10
- users.each do |user|
11
- user.should be_instance_of(FbGraph::User)
5
+ mock_graph :get, 'emacs/members', 'groups/members/emacs_private', :params => {
6
+ :access_token => 'access_token'
7
+ } do
8
+ users = FbGraph::Group.new('emacs', :access_token => 'access_token').members
9
+ users.each do |user|
10
+ user.should be_instance_of(FbGraph::User)
11
+ end
12
12
  end
13
13
  end
14
14
  end
@@ -1,10 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe FbGraph::Connections::Messages, '#messages' do
4
- before do
5
- fake_json(:get, '12345/messages?access_token=access_token&no_cache=true', 'thread/messages/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').messages
@@ -18,9 +14,14 @@ describe FbGraph::Connections::Messages, '#messages' do
18
14
  end
19
15
 
20
16
  it 'should return threads as FbGraph::Message' do
21
- messages = FbGraph::Thread.new(12345, :access_token => 'access_token').messages(:no_cache => true)
22
- messages.each do |message|
23
- message.should be_instance_of(FbGraph::Message)
17
+ mock_graph :get, '12345/messages', 'thread/messages/private', :params => {
18
+ :access_token => 'access_token',
19
+ :no_cache => 'true'
20
+ } do
21
+ messages = FbGraph::Thread.new(12345, :access_token => 'access_token').messages(:no_cache => true)
22
+ messages.each do |message|
23
+ message.should be_instance_of(FbGraph::Message)
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::Movies, '#movies' do
4
- before do
5
- fake_json(:get, 'matake/movies?access_token=access_token', 'users/movies/matake_private')
6
- end
7
-
8
4
  it 'should return movies pages as FbGraph::Page' do
9
- pages = FbGraph::User.new('matake', :access_token => 'access_token').movies
10
- pages.each do |page|
11
- page.should be_instance_of(FbGraph::Page)
5
+ mock_graph :get, 'matake/movies', 'users/movies/matake_private', :params => {
6
+ :access_token => 'access_token'
7
+ } do
8
+ pages = FbGraph::User.new('matake', :access_token => 'access_token').movies
9
+ pages.each do |page|
10
+ page.should be_instance_of(FbGraph::Page)
11
+ end
12
12
  end
13
13
  end
14
14
  end
@@ -1,14 +1,14 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe FbGraph::Connections::Music, '#music' do
4
- before do
5
- fake_json(:get, 'matake/music?access_token=access_token', 'users/music/matake_private')
6
- end
7
-
8
4
  it 'should return music pages as FbGraph::Page' do
9
- pages = FbGraph::User.new('matake', :access_token => 'access_token').music
10
- pages.each do |page|
11
- page.should be_instance_of(FbGraph::Page)
5
+ mock_graph :get, 'matake/music', 'users/music/matake_private', :params => {
6
+ :access_token => 'access_token'
7
+ } do
8
+ pages = FbGraph::User.new('matake', :access_token => 'access_token').music
9
+ pages.each do |page|
10
+ page.should be_instance_of(FbGraph::Page)
11
+ end
12
12
  end
13
13
  end
14
14
  end
@@ -1,14 +1,14 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe FbGraph::Connections::Noreply, '#noreply' do
4
- before do
5
- fake_json(:get, 'smartday/noreply?access_token=access_token', 'events/noreply/smartday_private')
6
- end
7
-
8
4
  it 'should return noreply users as FbGraph::User' do
9
- users = FbGraph::Event.new('smartday', :access_token => 'access_token').noreply
10
- users.each do |user|
11
- user.should be_instance_of(FbGraph::User)
5
+ mock_graph :get, 'smartday/noreply', 'events/noreply/smartday_private', :params => {
6
+ :access_token => 'access_token'
7
+ } do
8
+ users = FbGraph::Event.new('smartday', :access_token => 'access_token').noreply
9
+ users.each do |user|
10
+ user.should be_instance_of(FbGraph::User)
11
+ end
12
12
  end
13
13
  end
14
14
  end
@@ -2,14 +2,14 @@ require 'spec_helper'
2
2
 
3
3
  describe FbGraph::Connections::Notes, '#notes' do
4
4
  context 'when included by FbGraph::User' do
5
- before do
6
- fake_json(:get, 'matake/notes?access_token=access_token', 'users/notes/matake_private')
7
- end
8
-
9
5
  it 'should return notes as FbGraph::Note' do
10
- notes = FbGraph::User.new('matake', :access_token => 'access_token').notes
11
- notes.each do |note|
12
- note.should be_instance_of(FbGraph::Note)
6
+ mock_graph :get, 'matake/notes', 'users/notes/matake_private', :params => {
7
+ :access_token => 'access_token'
8
+ } do
9
+ notes = FbGraph::User.new('matake', :access_token => 'access_token').notes
10
+ notes.each do |note|
11
+ note.should be_instance_of(FbGraph::Note)
12
+ end
13
13
  end
14
14
  end
15
15
  end
@@ -17,16 +17,18 @@ end
17
17
 
18
18
  describe FbGraph::Connections::Notes, '#note!' do
19
19
  context 'when included by FbGraph::Page' do
20
- before do
21
- fake_json(:post, '12345/notes', 'pages/notes/post_with_valid_access_token')
22
- end
23
-
24
20
  it 'should return generated note' do
25
- note = FbGraph::Page.new('12345', :access_token => 'valid').note!(:subject => 'test', :message => 'hello')
26
- note.identifier.should == 396664845100
27
- note.subject.should == 'test'
28
- note.message.should == 'hello'
29
- note.access_token.should == 'valid'
21
+ mock_graph :post, '12345/notes', 'pages/notes/post_with_valid_access_token', :params => {
22
+ :access_token => 'valid',
23
+ :subject => 'test',
24
+ :message => 'hello'
25
+ } do
26
+ note = FbGraph::Page.new('12345', :access_token => 'valid').note!(:subject => 'test', :message => 'hello')
27
+ note.identifier.should == 396664845100
28
+ note.subject.should == 'test'
29
+ note.message.should == 'hello'
30
+ note.access_token.should == 'valid'
31
+ end
30
32
  end
31
33
  end
32
34
  end
@@ -1,10 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe FbGraph::Connections::Participants, '#participants' do
4
- before do
5
- fake_json(:get, '12345/participants?access_token=access_token&no_cache=true', 'thread/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').participants
@@ -18,9 +14,14 @@ describe FbGraph::Connections::Participants, '#participants' do
18
14
  end
19
15
 
20
16
  it 'should return participants as FbGraph::User' do
21
- participants = FbGraph::Thread.new(12345, :access_token => 'access_token').participants(:no_cache => true)
22
- participants.each do |participant|
23
- participant.should be_instance_of(FbGraph::User)
17
+ mock_graph :get, '12345/participants', 'thread/participants/private', :params => {
18
+ :access_token => 'access_token',
19
+ :no_cache => 'true'
20
+ } do
21
+ participants = FbGraph::Thread.new(12345, :access_token => 'access_token').participants(:no_cache => true)
22
+ participants.each do |participant|
23
+ participant.should be_instance_of(FbGraph::User)
24
+ end
24
25
  end
25
26
  end
26
27
  end
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ describe FbGraph::Connections::Permissions, '#permissions' do
4
+ let :permissions do
5
+ mock_graph :get, 'me/permissions', 'users/permissions/me_private', :params => {
6
+ :access_token => 'access_token'
7
+ } do
8
+ FbGraph::User.me('access_token').permissions
9
+ end
10
+ end
11
+ it 'should be an Array of Symbol' do
12
+ permissions.should be_instance_of Array
13
+ permissions.should_not be_blank
14
+ permissions.each do |permission|
15
+ permission.should be_instance_of Symbol
16
+ end
17
+ end
18
+ end