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
data/lib/fb_graph/user.rb CHANGED
@@ -10,6 +10,7 @@ module FbGraph
10
10
  include Connections::Feed
11
11
  include Connections::FriendLists
12
12
  include Connections::Friends
13
+ include Connections::Family
13
14
  include Connections::Games
14
15
  include Connections::Groups
15
16
  include Connections::Home
@@ -20,6 +21,7 @@ module FbGraph
20
21
  include Connections::Music
21
22
  include Connections::Notes
22
23
  include Connections::Payments
24
+ include Connections::Permissions
23
25
  include Connections::Photos
24
26
  include Connections::Picture
25
27
  include Connections::Posts
@@ -30,7 +32,7 @@ module FbGraph
30
32
  include Connections::Videos
31
33
  extend Searchable
32
34
 
33
- attr_accessor :first_name, :last_name, :name, :link, :about, :birthday, :work, :education, :email, :website, :hometown, :location, :bio, :quotes, :gender, :interested_in, :meeting_for, :relationship_status, :religion, :political, :verified, :significant_other, :timezone, :updated_time, :sports, :favorite_teams, :favorite_athletes, :inspirational_people, :locale, :languages, :third_party_id, :address, :mobile_phone
35
+ attr_accessor :first_name, :last_name, :name, :link, :about, :birthday, :work, :education, :email, :website, :hometown, :location, :bio, :quotes, :gender, :interested_in, :meeting_for, :relationship, :relationship_status, :religion, :political, :verified, :significant_other, :timezone, :updated_time, :sports, :favorite_teams, :favorite_athletes, :inspirational_people, :locale, :languages, :third_party_id, :address, :mobile_phone
34
36
 
35
37
  def initialize(identifier, attributes = {})
36
38
  super
@@ -93,6 +95,7 @@ module FbGraph
93
95
  @gender = attributes[:gender]
94
96
  @interested_in = Array(attributes[:interested_in])
95
97
  @meeting_for = Array(attributes[:meeting_for])
98
+ @relationship = attributes[:relationship]
96
99
  @relationship_status = attributes[:relationship_status]
97
100
  @religion = attributes[:religion]
98
101
  @political = attributes[:political]
data/lib/fb_graph.rb CHANGED
@@ -1,4 +1,3 @@
1
- require 'rubygems'
2
1
  require 'rack/oauth2'
3
2
 
4
3
  module FbGraph
@@ -21,19 +21,13 @@ describe FbGraph::Application, '.new' do
21
21
  end
22
22
 
23
23
  describe FbGraph::Application, '.get_access_token' do
24
- before do
25
- fake_json :post, 'oauth/access_token', 'token_response'
26
- @app = FbGraph::Application.new('client_id', :secret => 'client_secret')
27
- end
28
-
29
- it 'should POST oauth/token' do
30
- @app.access_token.should be_nil
31
- @app.get_access_token
32
- @app.access_token.should be_instance_of(Rack::OAuth2::AccessToken::Legacy)
33
- @app.access_token.access_token.should == 'token'
34
- end
35
-
36
- after do
37
- FakeWeb.clean_registry
24
+ let(:app) { FbGraph::Application.new('client_id', :secret => 'client_secret') }
25
+ it 'should return Rack::OAuth2::AccessToken::Legacy' do
26
+ mock_graph :post, 'oauth/access_token', 'token_response' do
27
+ app.access_token.should be_nil
28
+ app.get_access_token
29
+ app.access_token.should be_instance_of(Rack::OAuth2::AccessToken::Legacy)
30
+ app.access_token.access_token.should == 'token'
31
+ end
38
32
  end
39
33
  end
@@ -39,7 +39,7 @@ describe FbGraph::Auth, '#from_cookie' do
39
39
  @auth.user.should be_nil
40
40
  @auth.from_cookie(@cookie)
41
41
  @auth.access_token.access_token.should == 't'
42
- @auth.access_token.expires_in.should be_close @expires_at - Time.now, 1
42
+ @auth.access_token.expires_in.should be_within(1).of(@expires_at - Time.now)
43
43
  @auth.user.identifier.should == '12345'
44
44
  @auth.user.access_token.access_token.should == 't'
45
45
  end
@@ -15,24 +15,28 @@ describe FbGraph::Checkin, '.new' do
15
15
  end
16
16
 
17
17
  describe FbGraph::Checkin, '.search' do
18
- before do
19
- fake_json(:get, 'search?type=checkin', 'checkins/search_public', :status => [401, 'Unauthorized'])
20
- fake_json(:get, 'search?type=checkin&access_token=access_token', 'checkins/search_private')
21
- end
22
-
23
18
  context 'when no access_token given' do
24
19
  it 'should raise FbGraph::Unauthorized' do
25
- lambda do
26
- FbGraph::Checkin.search
27
- end.should raise_exception(FbGraph::Unauthorized)
20
+ mock_graph :get, 'search', 'checkins/search_public', :params => {
21
+ :type => 'checkin'
22
+ }, :status => [401, 'Unauthorized'] do
23
+ lambda do
24
+ FbGraph::Checkin.search
25
+ end.should raise_exception(FbGraph::Unauthorized)
26
+ end
28
27
  end
29
28
  end
30
29
 
31
30
  context 'when access_token is given' do
32
31
  it 'should return checkins as FbGraph::Checkin' do
33
- checkins = FbGraph::Checkin.search(:access_token => 'access_token')
34
- checkins.each do |checkin|
35
- checkin.should be_instance_of(FbGraph::Checkin)
32
+ mock_graph :get, 'search', 'checkins/search_private', :params => {
33
+ :type => 'checkin',
34
+ :access_token => 'access_token'
35
+ } do
36
+ checkins = FbGraph::Checkin.search(:access_token => 'access_token')
37
+ checkins.each do |checkin|
38
+ checkin.should be_instance_of(FbGraph::Checkin)
39
+ end
36
40
  end
37
41
  end
38
42
  end
@@ -1,15 +1,16 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe FbGraph::Collection, '.new' do
4
- before do
5
- fake_json(:get, 'platform/statuses?access_token=access_token', 'pages/statuses/platform_private')
6
- end
7
4
 
8
5
  it 'should return an array with pagination info' do
9
- collection = FbGraph::Page.new('platform', :access_token => 'access_token').statuses.collection
10
- collection.should be_kind_of(Array)
11
- collection.previous.should be_kind_of(Hash)
12
- collection.next.should be_kind_of(Hash)
6
+ mock_graph :get, 'platform/statuses', 'pages/statuses/platform_private', :params => {
7
+ :access_token => 'access_token'
8
+ } do
9
+ collection = FbGraph::Page.new('platform', :access_token => 'access_token').statuses.collection
10
+ collection.should be_kind_of(Array)
11
+ collection.previous.should be_kind_of(Hash)
12
+ collection.next.should be_kind_of(Hash)
13
+ end
13
14
  end
14
15
 
15
16
  it 'should allow blank data' do
@@ -1,37 +1,48 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe FbGraph::Connection, '.new' do
4
- before do
5
- fake_json(:get, 'platform/statuses?access_token=access_token', 'pages/statuses/platform_private')
6
- end
7
-
8
4
  it 'should return an array with connection info' do
9
- page = FbGraph::Page.new('platform', :access_token => 'access_token')
10
- statuses = page.statuses
11
- statuses.should be_kind_of(Array)
12
- statuses.collection.should be_kind_of(FbGraph::Collection)
13
- statuses.owner.should == page
14
- statuses.connection.should == :statuses
5
+ mock_graph :get, 'platform/statuses', 'pages/statuses/platform_private', :params => {
6
+ :access_token => 'access_token'
7
+ } do
8
+ page = FbGraph::Page.new('platform', :access_token => 'access_token')
9
+ statuses = page.statuses
10
+ statuses.should be_kind_of(Array)
11
+ statuses.collection.should be_kind_of(FbGraph::Collection)
12
+ statuses.owner.should == page
13
+ statuses.connection.should == :statuses
14
+ end
15
15
  end
16
16
  end
17
17
 
18
18
  describe FbGraph::Connection do
19
- before do
20
- fake_json(:get, 'me/home?access_token=access_token', 'users/home/me_private')
21
- fake_json(:get, 'me/home?limit=25&since=2010-04-27T13%3A06%3A14%2B0000&access_token=access_token', 'users/home/me_private_previous')
22
- fake_json(:get, 'me/home?limit=25&access_token=access_token&until=2010-04-27T11%3A07%3A48%2B0000', 'users/home/me_private_next')
23
- end
24
-
25
19
  it 'should be useful for pagenation' do
26
20
  me = FbGraph::User.new('me', :access_token => 'access_token')
27
- posts = me.home
28
- posts.first.created_time.should == Time.parse('2010-04-27T13:06:14+0000')
29
- posts.last.created_time.should == Time.parse('2010-04-27T11:07:48+0000')
30
- previous_posts = posts.previous
31
- previous_posts.first.created_time.should == Time.parse('2010-04-27T13:23:08+0000')
32
- previous_posts.last.created_time.should == Time.parse('2010-04-27T13:10:56+0000')
33
- next_posts = posts.next
34
- next_posts.first.created_time.should == Time.parse('2010-04-27T11:06:29+0000')
35
- next_posts.last.created_time.should == Time.parse('2010-04-27T09:44:28+0000')
21
+ posts = nil
22
+ mock_graph :get, 'me/home', 'users/home/me_private', :params => {
23
+ :access_token => 'access_token'
24
+ } do
25
+ posts = me.home
26
+ posts.first.created_time.should == Time.parse('2010-04-27T13:06:14+0000')
27
+ posts.last.created_time.should == Time.parse('2010-04-27T11:07:48+0000')
28
+ end
29
+ mock_graph :get, 'me/home', 'users/home/me_private_previous', :params => {
30
+ :access_token => 'access_token',
31
+ :limit => '25',
32
+ :since => '2010-04-27T13:06:14+0000'
33
+ } do
34
+ previous_posts = posts.previous
35
+ previous_posts.first.created_time.should == Time.parse('2010-04-27T13:23:08+0000')
36
+ previous_posts.last.created_time.should == Time.parse('2010-04-27T13:10:56+0000')
37
+ end
38
+ mock_graph :get, 'me/home', 'users/home/me_private_next', :params => {
39
+ :access_token => 'access_token',
40
+ :limit => '25',
41
+ :until => '2010-04-27T11:07:48+0000'
42
+ } do
43
+ next_posts = posts.next
44
+ next_posts.first.created_time.should == Time.parse('2010-04-27T11:06:29+0000')
45
+ next_posts.last.created_time.should == Time.parse('2010-04-27T09:44:28+0000')
46
+ end
36
47
  end
37
48
  end
@@ -2,44 +2,48 @@ require 'spec_helper'
2
2
 
3
3
  describe FbGraph::Connections::Accounts, '#accounts' do
4
4
  context 'when included by FbGraph::User' do
5
- before do
6
- fake_json(:get, 'matake/accounts', 'users/accounts/matake_public', :status => [401, 'Unauthorized'])
7
- fake_json(:get, 'matake/accounts?access_token=access_token', 'users/accounts/matake_private')
8
- fake_json(:get, 'matake/accounts?access_token=access_token_with_manage_pages_permission', 'users/accounts/matake_private_with_manage_pages_permission')
9
- end
10
-
11
5
  context 'when no access_token given' do
12
6
  it 'should raise FbGraph::Unauthorized' do
13
- lambda do
14
- FbGraph::User.new('matake').accounts
15
- end.should raise_exception(FbGraph::Unauthorized)
7
+ mock_graph :get, 'matake/accounts', 'users/accounts/matake_public', :status => [401, 'Unauthorized'] do
8
+ lambda do
9
+ FbGraph::User.new('matake').accounts
10
+ end.should raise_exception(FbGraph::Unauthorized)
11
+ end
16
12
  end
17
13
  end
18
14
 
19
15
  context 'when access_token is given' do
20
16
  it 'should return accounts as FbGraph::Page' do
21
- accounts = FbGraph::User.new('matake', :access_token => 'access_token').accounts
22
- accounts.class.should == FbGraph::Connection
23
- accounts.first.should == FbGraph::Page.new(
24
- '140478125968442',
25
- :access_token => 'access_token',
26
- :name => 'OAuth.jp',
27
- :category => 'Technology'
28
- )
29
- accounts.each do |account|
30
- account.should be_instance_of(FbGraph::Page)
31
- end
32
- end
33
-
34
- context 'when manage_pages permission given' do
35
- it 'should has special access_token behalf of the page' do
36
- accounts = FbGraph::User.new('matake', :access_token => 'access_token_with_manage_pages_permission').accounts
17
+ mock_graph :get, 'matake/accounts', 'users/accounts/matake_private', :params => {
18
+ :access_token => 'access_token'
19
+ } do
20
+ accounts = FbGraph::User.new('matake', :access_token => 'access_token').accounts
21
+ accounts.class.should == FbGraph::Connection
37
22
  accounts.first.should == FbGraph::Page.new(
38
23
  '140478125968442',
39
- :access_token => 'access_token_for_oauth_jp',
24
+ :access_token => 'access_token',
40
25
  :name => 'OAuth.jp',
41
26
  :category => 'Technology'
42
27
  )
28
+ accounts.each do |account|
29
+ account.should be_instance_of(FbGraph::Page)
30
+ end
31
+ end
32
+ end
33
+
34
+ context 'when manage_pages permission given' do
35
+ it 'should has special access_token behalf of the page' do
36
+ mock_graph :get, 'matake/accounts', 'users/accounts/matake_private_with_manage_pages_permission', :params => {
37
+ :access_token => 'access_token_for_user'
38
+ } do
39
+ accounts = FbGraph::User.new('matake', :access_token => 'access_token_for_user').accounts
40
+ accounts.first.should == FbGraph::Page.new(
41
+ '140478125968442',
42
+ :access_token => 'access_token_for_oauth_jp',
43
+ :name => 'OAuth.jp',
44
+ :category => 'Technology'
45
+ )
46
+ end
43
47
  end
44
48
  end
45
49
  end
@@ -3,31 +3,32 @@ require 'spec_helper'
3
3
 
4
4
  describe FbGraph::Connections::Activities, '#activities' do
5
5
  context 'when included by FbGraph::User' do
6
- before do
7
- fake_json(:get, 'arjun/activities', 'users/activities/arjun_public', :status => [401, 'Unauthorized'])
8
- fake_json(:get, 'arjun/activities?access_token=access_token', 'users/activities/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').activities
15
- end.should raise_exception(FbGraph::Unauthorized)
8
+ mock_graph :get, 'arjun/activities', 'users/activities/arjun_public', :status => [401, 'Unauthorized'] do
9
+ lambda do
10
+ FbGraph::User.new('arjun').activities
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 activities as FbGraph::Page' do
21
- activities = FbGraph::User.new('arjun', :access_token => 'access_token').activities
22
- activities.class.should == FbGraph::Connection
23
- activities.first.should == FbGraph::Page.new(
24
- '378209722137',
25
- :access_token => 'access_token',
26
- :name => 'Doing Things at the Last Minute',
27
- :category => '活動'
28
- )
29
- activities.each do |activity|
30
- activity.should be_instance_of(FbGraph::Page)
18
+ mock_graph :get, 'arjun/activities', 'users/activities/arjun_private', :params => {
19
+ :access_token => 'access_token'
20
+ } do
21
+ activities = FbGraph::User.new('arjun', :access_token => 'access_token').activities
22
+ activities.class.should == FbGraph::Connection
23
+ activities.first.should == FbGraph::Page.new(
24
+ '378209722137',
25
+ :access_token => 'access_token',
26
+ :name => 'Doing Things at the Last Minute',
27
+ :category => '活動'
28
+ )
29
+ activities.each do |activity|
30
+ activity.should be_instance_of(FbGraph::Page)
31
+ end
31
32
  end
32
33
  end
33
34
  end
@@ -3,40 +3,41 @@ require 'spec_helper'
3
3
 
4
4
  describe FbGraph::Connections::Albums, '#albums' do
5
5
  context 'when included by FbGraph::User' do
6
- before do
7
- fake_json(:get, 'matake/albums', 'users/albums/matake_public', :status => [401, 'Unauthorized'])
8
- fake_json(:get, 'matake/albums?access_token=access_token', 'users/albums/matake_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('matake').albums
15
- end.should raise_exception(FbGraph::Unauthorized)
8
+ mock_graph :get, 'matake/albums', 'users/albums/matake_public', :status => [401, 'Unauthorized'] do
9
+ lambda do
10
+ FbGraph::User.new('matake').albums
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 albums as FbGraph::Album' do
21
- albums = FbGraph::User.new('matake', :access_token => 'access_token').albums
22
- albums.first.should == FbGraph::Album.new(
23
- '19351532276',
24
- :access_token => 'access_token',
25
- :from => {
26
- :id => '579612276',
27
- :name => 'Nov Matake'
28
- },
29
- :name => 'モバイルアップロード',
30
- :description => 'hello facebookers!',
31
- :link => 'http://www.facebook.com/album.php?aid=25463&id=579612276',
32
- :location => 'NYC',
33
- :count => 3,
34
- :privacy => 'everyone',
35
- :created_time => '2008-07-27T11:38:15+0000',
36
- :updated_time => '2009-02-07T16:09:53+0000'
37
- )
38
- albums.each do |album|
39
- album.should be_instance_of(FbGraph::Album)
18
+ mock_graph :get, 'matake/albums', 'users/albums/matake_private', :params => {
19
+ :access_token => 'access_token'
20
+ } do
21
+ albums = FbGraph::User.new('matake', :access_token => 'access_token').albums
22
+ albums.first.should == FbGraph::Album.new(
23
+ '19351532276',
24
+ :access_token => 'access_token',
25
+ :from => {
26
+ :id => '579612276',
27
+ :name => 'Nov Matake'
28
+ },
29
+ :name => 'モバイルアップロード',
30
+ :description => 'hello facebookers!',
31
+ :link => 'http://www.facebook.com/album.php?aid=25463&id=579612276',
32
+ :location => 'NYC',
33
+ :count => 3,
34
+ :privacy => 'everyone',
35
+ :created_time => '2008-07-27T11:38:15+0000',
36
+ :updated_time => '2009-02-07T16:09:53+0000'
37
+ )
38
+ albums.each do |album|
39
+ album.should be_instance_of(FbGraph::Album)
40
+ end
40
41
  end
41
42
  end
42
43
  end
@@ -45,19 +46,21 @@ end
45
46
 
46
47
  describe FbGraph::Connections::Albums, '#album!' do
47
48
  context 'when included by FbGraph::User' do
48
- before do
49
- fake_json(:post, 'matake/albums', 'users/albums/post_with_valid_access_token')
50
- end
51
-
52
49
  it 'should return generated album' do
53
- album = FbGraph::User.new('matake', :access_token => 'valid').album!(
50
+ mock_graph :post, 'matake/albums', 'users/albums/post_with_valid_access_token', :params => {
51
+ :access_token => 'valid',
54
52
  :name => 'FbGraph test',
55
53
  :message => 'test test test'
56
- )
57
- album.identifier.should == 401096332276
58
- album.access_token.should == 'valid'
59
- album.name.should == 'FbGraph test'
60
- album.description.should == 'test test test'
54
+ } do
55
+ album = FbGraph::User.new('matake', :access_token => 'valid').album!(
56
+ :name => 'FbGraph test',
57
+ :message => 'test test test'
58
+ )
59
+ album.identifier.should == 401096332276
60
+ album.access_token.should == 'valid'
61
+ album.name.should == 'FbGraph test'
62
+ album.description.should == 'test test test'
63
+ end
61
64
  end
62
65
  end
63
66
  end
@@ -1,14 +1,14 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe FbGraph::Connections::AppRequests, '#app_requests' do
4
- before do
5
- fake_json(:get, 'me/apprequests?access_token=access_token', 'users/app_requests/me_private')
6
- end
7
-
8
4
  it 'should return app_requests as FbGraph::AppRequest' do
9
- app_requests = FbGraph::User.me('access_token').app_requests
10
- app_requests.each do |app_request|
11
- app_request.should be_instance_of(FbGraph::AppRequest)
5
+ mock_graph :get, 'me/apprequests', 'users/app_requests/me_private', :params => {
6
+ :access_token => 'access_token'
7
+ } do
8
+ app_requests = FbGraph::User.me('access_token').app_requests
9
+ app_requests.each do |app_request|
10
+ app_request.should be_instance_of(FbGraph::AppRequest)
11
+ end
12
12
  end
13
13
  end
14
14
  end
@@ -1,24 +1,24 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe FbGraph::Connections::Attending, '#attending' do
4
- before do
5
- fake_json(:get, 'smartday/attending?access_token=access_token', 'events/attending/smartday_private')
6
- end
7
-
8
4
  it 'should return attending users as FbGraph::User' do
9
- users = FbGraph::Event.new('smartday', :access_token => 'access_token').attending
10
- users.each do |user|
11
- user.should be_instance_of(FbGraph::User)
5
+ mock_graph :get, 'smartday/attending', 'events/attending/smartday_private', :params => {
6
+ :access_token => 'access_token'
7
+ } do
8
+ users = FbGraph::Event.new('smartday', :access_token => 'access_token').attending
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::Attending, '#attending!' do
17
- before do
18
- fake_json(:post, '12345/attending', 'events/attending/post_with_valid_access_token')
19
- end
20
-
21
17
  it 'should return true' do
22
- FbGraph::Event.new('12345', :access_token => 'valid').attending!.should be_true
18
+ mock_graph :post, '12345/attending', 'events/attending/post_with_valid_access_token', :params => {
19
+ :access_token => 'valid'
20
+ } do
21
+ FbGraph::Event.new('12345', :access_token => 'valid').attending!.should be_true
22
+ end
23
23
  end
24
24
  end
@@ -2,30 +2,31 @@ require 'spec_helper'
2
2
 
3
3
  describe FbGraph::Connections::Books, '#books' do
4
4
  context 'when included by FbGraph::User' do
5
- before do
6
- fake_json(:get, 'matake/books', 'users/books/matake_public', :status => [401, 'Unauthorized'])
7
- fake_json(:get, 'matake/books?access_token=access_token', 'users/books/matake_private')
8
- end
9
-
10
5
  context 'when no access_token given' do
11
6
  it 'should raise FbGraph::Unauthorized' do
12
- lambda do
13
- FbGraph::User.new('matake').books
14
- end.should raise_exception(FbGraph::Unauthorized)
7
+ mock_graph :get, 'matake/books', 'users/books/matake_public', :status => [401, 'Unauthorized'] do
8
+ lambda do
9
+ FbGraph::User.new('matake').books
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 books as FbGraph::Page' do
20
- books = FbGraph::User.new('matake', :access_token => 'access_token').books
21
- books.first.should == FbGraph::Page.new(
22
- '102253616477130',
23
- :access_token => 'access_token',
24
- :name => 'Momo Michael Ende',
25
- :category => 'Unknown'
26
- )
27
- books.each do |book|
28
- book.should be_instance_of(FbGraph::Page)
17
+ mock_graph :get, 'matake/books', 'users/books/matake_private', :params => {
18
+ :access_token => 'access_token'
19
+ } do
20
+ books = FbGraph::User.new('matake', :access_token => 'access_token').books
21
+ books.first.should == FbGraph::Page.new(
22
+ '102253616477130',
23
+ :access_token => 'access_token',
24
+ :name => 'Momo Michael Ende',
25
+ :category => 'Unknown'
26
+ )
27
+ books.each do |book|
28
+ book.should be_instance_of(FbGraph::Page)
29
+ end
29
30
  end
30
31
  end
31
32
  end