palidanx-fb_graph 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (211) hide show
  1. data/.document +5 -0
  2. data/.gitignore +21 -0
  3. data/LICENSE +20 -0
  4. data/README.rdoc +308 -0
  5. data/Rakefile +49 -0
  6. data/VERSION +1 -0
  7. data/assets/fb_graph.ai +1726 -6
  8. data/assets/fb_graph.png +0 -0
  9. data/fb_graph.gemspec +327 -0
  10. data/lib/fb_graph.rb +75 -0
  11. data/lib/fb_graph/album.rb +133 -0
  12. data/lib/fb_graph/application.rb +57 -0
  13. data/lib/fb_graph/auth.rb +52 -0
  14. data/lib/fb_graph/auth/cookie.rb +43 -0
  15. data/lib/fb_graph/checkin.rb +44 -0
  16. data/lib/fb_graph/collection.rb +44 -0
  17. data/lib/fb_graph/comment.rb +20 -0
  18. data/lib/fb_graph/comparison.rb +9 -0
  19. data/lib/fb_graph/connection.rb +30 -0
  20. data/lib/fb_graph/connections.rb +3 -0
  21. data/lib/fb_graph/connections/accounts.rb +58 -0
  22. data/lib/fb_graph/connections/activities.rb +14 -0
  23. data/lib/fb_graph/connections/albums.rb +96 -0
  24. data/lib/fb_graph/connections/attending.rb +18 -0
  25. data/lib/fb_graph/connections/books.rb +14 -0
  26. data/lib/fb_graph/connections/checkins.rb +22 -0
  27. data/lib/fb_graph/connections/comments.rb +39 -0
  28. data/lib/fb_graph/connections/declined.rb +18 -0
  29. data/lib/fb_graph/connections/events.rb +21 -0
  30. data/lib/fb_graph/connections/feed.rb +90 -0
  31. data/lib/fb_graph/connections/friends.rb +14 -0
  32. data/lib/fb_graph/connections/groups.rb +14 -0
  33. data/lib/fb_graph/connections/home.rb +14 -0
  34. data/lib/fb_graph/connections/insights.rb +13 -0
  35. data/lib/fb_graph/connections/interests.rb +14 -0
  36. data/lib/fb_graph/connections/invited.rb +14 -0
  37. data/lib/fb_graph/connections/likes.rb +16 -0
  38. data/lib/fb_graph/connections/links.rb +21 -0
  39. data/lib/fb_graph/connections/maybe.rb +18 -0
  40. data/lib/fb_graph/connections/members.rb +14 -0
  41. data/lib/fb_graph/connections/movies.rb +14 -0
  42. data/lib/fb_graph/connections/music.rb +14 -0
  43. data/lib/fb_graph/connections/noreply.rb +14 -0
  44. data/lib/fb_graph/connections/notes.rb +21 -0
  45. data/lib/fb_graph/connections/photos.rb +21 -0
  46. data/lib/fb_graph/connections/picture.rb +14 -0
  47. data/lib/fb_graph/connections/posts.rb +14 -0
  48. data/lib/fb_graph/connections/statuses.rb +14 -0
  49. data/lib/fb_graph/connections/subscriptions.rb +53 -0
  50. data/lib/fb_graph/connections/tagged.rb +14 -0
  51. data/lib/fb_graph/connections/television.rb +14 -0
  52. data/lib/fb_graph/connections/videos.rb +14 -0
  53. data/lib/fb_graph/education.rb +25 -0
  54. data/lib/fb_graph/event.rb +47 -0
  55. data/lib/fb_graph/group.rb +27 -0
  56. data/lib/fb_graph/insight.rb +14 -0
  57. data/lib/fb_graph/link.rb +28 -0
  58. data/lib/fb_graph/node.rb +121 -0
  59. data/lib/fb_graph/note.rb +28 -0
  60. data/lib/fb_graph/page.rb +41 -0
  61. data/lib/fb_graph/photo.rb +41 -0
  62. data/lib/fb_graph/post.rb +50 -0
  63. data/lib/fb_graph/searchable.rb +25 -0
  64. data/lib/fb_graph/searchable/result.rb +31 -0
  65. data/lib/fb_graph/status.rb +23 -0
  66. data/lib/fb_graph/subscription.rb +14 -0
  67. data/lib/fb_graph/tag.rb +16 -0
  68. data/lib/fb_graph/user.rb +89 -0
  69. data/lib/fb_graph/venue.rb +17 -0
  70. data/lib/fb_graph/video.rb +28 -0
  71. data/lib/fb_graph/work.rb +35 -0
  72. data/spec/fake_json/albums/photos/matake_private.json +97 -0
  73. data/spec/fake_json/albums/photos/post_with_valid_access_token.json +1 -0
  74. data/spec/fake_json/applications/subscriptions/fb_graph_private.json +12 -0
  75. data/spec/fake_json/checkins/search_private.json +54 -0
  76. data/spec/fake_json/checkins/search_public.json +6 -0
  77. data/spec/fake_json/events/attending/post_with_valid_access_token.json +1 -0
  78. data/spec/fake_json/events/attending/smartday_private.json +44 -0
  79. data/spec/fake_json/events/declined/post_with_valid_access_token.json +1 -0
  80. data/spec/fake_json/events/declined/smartday_private.json +720 -0
  81. data/spec/fake_json/events/invited/smartday_private.json +7092 -0
  82. data/spec/fake_json/events/maybe/post_with_valid_access_token.json +1 -0
  83. data/spec/fake_json/events/maybe/smartday_private.json +956 -0
  84. data/spec/fake_json/events/noreply/smartday_private.json +896 -0
  85. data/spec/fake_json/groups/members/emacs_private.json +1996 -0
  86. data/spec/fake_json/pages/checkins/gowalla_private.json +113 -0
  87. data/spec/fake_json/pages/checkins/gowalla_public.json +6 -0
  88. data/spec/fake_json/pages/notes/post_with_valid_access_token.json +1 -0
  89. data/spec/fake_json/pages/platform_private.json +13 -0
  90. data/spec/fake_json/pages/platform_public.json +13 -0
  91. data/spec/fake_json/pages/statuses/platform_private.json +258 -0
  92. data/spec/fake_json/pages/statuses/platform_public.json +6 -0
  93. data/spec/fake_json/posts/comments/post_with_invalid_access_token.json +1 -0
  94. data/spec/fake_json/posts/comments/post_with_valid_access_token.json +1 -0
  95. data/spec/fake_json/posts/comments/post_without_access_token.json +1 -0
  96. data/spec/fake_json/posts/likes/post_with_invalid_access_token.json +1 -0
  97. data/spec/fake_json/posts/likes/post_with_valid_access_token.json +1 -0
  98. data/spec/fake_json/posts/likes/post_without_access_token.json +1 -0
  99. data/spec/fake_json/posts/platform_private.json +97 -0
  100. data/spec/fake_json/posts/platform_public.json +52 -0
  101. data/spec/fake_json/users/accounts/matake_private.json +14 -0
  102. data/spec/fake_json/users/accounts/matake_private_with_manage_pages_permission.json +16 -0
  103. data/spec/fake_json/users/accounts/matake_public.json +6 -0
  104. data/spec/fake_json/users/activities/arjun_private.json +24 -0
  105. data/spec/fake_json/users/activities/arjun_public.json +6 -0
  106. data/spec/fake_json/users/albums/matake_private.json +36 -0
  107. data/spec/fake_json/users/albums/matake_public.json +6 -0
  108. data/spec/fake_json/users/albums/post_with_valid_access_token.json +1 -0
  109. data/spec/fake_json/users/arjun_private.json +109 -0
  110. data/spec/fake_json/users/arjun_public.json +12 -0
  111. data/spec/fake_json/users/books/matake_private.json +9 -0
  112. data/spec/fake_json/users/books/matake_public.json +6 -0
  113. data/spec/fake_json/users/checkins/mattt_private.json +389 -0
  114. data/spec/fake_json/users/checkins/mattt_public.json +6 -0
  115. data/spec/fake_json/users/events/matake_private.json +71 -0
  116. data/spec/fake_json/users/events/matake_public.json +6 -0
  117. data/spec/fake_json/users/events/post_with_valid_access_token.json +1 -0
  118. data/spec/fake_json/users/feed/arjun_private.json +520 -0
  119. data/spec/fake_json/users/feed/arjun_public.json +520 -0
  120. data/spec/fake_json/users/feed/post_with_invalid_access_token.json +1 -0
  121. data/spec/fake_json/users/feed/post_with_valid_access_token.json +1 -0
  122. data/spec/fake_json/users/feed/post_without_access_token.json +1 -0
  123. data/spec/fake_json/users/friends/arjun_private.json +6 -0
  124. data/spec/fake_json/users/friends/arjun_public.json +6 -0
  125. data/spec/fake_json/users/friends/me_private.json +524 -0
  126. data/spec/fake_json/users/friends/me_public.json +6 -0
  127. data/spec/fake_json/users/groups/matake_private.json +48 -0
  128. data/spec/fake_json/users/groups/matake_public.json +6 -0
  129. data/spec/fake_json/users/home/arjun_private.json +6 -0
  130. data/spec/fake_json/users/home/arjun_public.json +6 -0
  131. data/spec/fake_json/users/home/me_private.json +460 -0
  132. data/spec/fake_json/users/home/me_private_next.json +382 -0
  133. data/spec/fake_json/users/home/me_private_previous.json +36 -0
  134. data/spec/fake_json/users/home/me_public.json +6 -0
  135. data/spec/fake_json/users/interests/matake_private.json +14 -0
  136. data/spec/fake_json/users/likes/arjun_private.json +1394 -0
  137. data/spec/fake_json/users/likes/arjun_public.json +6 -0
  138. data/spec/fake_json/users/links/matake_private.json +221 -0
  139. data/spec/fake_json/users/links/post_with_valid_access_token.json +1 -0
  140. data/spec/fake_json/users/me_private.json +128 -0
  141. data/spec/fake_json/users/me_public.json +6 -0
  142. data/spec/fake_json/users/movies/matake_private.json +9 -0
  143. data/spec/fake_json/users/music/matake_private.json +34 -0
  144. data/spec/fake_json/users/notes/matake_private.json +308 -0
  145. data/spec/fake_json/users/posts/arjun_private.json +386 -0
  146. data/spec/fake_json/users/posts/arjun_public.json +386 -0
  147. data/spec/fake_json/users/statuses/arjun_private.json +233 -0
  148. data/spec/fake_json/users/statuses/arjun_public.json +6 -0
  149. data/spec/fake_json/users/tagged/arjun_private.json +308 -0
  150. data/spec/fake_json/users/tagged/arjun_public.json +308 -0
  151. data/spec/fake_json/users/television/matake_private.json +9 -0
  152. data/spec/fake_json/users/videos/kirk_private.json +41 -0
  153. data/spec/fb_graph/album_spec.rb +61 -0
  154. data/spec/fb_graph/application_spec.rb +23 -0
  155. data/spec/fb_graph/auth_spec.rb +35 -0
  156. data/spec/fb_graph/checkin_spec.rb +29 -0
  157. data/spec/fb_graph/collection_spec.rb +45 -0
  158. data/spec/fb_graph/comment_spec.rb +31 -0
  159. data/spec/fb_graph/connection_spec.rb +38 -0
  160. data/spec/fb_graph/connections/accounts_spec.rb +47 -0
  161. data/spec/fb_graph/connections/activities_spec.rb +34 -0
  162. data/spec/fb_graph/connections/albums_spec.rb +60 -0
  163. data/spec/fb_graph/connections/attending_spec.rb +24 -0
  164. data/spec/fb_graph/connections/books_spec.rb +33 -0
  165. data/spec/fb_graph/connections/checkins_spec.rb +109 -0
  166. data/spec/fb_graph/connections/comments_spec.rb +85 -0
  167. data/spec/fb_graph/connections/declined_spec.rb +24 -0
  168. data/spec/fb_graph/connections/events_spec.rb +53 -0
  169. data/spec/fb_graph/connections/feed_spec.rb +102 -0
  170. data/spec/fb_graph/connections/friends_spec.rb +50 -0
  171. data/spec/fb_graph/connections/groups_spec.rb +32 -0
  172. data/spec/fb_graph/connections/home_spec.rb +58 -0
  173. data/spec/fb_graph/connections/interests_spec.rb +14 -0
  174. data/spec/fb_graph/connections/invited_spec.rb +14 -0
  175. data/spec/fb_graph/connections/likes_spec.rb +33 -0
  176. data/spec/fb_graph/connections/links_spec.rb +33 -0
  177. data/spec/fb_graph/connections/maybe_spec.rb +24 -0
  178. data/spec/fb_graph/connections/members_spec.rb +14 -0
  179. data/spec/fb_graph/connections/movies_spec.rb +14 -0
  180. data/spec/fb_graph/connections/music_spec.rb +14 -0
  181. data/spec/fb_graph/connections/noreply_spec.rb +14 -0
  182. data/spec/fb_graph/connections/notes_spec.rb +32 -0
  183. data/spec/fb_graph/connections/photos_spec.rb +30 -0
  184. data/spec/fb_graph/connections/picture_spec.rb +29 -0
  185. data/spec/fb_graph/connections/posts_spec.rb +35 -0
  186. data/spec/fb_graph/connections/statuses_spec.rb +74 -0
  187. data/spec/fb_graph/connections/subscriptions_spec.rb +18 -0
  188. data/spec/fb_graph/connections/tagged_spec.rb +42 -0
  189. data/spec/fb_graph/connections/television_spec.rb +14 -0
  190. data/spec/fb_graph/connections/videos_spec.rb +14 -0
  191. data/spec/fb_graph/education_spec.rb +61 -0
  192. data/spec/fb_graph/event_spec.rb +50 -0
  193. data/spec/fb_graph/group_spec.rb +46 -0
  194. data/spec/fb_graph/insight_spec.rb +17 -0
  195. data/spec/fb_graph/link_spec.rb +43 -0
  196. data/spec/fb_graph/node_spec.rb +13 -0
  197. data/spec/fb_graph/note_spec.rb +37 -0
  198. data/spec/fb_graph/page_spec.rb +56 -0
  199. data/spec/fb_graph/photo_spec.rb +60 -0
  200. data/spec/fb_graph/post_spec.rb +71 -0
  201. data/spec/fb_graph/status_spec.rb +31 -0
  202. data/spec/fb_graph/subscription_spec.rb +5 -0
  203. data/spec/fb_graph/tag_spec.rb +20 -0
  204. data/spec/fb_graph/user_spec.rb +139 -0
  205. data/spec/fb_graph/venue_spec.rb +23 -0
  206. data/spec/fb_graph/video_spec.rb +37 -0
  207. data/spec/fb_graph/work_spec.rb +67 -0
  208. data/spec/helpers/fake_json_helper.rb +11 -0
  209. data/spec/spec.opts +3 -0
  210. data/spec/spec_helper.rb +18 -0
  211. metadata +414 -0
@@ -0,0 +1,50 @@
1
+ require File.join(File.dirname(__FILE__), '../spec_helper')
2
+
3
+ describe FbGraph::Event, '.new' do
4
+
5
+ it 'should setup all supported attributes' do
6
+ attributes = {
7
+ :id => '12345',
8
+ :owner => {
9
+ :id => '23456',
10
+ :name => 'nov matake'
11
+ },
12
+ :name => 'event 1',
13
+ :description => 'an event for fb_graph test',
14
+ :start_time => '2010-03-14T21:00:00+0000',
15
+ :end_time => '2010-03-15T00:30:00+0000',
16
+ :location => 'Smart.fm office',
17
+ :venue => {
18
+ :street => 'Sakuragaoka',
19
+ :city => 'Shibuya',
20
+ :state => 'Tokyo',
21
+ :zip => '150-0031',
22
+ :country => 'Japan',
23
+ :latitude => '35.685',
24
+ :longitude => '139.751'
25
+ },
26
+ :privacy => 'OPEN',
27
+ :updated_time => '2010-01-02T15:37:41+0000'
28
+ }
29
+ event = FbGraph::Event.new(attributes.delete(:id), attributes)
30
+ event.identifier.should == '12345'
31
+ event.owner.should == FbGraph::User.new('23456', :name => 'nov matake')
32
+ event.name.should == 'event 1'
33
+ event.description.should == 'an event for fb_graph test'
34
+ event.start_time.should == Time.parse('2010-03-14T21:00:00+0000')
35
+ event.end_time.should == Time.parse('2010-03-15T00:30:00+0000')
36
+ event.location.should == 'Smart.fm office'
37
+ event.venue.should == FbGraph::Venue.new(
38
+ :street => 'Sakuragaoka',
39
+ :city => 'Shibuya',
40
+ :state => 'Tokyo',
41
+ :zip => '150-0031',
42
+ :country => 'Japan',
43
+ :latitude => '35.685',
44
+ :longitude => '139.751'
45
+ )
46
+ event.privacy.should == 'OPEN'
47
+ event.updated_time.should == Time.parse('2010-01-02T15:37:41+0000')
48
+ end
49
+
50
+ end
@@ -0,0 +1,46 @@
1
+ require File.join(File.dirname(__FILE__), '../spec_helper')
2
+
3
+ describe FbGraph::Group, '.new' do
4
+
5
+ it 'should setup all supported attributes' do
6
+ attributes = {
7
+ :id => '12345',
8
+ :owner => {
9
+ :id => '23456',
10
+ :name => 'nov matake'
11
+ },
12
+ :name => 'group 1',
13
+ :description => 'a group for fb_graph test',
14
+ :link => 'http://www.facebook.com/group/12345',
15
+ :venue => {
16
+ :street => 'Sakuragaoka',
17
+ :city => 'Shibuya',
18
+ :state => 'Tokyo',
19
+ :zip => '150-0031',
20
+ :country => 'Japan',
21
+ :latitude => '35.685',
22
+ :longitude => '139.751'
23
+ },
24
+ :privacy => 'OPEN',
25
+ :updated_time => '2010-01-02T15:37:41+0000'
26
+ }
27
+ group = FbGraph::Group.new(attributes.delete(:id), attributes)
28
+ group.identifier.should == '12345'
29
+ group.owner.should == FbGraph::User.new('23456', :name => 'nov matake')
30
+ group.name.should == 'group 1'
31
+ group.description.should == 'a group for fb_graph test'
32
+ group.link.should == 'http://www.facebook.com/group/12345'
33
+ group.venue.should == FbGraph::Venue.new(
34
+ :street => 'Sakuragaoka',
35
+ :city => 'Shibuya',
36
+ :state => 'Tokyo',
37
+ :zip => '150-0031',
38
+ :country => 'Japan',
39
+ :latitude => '35.685',
40
+ :longitude => '139.751'
41
+ )
42
+ group.privacy.should == 'OPEN'
43
+ group.updated_time.should == Time.parse('2010-01-02T15:37:41+0000')
44
+ end
45
+
46
+ end
@@ -0,0 +1,17 @@
1
+ require File.join(File.dirname(__FILE__), '../spec_helper')
2
+
3
+ describe FbGraph::Insight, '.new' do
4
+
5
+ it 'should setup all supported attributes' do
6
+ attributes = {
7
+ :name => 'name_for_the_stats',
8
+ :period => 'day',
9
+ :values => [{'key1' => 'value2'}, {'key2' => 'value2'}]
10
+ }
11
+ insight = FbGraph::Insight.new(attributes)
12
+ insight.period.should == 'day'
13
+ insight.values.should == [{'key1' => 'value2'}, {'key2' => 'value2'}]
14
+ insight.values.first[:key1].should == 'value2'
15
+ end
16
+
17
+ end
@@ -0,0 +1,43 @@
1
+ require File.join(File.dirname(__FILE__), '../spec_helper')
2
+
3
+ describe FbGraph::Link, '.new' do
4
+
5
+ it 'should setup all supported attributes' do
6
+ attributes = {
7
+ :id => '12345',
8
+ :from => {
9
+ :id => '23456',
10
+ :name => 'nov matake'
11
+ },
12
+ :link => 'http://www.facebook.com/link/12345',
13
+ :name => 'name',
14
+ :caption => 'caption',
15
+ :description => 'description',
16
+ :icon => 'http://static.ak.fbcdn.net/rsrc.php/zB010/hash/9yvl71tw.gif',
17
+ :picture => 'http://i.ytimg.com/vi/JA068qeB0oM/2.jpg',
18
+ :message => 'check this out!',
19
+ :created_time => '2010-01-02T15:37:41+0000'
20
+ }
21
+ link = FbGraph::Link.new(attributes.delete(:id), attributes)
22
+ link.identifier.should == '12345'
23
+ link.from.should == FbGraph::User.new('23456', :name => 'nov matake')
24
+ link.link.should == 'http://www.facebook.com/link/12345'
25
+ link.name.should == 'name'
26
+ link.caption.should == 'caption'
27
+ link.description.should == 'description'
28
+ link.icon.should == 'http://static.ak.fbcdn.net/rsrc.php/zB010/hash/9yvl71tw.gif'
29
+ link.picture.should == 'http://i.ytimg.com/vi/JA068qeB0oM/2.jpg'
30
+ link.message.should == 'check this out!'
31
+ link.created_time.should == Time.parse('2010-01-02T15:37:41+0000')
32
+ end
33
+
34
+ it 'should support page as from' do
35
+ page_link = FbGraph::Link.new('12345', :from => {
36
+ :id => '23456',
37
+ :name => 'Smart.fm',
38
+ :category => 'Web Site'
39
+ })
40
+ page_link.from.should == FbGraph::Page.new('23456', :name => 'Smart.fm', :category => 'Web Site')
41
+ end
42
+
43
+ end
@@ -0,0 +1,13 @@
1
+ require File.join(File.dirname(__FILE__), '../spec_helper')
2
+
3
+ describe FbGraph::Node, '.new' do
4
+
5
+ it 'should setup endpoint' do
6
+ FbGraph::Node.new('matake').endpoint.should == File.join(FbGraph::ROOT_URL, 'matake')
7
+ end
8
+
9
+ it 'should support access_token option' do
10
+ FbGraph::Node.new('matake', :access_token => 'access_token').access_token.should == 'access_token'
11
+ end
12
+
13
+ end
@@ -0,0 +1,37 @@
1
+ require File.join(File.dirname(__FILE__), '../spec_helper')
2
+
3
+ describe FbGraph::Note, '.new' do
4
+
5
+ it 'should setup all supported attributes' do
6
+ attributes = {
7
+ :id => '12345',
8
+ :from => {
9
+ :id => '23456',
10
+ :name => 'nov matake'
11
+ },
12
+ :subject => 'TODO',
13
+ :message => 'later or never',
14
+ :created_time => '2010-01-02T15:37:40+0000',
15
+ :updated_time => '2010-01-02T15:37:41+0000',
16
+ :icon => 'http://static.ak.fbcdn.net/rsrc.php/z7NSY/hash/ajh5dbgz.gif'
17
+ }
18
+ note = FbGraph::Note.new(attributes.delete(:id), attributes)
19
+ note.identifier.should == '12345'
20
+ note.from.should == FbGraph::User.new('23456', :name => 'nov matake')
21
+ note.subject.should == 'TODO'
22
+ note.message.should == 'later or never'
23
+ note.created_time.should == Time.parse('2010-01-02T15:37:40+0000')
24
+ note.updated_time.should == Time.parse('2010-01-02T15:37:41+0000')
25
+ note.icon.should == 'http://static.ak.fbcdn.net/rsrc.php/z7NSY/hash/ajh5dbgz.gif'
26
+ end
27
+
28
+ it 'should support page as from' do
29
+ page_note = FbGraph::Note.new('12345', :from => {
30
+ :id => '23456',
31
+ :name => 'Smart.fm',
32
+ :category => 'Web Site'
33
+ })
34
+ page_note.from.should == FbGraph::Page.new('23456', :name => 'Smart.fm', :category => 'Web Site')
35
+ end
36
+
37
+ end
@@ -0,0 +1,56 @@
1
+ require File.join(File.dirname(__FILE__), '../spec_helper')
2
+
3
+ describe FbGraph::Page, '.new' do
4
+ it 'should setup all supported attributes' do
5
+ attributes = {
6
+ :id => '19292868552',
7
+ :name => 'Facebook Platform',
8
+ :founded => 'May 2007',
9
+ :category => 'Technology',
10
+ :username => 'platform',
11
+ :mission => 'To make the web more open and social.',
12
+ :products => "Facebook Application Programming Interface (API)\nFacebook Query Language (FQL)\nFacebook Markup Language (FBML)\nFacebook JavaScript (FBJS)\nFacebook Connect\n",
13
+ :fan_count => 578246,
14
+ :company_overview => 'Facebook Platform enables anyone to build social applications on Facebook and the web.',
15
+ :link => 'http://www.facebook.com/platform',
16
+ :picture => 'http://profile.ak.fbcdn.net/profile-ak-snc1/object3/1566/8/s19292868552_1660.jpg'
17
+ }
18
+ page = FbGraph::Page.new(attributes.delete(:id), attributes)
19
+ page.identifier.should == '19292868552'
20
+ page.name.should == 'Facebook Platform'
21
+ page.founded.should == Date.new(2007, 5)
22
+ page.category.should == 'Technology'
23
+ page.username.should == 'platform'
24
+ page.mission.should == 'To make the web more open and social.'
25
+ page.products.should == [
26
+ 'Facebook Application Programming Interface (API)',
27
+ 'Facebook Query Language (FQL)',
28
+ 'Facebook Markup Language (FBML)',
29
+ 'Facebook JavaScript (FBJS)',
30
+ 'Facebook Connect'
31
+ ]
32
+ page.fan_count.should == 578246
33
+ page.company_overview.should == 'Facebook Platform enables anyone to build social applications on Facebook and the web.'
34
+ page.link.should == 'http://www.facebook.com/platform'
35
+ page.picture.should == 'https://graph.facebook.com/19292868552/picture' # use connection
36
+ end
37
+
38
+ it 'should allow invalid date as founded' do
39
+ page = FbGraph::Page.new(12345, :founded => "2004")
40
+ page.founded.should == Date.new(2004, 1, 1)
41
+ end
42
+ end
43
+
44
+ describe FbGraph::Page, '.fetch' do
45
+ before(:all) do
46
+ fake_json(:get, 'platform', 'pages/platform_public')
47
+ fake_json(:get, 'platform?access_token=access_token', 'pages/platform_private')
48
+ end
49
+
50
+ it 'should get page attributes' do
51
+ page = FbGraph::Page.fetch('platform')
52
+ page.identifier.should == '19292868552'
53
+ page.name.should == 'Facebook Platform'
54
+ page.category.should == 'Technology'
55
+ end
56
+ end
@@ -0,0 +1,60 @@
1
+ require File.join(File.dirname(__FILE__), '../spec_helper')
2
+
3
+ describe FbGraph::Photo, '.new' do
4
+
5
+ it 'should setup all supported attributes' do
6
+ attributes = {
7
+ :id => '12345',
8
+ :from => {
9
+ :id => '23456',
10
+ :name => 'nov matake'
11
+ },
12
+ :tags => {
13
+ :data => [{
14
+ :id => '12345',
15
+ :name => 'nov matake',
16
+ :x => 32.5,
17
+ :y => 27.7778,
18
+ :created_time => '2010-01-10T15:37:40+0000'
19
+ }]
20
+ },
21
+ :name => 'photo 1',
22
+ :picture => 'http://www.facebook.com/matake/picture/album_size',
23
+ :icon => 'http://static.ak.fbcdn.net/rsrc.php/z2E5Y/hash/8as8iqdm.gif',
24
+ :source => 'http://www.facebook.com/matake/picture/original_size',
25
+ :height => 100,
26
+ :width => 200,
27
+ :link => 'http://www.facebook.com/photo/12345',
28
+ :created_time => '2010-01-02T15:37:40+0000',
29
+ :updated_time => '2010-01-02T15:37:41+0000'
30
+ }
31
+ photo = FbGraph::Photo.new(attributes.delete(:id), attributes)
32
+ photo.identifier.should == '12345'
33
+ photo.from.should == FbGraph::User.new('23456', :name => 'nov matake')
34
+ photo.tags.should == [FbGraph::Tag.new(
35
+ '12345',
36
+ :name => 'nov matake',
37
+ :x => 32.5,
38
+ :y => 27.7778,
39
+ :created_time => '2010-01-10T15:37:40+0000'
40
+ )]
41
+ photo.picture.should == 'http://www.facebook.com/matake/picture/album_size'
42
+ photo.icon.should == 'http://static.ak.fbcdn.net/rsrc.php/z2E5Y/hash/8as8iqdm.gif'
43
+ photo.source.should == 'http://www.facebook.com/matake/picture/original_size'
44
+ photo.height.should == 100
45
+ photo.width.should == 200
46
+ photo.link.should == 'http://www.facebook.com/photo/12345'
47
+ photo.created_time.should == Time.parse('2010-01-02T15:37:40+0000')
48
+ photo.updated_time.should == Time.parse('2010-01-02T15:37:41+0000')
49
+ end
50
+
51
+ it 'should support page as from' do
52
+ page_photo = FbGraph::Photo.new('12345', :from => {
53
+ :id => '23456',
54
+ :name => 'Smart.fm',
55
+ :category => 'Web Site'
56
+ })
57
+ page_photo.from.should == FbGraph::Page.new('23456', :name => 'Smart.fm', :category => 'Web Site')
58
+ end
59
+
60
+ end
@@ -0,0 +1,71 @@
1
+ require File.join(File.dirname(__FILE__), '../spec_helper')
2
+
3
+ describe FbGraph::Post, '.new' do
4
+ it 'should setup all supported attributes' do
5
+ # TODO
6
+ end
7
+
8
+ it 'should support page as from' do
9
+ page_post = FbGraph::Post.new('12345', :from => {
10
+ :id => '23456',
11
+ :name => 'Smart.fm',
12
+ :category => 'Web Site'
13
+ }, :message => 'Hello')
14
+ page_post.from.should == FbGraph::Page.new('23456', :name => 'Smart.fm', :category => 'Web Site')
15
+ end
16
+
17
+ it 'should support page as to' do
18
+ page_post = FbGraph::Post.new('12345', :to => {:data => [
19
+ :id => '23456',
20
+ :name => 'Smart.fm',
21
+ :category => 'Web Site'
22
+ ]}, :message => 'Hello')
23
+ page_post.to.first.should == FbGraph::Page.new('23456', :name => 'Smart.fm', :category => 'Web Site')
24
+ end
25
+ end
26
+
27
+ describe FbGraph::Post, '#fetch' do
28
+
29
+ context 'when no access_token given' do
30
+ before(:all) do
31
+ fake_json(:get, 'platform', 'posts/platform_public')
32
+ end
33
+
34
+ it 'should get all attributes except some comments' do
35
+ post = FbGraph::Post.fetch('platform')
36
+ post.identifier.should == '19292868552_118464504835613'
37
+ post.from.should == FbGraph::Page.new(
38
+ "19292868552",
39
+ :name => "Facebook Platform",
40
+ :category => "Technology"
41
+ )
42
+ post.message.should == "We're getting ready for f8! Check out the latest on the f8 Page, including a video from the first event, when Platform launched :: http://bit.ly/ahHl7j"
43
+ post.likes.should == 61
44
+ post.created_time.should == Time.parse("2010-04-15T17:37:03+0000")
45
+ post.updated_time.should == Time.parse("2010-04-22T18:19:13+0000")
46
+ post.comments.size.should == 4
47
+ end
48
+ end
49
+
50
+ context 'when access_token given' do
51
+ before(:all) do
52
+ fake_json(:get, 'platform?access_token=access_token', 'posts/platform_private')
53
+ end
54
+
55
+ it 'shold get all attributes and comments' do
56
+ post = FbGraph::Post.fetch('platform', :access_token => 'access_token')
57
+ post.identifier.should == '19292868552_118464504835613'
58
+ post.from.should == FbGraph::Page.new(
59
+ "19292868552",
60
+ :name => "Facebook Platform",
61
+ :category => "Technology"
62
+ )
63
+ post.message.should == "We're getting ready for f8! Check out the latest on the f8 Page, including a video from the first event, when Platform launched :: http://bit.ly/ahHl7j"
64
+ post.likes.should == 61
65
+ post.created_time.should == Time.parse("2010-04-15T17:37:03+0000")
66
+ post.updated_time.should == Time.parse("2010-04-22T18:19:13+0000")
67
+ post.comments.size.should == 9
68
+ end
69
+ end
70
+
71
+ end
@@ -0,0 +1,31 @@
1
+ require File.join(File.dirname(__FILE__), '../spec_helper')
2
+
3
+ describe FbGraph::Status, '.new' do
4
+
5
+ it 'should setup all supported attributes' do
6
+ attributes = {
7
+ :id => '12345',
8
+ :from => {
9
+ :id => '23456',
10
+ :name => 'nov matake'
11
+ },
12
+ :message => 'hello, how are you?',
13
+ :updated_time => '2010-01-02T15:37:41+0000'
14
+ }
15
+ status = FbGraph::Status.new(attributes.delete(:id), attributes)
16
+ status.identifier.should == '12345'
17
+ status.from.should == FbGraph::User.new('23456', :name => 'nov matake')
18
+ status.message.should == 'hello, how are you?'
19
+ status.updated_time.should == Time.parse('2010-01-02T15:37:41+0000')
20
+ end
21
+
22
+ it 'should support page as from' do
23
+ page_status = FbGraph::Status.new('12345', :from => {
24
+ :id => '23456',
25
+ :name => 'Smart.fm',
26
+ :category => 'Web Site'
27
+ })
28
+ page_status.from.should == FbGraph::Page.new('23456', :name => 'Smart.fm', :category => 'Web Site')
29
+ end
30
+
31
+ end
@@ -0,0 +1,5 @@
1
+ require File.join(File.dirname(__FILE__), '../spec_helper')
2
+
3
+ describe FbGraph::Subscription, '.new' do
4
+ # TODO
5
+ end
@@ -0,0 +1,20 @@
1
+ require File.join(File.dirname(__FILE__), '../spec_helper')
2
+
3
+ describe FbGraph::Tag, '.new' do
4
+
5
+ it 'should setup all supported attributes' do
6
+ attributes = {
7
+ :id => "7901103",
8
+ :name => "Arjun Banker",
9
+ :x => 32.5,
10
+ :y => 27.7778,
11
+ :created_time => "2010-04-22T08:24:26+0000"
12
+ }
13
+ tag = FbGraph::Tag.new(attributes.delete(:id), attributes)
14
+ tag.user.should == FbGraph::User.new('7901103', :name => "Arjun Banker")
15
+ tag.x.should == 32.5
16
+ tag.y.should == 27.7778
17
+ tag.created_time.should == Time.parse("2010-04-22T08:24:26+0000")
18
+ end
19
+
20
+ end