fb_graph 0.0.7 → 0.0.8

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 (56) hide show
  1. data/README.rdoc +2 -1
  2. data/VERSION +1 -1
  3. data/assets/fb_graph.ai +1726 -6
  4. data/assets/fb_graph.png +0 -0
  5. data/fb_graph.gemspec +22 -2
  6. data/lib/fb_graph/album.rb +8 -4
  7. data/lib/fb_graph/collection.rb +4 -1
  8. data/lib/fb_graph/comment.rb +6 -4
  9. data/lib/fb_graph/connections/comments.rb +8 -1
  10. data/lib/fb_graph/education.rb +25 -0
  11. data/lib/fb_graph/event.rb +10 -4
  12. data/lib/fb_graph/group.rb +4 -2
  13. data/lib/fb_graph/link.rb +5 -3
  14. data/lib/fb_graph/note.rb +8 -4
  15. data/lib/fb_graph/photo.rb +9 -5
  16. data/lib/fb_graph/post.rb +24 -17
  17. data/lib/fb_graph/status.rb +5 -3
  18. data/lib/fb_graph/tag.rb +3 -1
  19. data/lib/fb_graph/user.rb +16 -4
  20. data/lib/fb_graph/video.rb +11 -7
  21. data/lib/fb_graph/work.rb +25 -0
  22. data/lib/fb_graph.rb +2 -0
  23. data/spec/fake_json/posts/platform_private.json +97 -0
  24. data/spec/fake_json/posts/platform_public.json +52 -0
  25. data/spec/fake_json/users/books/matake_private.json +9 -0
  26. data/spec/fake_json/users/books/matake_public.json +6 -0
  27. data/spec/fb_graph/album_spec.rb +2 -2
  28. data/spec/fb_graph/collection_spec.rb +7 -8
  29. data/spec/fb_graph/comment_spec.rb +31 -0
  30. data/spec/fb_graph/connections/activities_spec.rb +18 -14
  31. data/spec/fb_graph/connections/albums_spec.rb +25 -21
  32. data/spec/fb_graph/connections/books_spec.rb +32 -0
  33. data/spec/fb_graph/connections/events_spec.rb +20 -17
  34. data/spec/fb_graph/connections/feed_spec.rb +23 -22
  35. data/spec/fb_graph/connections/friends_spec.rb +29 -22
  36. data/spec/fb_graph/connections/groups_spec.rb +17 -14
  37. data/spec/fb_graph/connections/home_spec.rb +37 -30
  38. data/spec/fb_graph/connections/likes_spec.rb +18 -14
  39. data/spec/fb_graph/connections/picture_spec.rb +2 -2
  40. data/spec/fb_graph/connections/posts_spec.rb +23 -22
  41. data/spec/fb_graph/connections/statuses_spec.rb +45 -37
  42. data/spec/fb_graph/connections/tagged_spec.rb +30 -29
  43. data/spec/fb_graph/education_spec.rb +61 -0
  44. data/spec/fb_graph/event_spec.rb +3 -3
  45. data/spec/fb_graph/group_spec.rb +1 -1
  46. data/spec/fb_graph/link_spec.rb +1 -1
  47. data/spec/fb_graph/note_spec.rb +2 -2
  48. data/spec/fb_graph/photo_spec.rb +2 -2
  49. data/spec/fb_graph/post_spec.rb +63 -2
  50. data/spec/fb_graph/status_spec.rb +1 -1
  51. data/spec/fb_graph/tag_spec.rb +21 -0
  52. data/spec/fb_graph/user_spec.rb +64 -22
  53. data/spec/fb_graph/venue_spec.rb +23 -0
  54. data/spec/fb_graph/video_spec.rb +2 -2
  55. data/spec/fb_graph/work_spec.rb +52 -0
  56. metadata +23 -3
@@ -1,27 +1,31 @@
1
1
  require File.join(File.dirname(__FILE__), '../../spec_helper')
2
2
 
3
3
  describe FbGraph::Connections::Likes, '#likes' do
4
- describe 'when included by FbGraph::User' do
4
+ context 'when included by FbGraph::User' do
5
5
  before(:all) do
6
6
  fake_json(:get, 'arjun/likes', 'users/likes/arjun_public')
7
7
  fake_json(:get, 'arjun/likes?access_token=access_token', 'users/likes/arjun_private')
8
8
  end
9
9
 
10
- it 'should raise FbGraph::Unauthorized when no access_token given' do
11
- lambda do
12
- FbGraph::User.new('arjun').likes
13
- end.should raise_exception(FbGraph::Unauthorized)
10
+ context 'when no access_token given' do
11
+ it 'should raise FbGraph::Unauthorized' do
12
+ lambda do
13
+ FbGraph::User.new('arjun').likes
14
+ end.should raise_exception(FbGraph::Unauthorized)
15
+ end
14
16
  end
15
17
 
16
- it 'should return liked pages' do
17
- likes = FbGraph::User.new('arjun', :access_token => 'access_token').likes
18
- likes.first.should == FbGraph::Page.new(
19
- '378209722137',
20
- :name => 'Doing Things at the Last Minute',
21
- :category => '活動'
22
- )
23
- likes.each do |like|
24
- like.should be_instance_of(FbGraph::Page)
18
+ context 'when access_token is given' do
19
+ it 'should return liked pages as FbGraph::Page' do
20
+ likes = FbGraph::User.new('arjun', :access_token => 'access_token').likes
21
+ likes.first.should == FbGraph::Page.new(
22
+ '378209722137',
23
+ :name => 'Doing Things at the Last Minute',
24
+ :category => '活動'
25
+ )
26
+ likes.each do |like|
27
+ like.should be_instance_of(FbGraph::Page)
28
+ end
25
29
  end
26
30
  end
27
31
  end
@@ -2,7 +2,7 @@ require File.join(File.dirname(__FILE__), '../../spec_helper')
2
2
 
3
3
  describe FbGraph::Connections::Picture, '#picture' do
4
4
 
5
- describe 'when included by FbGraph::User' do
5
+ context 'when included by FbGraph::User' do
6
6
  it 'should return image url' do
7
7
  FbGraph::User.new('matake').picture.should == File.join(FbGraph::ROOT_URL, 'matake/picture')
8
8
  end
@@ -14,7 +14,7 @@ describe FbGraph::Connections::Picture, '#picture' do
14
14
  end
15
15
  end
16
16
 
17
- describe 'when included by FbGraph::Page' do
17
+ context 'when included by FbGraph::Page' do
18
18
  it 'should return image url' do
19
19
  FbGraph::Page.new('platform').picture.should == File.join(FbGraph::ROOT_URL, 'platform/picture')
20
20
  end
@@ -1,34 +1,35 @@
1
1
  require File.join(File.dirname(__FILE__), '../../spec_helper')
2
2
 
3
3
  describe FbGraph::Connections::Posts, '#posts' do
4
- describe 'when included by FbGraph::User' do
4
+ context 'when included by FbGraph::User' do
5
5
  before(:all) do
6
6
  fake_json(:get, 'arjun/posts', 'users/posts/arjun_public')
7
7
  fake_json(:get, 'arjun/posts?access_token=access_token', 'users/posts/arjun_private')
8
8
  end
9
9
 
10
- it 'should return public own posts even when access_token is not given' do
11
- posts = FbGraph::User.new('arjun').posts
12
- posts.first.should == FbGraph::Post.new(
13
- '7901103_121392141207495',
14
- :from => {
15
- :id => '7901103',
16
- :name => 'Arjun Banker'
17
- },
18
- :picture => 'http://external.ak.fbcdn.net/safe_image.php?d=d2cc5beedaa401ba54eccc9014647285&w=130&h=130&url=http%3A%2F%2Fimages.ted.com%2Fimages%2Fted%2F269_389x292.jpg',
19
- :link => 'http://www.ted.com/talks/wade_davis_on_endangered_cultures.html',
20
- :name => 'Wade Davis on endangered cultures | Video on TED.com',
21
- :caption => 'www.ted.com',
22
- :description => 'TED Talks With stunning photos and stories, National Geographic Explorer Wade Davis celebrates the extraordinary diversity of the world\'s indigenous cultures, which are disappearing from the planet at an alarming rate.',
23
- :icon => 'http://static.ak.fbcdn.net/rsrc.php/z9XZ8/hash/976ulj6z.gif',
24
- :created_time => '2010-04-25T04:05:32+0000',
25
- :updated_time => '2010-04-25T04:05:32+0000',
26
- :likes => 1
27
- )
28
- posts.each do |post|
29
- post.should be_instance_of(FbGraph::Post)
10
+ context 'when no access_token given' do
11
+ it 'should return public posts the user created as FbGraph::Post' do
12
+ posts = FbGraph::User.new('arjun').posts
13
+ posts.first.should == FbGraph::Post.new(
14
+ '7901103_121392141207495',
15
+ :from => {
16
+ :id => '7901103',
17
+ :name => 'Arjun Banker'
18
+ },
19
+ :picture => 'http://external.ak.fbcdn.net/safe_image.php?d=d2cc5beedaa401ba54eccc9014647285&w=130&h=130&url=http%3A%2F%2Fimages.ted.com%2Fimages%2Fted%2F269_389x292.jpg',
20
+ :link => 'http://www.ted.com/talks/wade_davis_on_endangered_cultures.html',
21
+ :name => 'Wade Davis on endangered cultures | Video on TED.com',
22
+ :caption => 'www.ted.com',
23
+ :description => 'TED Talks With stunning photos and stories, National Geographic Explorer Wade Davis celebrates the extraordinary diversity of the world\'s indigenous cultures, which are disappearing from the planet at an alarming rate.',
24
+ :icon => 'http://static.ak.fbcdn.net/rsrc.php/z9XZ8/hash/976ulj6z.gif',
25
+ :created_time => '2010-04-25T04:05:32+0000',
26
+ :updated_time => '2010-04-25T04:05:32+0000',
27
+ :likes => 1
28
+ )
29
+ posts.each do |post|
30
+ post.should be_instance_of(FbGraph::Post)
31
+ end
30
32
  end
31
33
  end
32
-
33
34
  end
34
35
  end
@@ -2,61 +2,69 @@ require File.join(File.dirname(__FILE__), '../../spec_helper')
2
2
 
3
3
  describe FbGraph::Connections::Statuses, '#statuses' do
4
4
 
5
- describe 'when included by FbGraph::User' do
5
+ context 'when included by FbGraph::User' do
6
6
  before(:all) do
7
7
  fake_json(:get, 'arjun/statuses', 'users/statuses/arjun_public')
8
8
  fake_json(:get, 'arjun/statuses?access_token=access_token', 'users/statuses/arjun_private')
9
9
  end
10
10
 
11
- it 'should raise FbGraph::Unauthorized when no access_token given' do
12
- lambda do
13
- FbGraph::User.new('arjun').statuses
14
- end.should raise_exception(FbGraph::Unauthorized)
11
+ context 'when no access_token given' do
12
+ it 'should raise FbGraph::Unauthorized' do
13
+ lambda do
14
+ FbGraph::User.new('arjun').statuses
15
+ end.should raise_exception(FbGraph::Unauthorized)
16
+ end
15
17
  end
16
18
 
17
- it 'should return statuses' do
18
- statuses = FbGraph::User.new('arjun', :access_token => 'access_token').statuses
19
- statuses.first.should == FbGraph::Status.new(
20
- '113559395341627',
21
- :from => {
22
- :id => '7901103',
23
- :name => 'Arjun Banker'
24
- },
25
- :message => 'http://www.facebook.com/photo.php?pid=60538827&l=79b44ffb74&id=7901103',
26
- :updated_time => '2010-04-21T21:10:16+0000'
27
- )
28
- statuses.each do |like|
29
- like.should be_instance_of(FbGraph::Status)
19
+ context 'when access_token is given' do
20
+ it 'should return statuses as FbGraph::Status' do
21
+ statuses = FbGraph::User.new('arjun', :access_token => 'access_token').statuses
22
+ statuses.first.should == FbGraph::Status.new(
23
+ '113559395341627',
24
+ :from => {
25
+ :id => '7901103',
26
+ :name => 'Arjun Banker'
27
+ },
28
+ :message => 'http://www.facebook.com/photo.php?pid=60538827&l=79b44ffb74&id=7901103',
29
+ :updated_time => '2010-04-21T21:10:16+0000'
30
+ )
31
+ statuses.each do |status|
32
+ status.should be_instance_of(FbGraph::Status)
33
+ end
30
34
  end
31
35
  end
32
36
  end
33
37
 
34
- describe 'when included by FbGraph::Page' do
38
+ context 'when included by FbGraph::Page' do
35
39
  before(:all) do
36
40
  fake_json(:get, 'platform/statuses', 'pages/statuses/platform_public')
37
41
  fake_json(:get, 'platform/statuses?access_token=access_token', 'pages/statuses/platform_private')
38
42
  end
39
43
 
40
- it 'should raise FbGraph::Unauthorized when no access_token given' do
41
- lambda do
42
- FbGraph::Page.new('platform').statuses
43
- end.should raise_exception(FbGraph::Unauthorized)
44
+ context 'when no access_token given' do
45
+ it 'should raise FbGraph::Unauthorized' do
46
+ lambda do
47
+ FbGraph::Page.new('platform').statuses
48
+ end.should raise_exception(FbGraph::Unauthorized)
49
+ end
44
50
  end
45
51
 
46
- it 'should return statuses with pagination info' do
47
- statuses = FbGraph::Page.new('platform', :access_token => 'access_token').statuses
48
- statuses.first.should == FbGraph::Status.new(
49
- '111081598927600',
50
- :from => {
51
- :id => '19292868552',
52
- :name => 'Facebook Platform',
53
- :category => 'Technology'
54
- },
55
- :message => 'Here\'s more information on the new social plugins announced at f8 today - http://bit.ly/db8ahS',
56
- :updated_time => '2010-04-21T20:17:04+0000'
57
- )
58
- statuses.each do |like|
59
- like.should be_instance_of(FbGraph::Status)
52
+ context 'when access_token is given' do
53
+ it 'should return statuses as FbGraph::Status' do
54
+ statuses = FbGraph::Page.new('platform', :access_token => 'access_token').statuses
55
+ statuses.first.should == FbGraph::Status.new(
56
+ '111081598927600',
57
+ :from => {
58
+ :id => '19292868552',
59
+ :name => 'Facebook Platform',
60
+ :category => 'Technology'
61
+ },
62
+ :message => 'Here\'s more information on the new social plugins announced at f8 today - http://bit.ly/db8ahS',
63
+ :updated_time => '2010-04-21T20:17:04+0000'
64
+ )
65
+ statuses.each do |status|
66
+ status.should be_instance_of(FbGraph::Status)
67
+ end
60
68
  end
61
69
  end
62
70
  end
@@ -1,41 +1,42 @@
1
1
  require File.join(File.dirname(__FILE__), '../../spec_helper')
2
2
 
3
3
  describe FbGraph::Connections::Tagged, '#tagged' do
4
- describe 'when included by FbGraph::User' do
4
+ context 'when included by FbGraph::User' do
5
5
  before(:all) do
6
6
  fake_json(:get, 'arjun/tagged', 'users/tagged/arjun_public')
7
7
  fake_json(:get, 'arjun/tagged?access_token=access_token', 'users/tagged/arjun_private')
8
8
  end
9
9
 
10
- it 'should return public own posts even when access_token is not given' do
11
- posts = FbGraph::User.new('arjun').tagged
12
- posts.first.should == FbGraph::Post.new(
13
- '7901103_117809521578252',
14
- :from => {
15
- :id => '1404401889',
16
- :name => 'Elli Mooney'
17
- },
18
- :to => {
19
- :data => [{
20
- :id => '7901103',
21
- :name => 'Arjun Banker'
22
- }]
23
- },
24
- :message => '...uh oh, here comes a privacy issue....',
25
- :picture => 'http://external.ak.fbcdn.net/safe_image.php?d=c659c86d415c60c37b2871bfd67f2a97&w=130&h=130&url=http%3A%2F%2Fcdn.venturebeat.com%2Fwp-content%2Fuploads%2F2010%2F04%2Fusethisone.jpg',
26
- :link => 'http://venturebeat.com/2010/04/23/blippy-credit-card-citibank/',
27
- :name => 'Blippy users’ credit card numbers found on Google | VentureBeat',
28
- :caption => 'venturebeat.com',
29
- :description => '[Update: Blippy cofounder Philip Kaplan emailed a response. CNET News is reporting that the cards in question were issued by ...',
30
- :icon => 'http://static.ak.fbcdn.net/rsrc.php/zB010/hash/9yvl71tw.gif',
31
- :created_time => '2010-04-24T08:07:59+0000',
32
- :updated_time => '2010-04-24T08:07:59+0000',
33
- :likes => 1
34
- )
35
- posts.each do |post|
36
- post.should be_instance_of(FbGraph::Post)
10
+ context 'when no access_token given' do
11
+ it 'should return posts the user has been tagged as FbGraph::Post' do
12
+ posts = FbGraph::User.new('arjun').tagged
13
+ posts.first.should == FbGraph::Post.new(
14
+ '7901103_117809521578252',
15
+ :from => {
16
+ :id => '1404401889',
17
+ :name => 'Elli Mooney'
18
+ },
19
+ :to => {
20
+ :data => [{
21
+ :id => '7901103',
22
+ :name => 'Arjun Banker'
23
+ }]
24
+ },
25
+ :message => '...uh oh, here comes a privacy issue....',
26
+ :picture => 'http://external.ak.fbcdn.net/safe_image.php?d=c659c86d415c60c37b2871bfd67f2a97&w=130&h=130&url=http%3A%2F%2Fcdn.venturebeat.com%2Fwp-content%2Fuploads%2F2010%2F04%2Fusethisone.jpg',
27
+ :link => 'http://venturebeat.com/2010/04/23/blippy-credit-card-citibank/',
28
+ :name => 'Blippy users’ credit card numbers found on Google | VentureBeat',
29
+ :caption => 'venturebeat.com',
30
+ :description => '[Update: Blippy cofounder Philip Kaplan emailed a response. CNET News is reporting that the cards in question were issued by ...',
31
+ :icon => 'http://static.ak.fbcdn.net/rsrc.php/zB010/hash/9yvl71tw.gif',
32
+ :created_time => '2010-04-24T08:07:59+0000',
33
+ :updated_time => '2010-04-24T08:07:59+0000',
34
+ :likes => 1
35
+ )
36
+ posts.each do |post|
37
+ post.should be_instance_of(FbGraph::Post)
38
+ end
37
39
  end
38
40
  end
39
-
40
41
  end
41
42
  end
@@ -0,0 +1,61 @@
1
+ require File.join(File.dirname(__FILE__), '../spec_helper')
2
+
3
+ describe FbGraph::Education, '#new' do
4
+
5
+ it 'should setup all supported attributes' do
6
+ attributes = {
7
+ :school => {
8
+ :id => 110149592341159,
9
+ :name => "\u540c\u5fd7\u793e\u5927\u5b66"
10
+ },
11
+ :degree => {
12
+ :id => 110616875633830,
13
+ :name => "Master of Engineering"
14
+ },
15
+ :year => {
16
+ :id => 104926492884272,
17
+ :name => "2007"
18
+ },
19
+ :concentration => [
20
+ {
21
+ :id => 112303688789448,
22
+ :name => "Engineering"
23
+ },
24
+ {
25
+ :id => 102358546472290,
26
+ :name => "Intelligent Information"
27
+ },
28
+ {
29
+ :id => 108311762535367,
30
+ :name => "Intelligent Systems Design Laboratory"
31
+ }
32
+ ] }
33
+ education = FbGraph::Education.new(attributes)
34
+ education.school.should == FbGraph::Page.new(
35
+ 110149592341159,
36
+ :name => "\u540c\u5fd7\u793e\u5927\u5b66"
37
+ )
38
+ education.degree.should == FbGraph::Page.new(
39
+ 110616875633830,
40
+ :name => "Master of Engineering"
41
+ )
42
+ education.year.should == FbGraph::Page.new(
43
+ 104926492884272,
44
+ :name => "2007"
45
+ )
46
+ education.concentration.should == [
47
+ FbGraph::Page.new(
48
+ 112303688789448,
49
+ :name => "Engineering"
50
+ ),
51
+ FbGraph::Page.new(
52
+ 102358546472290,
53
+ :name => "Intelligent Information"
54
+ ),
55
+ FbGraph::Page.new(
56
+ 108311762535367,
57
+ :name => "Intelligent Systems Design Laboratory"
58
+ )
59
+ ]
60
+ end
61
+ end
@@ -31,8 +31,8 @@ describe FbGraph::Event, '#new' do
31
31
  event.owner.should == FbGraph::User.new('23456', :name => 'nov matake')
32
32
  event.name.should == 'event 1'
33
33
  event.description.should == 'an event for fb_graph test'
34
- event.start_time.should == '2010-03-14T21:00:00+0000'
35
- event.end_time.should == '2010-03-15T00:30:00+0000'
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
36
  event.location.should == 'Smart.fm office'
37
37
  event.venue.should == FbGraph::Venue.new(
38
38
  :street => 'Sakuragaoka',
@@ -44,7 +44,7 @@ describe FbGraph::Event, '#new' do
44
44
  :longitude => '139.751'
45
45
  )
46
46
  event.privacy.should == 'OPEN'
47
- event.updated_time.should == '2010-01-02T15:37:41+0000'
47
+ event.updated_time.should == Time.parse('2010-01-02T15:37:41+0000')
48
48
  end
49
49
 
50
50
  end
@@ -40,7 +40,7 @@ describe FbGraph::Group, '#new' do
40
40
  :longitude => '139.751'
41
41
  )
42
42
  group.privacy.should == 'OPEN'
43
- group.updated_time.should == '2010-01-02T15:37:41+0000'
43
+ group.updated_time.should == Time.parse('2010-01-02T15:37:41+0000')
44
44
  end
45
45
 
46
46
  end
@@ -18,7 +18,7 @@ describe FbGraph::Link, '#new' do
18
18
  link.from.should == FbGraph::User.new('23456', :name => 'nov matake')
19
19
  link.link.should == 'http://www.facebook.com/link/12345'
20
20
  link.message.should == 'check this out!'
21
- link.updated_time.should == '2010-01-02T15:37:41+0000'
21
+ link.updated_time.should == Time.parse('2010-01-02T15:37:41+0000')
22
22
  end
23
23
 
24
24
  it 'should support page as from' do
@@ -19,8 +19,8 @@ describe FbGraph::Note, '#new' do
19
19
  note.from.should == FbGraph::User.new('23456', :name => 'nov matake')
20
20
  note.subject.should == 'TODO'
21
21
  note.message.should == 'later or never'
22
- note.created_time.should == '2010-01-02T15:37:40+0000'
23
- note.updated_time.should == '2010-01-02T15:37:41+0000'
22
+ note.created_time.should == Time.parse('2010-01-02T15:37:40+0000')
23
+ note.updated_time.should == Time.parse('2010-01-02T15:37:41+0000')
24
24
  end
25
25
 
26
26
  it 'should support page as from' do
@@ -42,8 +42,8 @@ describe FbGraph::Photo, '#new' do
42
42
  photo.height.should == 100
43
43
  photo.width.should == 200
44
44
  photo.link.should == 'http://www.facebook.com/photo/12345'
45
- photo.created_time.should == '2010-01-02T15:37:40+0000'
46
- photo.updated_time.should == '2010-01-02T15:37:41+0000'
45
+ photo.created_time.should == Time.parse('2010-01-02T15:37:40+0000')
46
+ photo.updated_time.should == Time.parse('2010-01-02T15:37:41+0000')
47
47
  end
48
48
 
49
49
  it 'should support page as from' do
@@ -1,6 +1,67 @@
1
1
  require File.join(File.dirname(__FILE__), '../spec_helper')
2
2
 
3
3
  describe FbGraph::Post, '#new' do
4
- # TODO
5
- # get actual json data first
4
+ it 'should support page as from' do
5
+ page_post = FbGraph::Post.new('12345', :from => {
6
+ :id => '23456',
7
+ :name => 'Smart.fm',
8
+ :category => 'Web Site'
9
+ }, :message => 'Hello')
10
+ page_post.from.should == FbGraph::Page.new('23456', :name => 'Smart.fm', :category => 'Web Site')
11
+ end
12
+
13
+ it 'should support page as to' do
14
+ page_post = FbGraph::Post.new('12345', :to => {:data => [
15
+ :id => '23456',
16
+ :name => 'Smart.fm',
17
+ :category => 'Web Site'
18
+ ]}, :message => 'Hello')
19
+ page_post.to.first.should == FbGraph::Page.new('23456', :name => 'Smart.fm', :category => 'Web Site')
20
+ end
21
+ end
22
+
23
+ describe FbGraph::Post, '#fetch' do
24
+
25
+ context 'when no access_token given' do
26
+ before(:all) do
27
+ fake_json(:get, 'platform', 'posts/platform_public')
28
+ end
29
+
30
+ it 'should get all attributes except some comments' do
31
+ post = FbGraph::Post.fetch('platform')
32
+ post.identifier.should == '19292868552_118464504835613'
33
+ post.from.should == FbGraph::Page.new(
34
+ "19292868552",
35
+ :name => "Facebook Platform",
36
+ :category => "Technology"
37
+ )
38
+ 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"
39
+ post.likes.should == 61
40
+ post.created_time.should == Time.parse("2010-04-15T17:37:03+0000")
41
+ post.updated_time.should == Time.parse("2010-04-22T18:19:13+0000")
42
+ post.comments.size.should == 4
43
+ end
44
+ end
45
+
46
+ context 'when access_token given' do
47
+ before(:all) do
48
+ fake_json(:get, 'platform?access_token=access_token', 'posts/platform_private')
49
+ end
50
+
51
+ it 'shold get all attributes and comments' do
52
+ post = FbGraph::Post.fetch('platform', :access_token => 'access_token')
53
+ post.identifier.should == '19292868552_118464504835613'
54
+ post.from.should == FbGraph::Page.new(
55
+ "19292868552",
56
+ :name => "Facebook Platform",
57
+ :category => "Technology"
58
+ )
59
+ 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"
60
+ post.likes.should == 61
61
+ post.created_time.should == Time.parse("2010-04-15T17:37:03+0000")
62
+ post.updated_time.should == Time.parse("2010-04-22T18:19:13+0000")
63
+ post.comments.size.should == 9
64
+ end
65
+ end
66
+
6
67
  end
@@ -16,7 +16,7 @@ describe FbGraph::Status, '#new' do
16
16
  status.identifier.should == '12345'
17
17
  status.from.should == FbGraph::User.new('23456', :name => 'nov matake')
18
18
  status.message.should == 'hello, how are you?'
19
- status.updated_time.should == '2010-01-02T15:37:41+0000'
19
+ status.updated_time.should == Time.parse('2010-01-02T15:37:41+0000')
20
20
  end
21
21
 
22
22
  it 'should support page as from' do
@@ -0,0 +1,21 @@
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
+
19
+ end
20
+
21
+ end
@@ -12,30 +12,72 @@ describe FbGraph::User, '.fetch' do
12
12
  fake_json(:get, 'arjun?access_token=access_token', 'users/arjun_private')
13
13
  end
14
14
 
15
- it 'should get only public profile when no access_token given' do
16
- user = FbGraph::User.fetch('arjun')
17
- user.name.should == 'Arjun Banker'
18
- user.first_name.should == 'Arjun'
19
- user.last_name.should == 'Banker'
20
- user.identifier.should == '7901103'
21
- user.link.should == 'http://www.facebook.com/Arjun'
15
+ context 'when no access_token given' do
16
+ it 'should get only public profile' do
17
+ user = FbGraph::User.fetch('arjun')
18
+ user.name.should == 'Arjun Banker'
19
+ user.first_name.should == 'Arjun'
20
+ user.last_name.should == 'Banker'
21
+ user.identifier.should == '7901103'
22
+ user.link.should == 'http://www.facebook.com/Arjun'
23
+ end
22
24
  end
23
25
 
24
- it 'should get public + private profile when access_token given' do
25
- user = FbGraph::User.fetch('arjun', :access_token => 'access_token')
26
- # public
27
- user.name.should == 'Arjun Banker'
28
- user.first_name.should == 'Arjun'
29
- user.last_name.should == 'Banker'
30
- user.identifier.should == '7901103'
31
- user.link.should == 'http://www.facebook.com/Arjun'
26
+ context 'when access_token given' do
27
+ it 'should get public + private profile' do
28
+ user = FbGraph::User.fetch('arjun', :access_token => 'access_token')
32
29
 
33
- # private
34
- user.about.should == "squish squash\npip pop\nfizz bang"
35
- user.birthday.should == '04/15/1984'
36
- user.work.should == [{'position'=>{'name'=>'Software Engineer', 'id'=>107879555911138}, 'start_date'=>'2007-11', 'location'=>{'name'=>'Palo Alto, California', 'id'=>104022926303756}, 'employer'=>{'name'=>'Facebook', 'id'=>20531316728}}, {'position'=>{'name'=>'Business Intelligence Analyst', 'id'=>105918922782444}, 'start_date'=>'2006-03', 'employer'=>{'name'=>'Zillow', 'id'=>113816405300191}, 'end_date'=>'2007-10'}, {'position'=>{'name'=>'SDET', 'id'=>110006949022640}, 'start_date'=>'2004-08', 'employer'=>{'name'=>'Microsoft', 'id'=>20528438720}, 'end_date'=>'2006-03'}, {'position'=>{'name'=>'Programmer Analyst', 'id'=>110344568993267}, 'start_date'=>'2003-06', 'employer'=>{'name'=>'Dell', 'id'=>7706457055}, 'end_date'=>'2004-07'}]
37
- user.education.should == [{'school'=>{'name'=>'Texas Academy Of Math And Science', 'id'=>107922345906866}, 'year'=>{'name'=>'2001', 'id'=>102241906483610}}, {'school'=>{'name'=>'The University of Texas at Austin', 'id'=>24147741537}, 'concentration'=>[{'name'=>'Computer Science', 'id'=>116831821660155}], 'year'=>{'name'=>'2003', 'id'=>108077232558120}}]
38
- user.email.should == nil
39
- user.website.should == nil
30
+ # public
31
+ user.name.should == 'Arjun Banker'
32
+ user.first_name.should == 'Arjun'
33
+ user.last_name.should == 'Banker'
34
+ user.identifier.should == '7901103'
35
+ user.link.should == 'http://www.facebook.com/Arjun'
36
+
37
+ # private
38
+ user.about.should == "squish squash\npip pop\nfizz bang"
39
+ user.birthday.should == Date.parse('04/15/1984')
40
+ user.work.should == [
41
+ FbGraph::Work.new({
42
+ :employer => {:name => 'Facebook', :id => 20531316728},
43
+ :position => {:name => 'Software Engineer', :id => 107879555911138},
44
+ :location => {:name => 'Palo Alto, California', :id => 104022926303756},
45
+ :start_date => '2007-11'
46
+ }),
47
+ FbGraph::Work.new({
48
+ :employer => {:name => 'Zillow', :id => 113816405300191},
49
+ :position => {:name => 'Business Intelligence Analyst', :id => 105918922782444},
50
+ :start_date => '2006-03',
51
+ :end_date => '2007-10'
52
+ }),
53
+ FbGraph::Work.new({
54
+ :employer => {:name => 'Microsoft', :id => 20528438720},
55
+ :position => {:name => 'SDET', :id => 110006949022640},
56
+ :start_date => '2004-08',
57
+ :end_date => '2006-03'
58
+ }),
59
+ FbGraph::Work.new({
60
+ :employer => {:name => 'Dell', :id => 7706457055},
61
+ :position => {:name => 'Programmer Analyst', :id => 110344568993267},
62
+ :start_date => '2003-06',
63
+ :end_date => '2004-07'
64
+ })
65
+ ]
66
+ user.education.should == [
67
+ FbGraph::Education.new({
68
+ :school => {:name => 'Texas Academy Of Math And Science', :id => 107922345906866},
69
+ :year => {:name => '2001', :id => 102241906483610}
70
+ }),
71
+ FbGraph::Education.new({
72
+ :school => {:name => 'The University of Texas at Austin', :id => 24147741537},
73
+ :year => {:name => '2003', :id => 108077232558120},
74
+ :concentration => [
75
+ {:name => 'Computer Science', :id => 116831821660155}
76
+ ]
77
+ })
78
+ ]
79
+ user.email.should == nil
80
+ user.website.should == []
81
+ end
40
82
  end
41
83
  end