fb_graph 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -0,0 +1,52 @@
1
+ {
2
+ "id": "19292868552_118464504835613",
3
+ "from": {
4
+ "name": "Facebook Platform",
5
+ "category": "Technology",
6
+ "id": "19292868552"
7
+ },
8
+ "message": "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",
9
+ "created_time": "2010-04-15T17:37:03+0000",
10
+ "updated_time": "2010-04-22T18:19:13+0000",
11
+ "likes": 61,
12
+ "comments": {
13
+ "data": [
14
+ {
15
+ "id": "19292868552_118464504835613_390050",
16
+ "from": {
17
+ "name": "Goran Kaplovic",
18
+ "id": "1849687320"
19
+ },
20
+ "message": "Platform Fans.. would you like to launch your own facebook integrated FMyLife.com 4 free? check this out: http://facebook.com/Anekdotz",
21
+ "created_time": "2010-04-15T20:29:35+0000"
22
+ },
23
+ {
24
+ "id": "19292868552_118464504835613_390487",
25
+ "from": {
26
+ "name": "Manuela Morales",
27
+ "id": "1259255079"
28
+ },
29
+ "message": "become a fan plz http://www.facebook.com/?sk=messages&tid=1426513385890#!/pages/Juanita-Rojas-Gabriela-Bernal/105811462793768?ref=nf <---please become a fannn \u2665",
30
+ "created_time": "2010-04-15T21:23:27+0000"
31
+ },
32
+ {
33
+ "id": "19292868552_118464504835613_429610",
34
+ "from": {
35
+ "name": "Mubashir Tanvir Zaver \u0645\u0628\u0634\u0631\u062a\u0646\u0648\u06cc\u0631\u0632\u06cc\u0648\u0631",
36
+ "id": "1181826641"
37
+ },
38
+ "message": ".\nThe \"AMAZING\" Page:\n\nhttp://www.facebook.com/profile.php?id=1181826641&ref=profile#!/pages/AMAZING/10150157765120055?ref=ts",
39
+ "created_time": "2010-04-20T14:48:57+0000"
40
+ },
41
+ {
42
+ "id": "19292868552_118464504835613_449320",
43
+ "from": {
44
+ "name": "Steve Boyer",
45
+ "id": "17814467"
46
+ },
47
+ "message": "These changes are amazing. Watch out world! FB is coming!",
48
+ "created_time": "2010-04-22T18:19:13+0000"
49
+ }
50
+ ]
51
+ }
52
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "data": [
3
+ {
4
+ "name": "Momo Michael Ende",
5
+ "category": "Unknown",
6
+ "id": "102253616477130"
7
+ }
8
+ ]
9
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "error": {
3
+ "type": "OAuthAccessTokenException",
4
+ "message": "An access token is required to request this resource."
5
+ }
6
+ }
@@ -25,8 +25,8 @@ describe FbGraph::Album, '#new' do
25
25
  album.location.should == 'Tokyo, Japan'
26
26
  album.link.should == 'http://www.facebook.com/album/12345'
27
27
  album.count.should == 10
28
- album.created_time.should == '2009-12-29T15:24:50+0000'
29
- album.updated_time.should == '2010-01-02T15:37:41+0000'
28
+ album.created_time.should == Time.parse('2009-12-29T15:24:50+0000')
29
+ album.updated_time.should == Time.parse('2010-01-02T15:37:41+0000')
30
30
  end
31
31
 
32
32
  it 'should support page as from' do
@@ -20,18 +20,17 @@ describe FbGraph::Collection do
20
20
  fake_json(:get, 'me/home?limit=25&access_token=access_token&until=2010-04-27T11%3A07%3A48%2B0000', 'users/home/me_private_next')
21
21
  end
22
22
 
23
- it 'should ' do
23
+ it 'should be useful for pagenation' do
24
24
  me = FbGraph::User.new('me', :access_token => 'access_token')
25
25
  posts = me.home
26
- puts posts.previous.inspect, posts.next.inspect
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')
27
28
  previous_posts = me.home(posts.previous)
29
+ previous_posts.first.created_time.should == Time.parse('2010-04-27T13:23:08+0000')
30
+ previous_posts.last.created_time.should == Time.parse('2010-04-27T13:10:56+0000')
28
31
  next_posts = me.home(posts.next)
29
- posts.first.created_time.should == '2010-04-27T13:06:14+0000'
30
- posts.last.created_time.should == '2010-04-27T11:07:48+0000'
31
- previous_posts.first.created_time.should == '2010-04-27T13:23:08+0000'
32
- previous_posts.last.created_time.should == '2010-04-27T13:10:56+0000'
33
- next_posts.first.created_time.should == '2010-04-27T11:06:29+0000'
34
- next_posts.last.created_time.should == '2010-04-27T09:44:28+0000'
32
+ next_posts.first.created_time.should == Time.parse('2010-04-27T11:06:29+0000')
33
+ next_posts.last.created_time.should == Time.parse('2010-04-27T09:44:28+0000')
35
34
  end
36
35
 
37
36
  end
@@ -0,0 +1,31 @@
1
+ require File.join(File.dirname(__FILE__), '../spec_helper')
2
+
3
+ describe FbGraph::Comment, '#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',
13
+ :created_time => '2010-01-02T15:37:40+0000'
14
+ }
15
+ comment = FbGraph::Comment.new(attributes.delete(:id), attributes)
16
+ comment.identifier.should == '12345'
17
+ comment.from.should == FbGraph::User.new('23456', :name => 'nov matake')
18
+ comment.message.should == 'hello'
19
+ comment.created_time.should == Time.parse('2010-01-02T15:37:40+0000')
20
+ end
21
+
22
+ it 'should support page as from' do
23
+ page_comment = FbGraph::Comment.new('12345', :from => {
24
+ :id => '23456',
25
+ :name => 'Smart.fm',
26
+ :category => 'Web Site'
27
+ })
28
+ page_comment.from.should == FbGraph::Page.new('23456', :name => 'Smart.fm', :category => 'Web Site')
29
+ end
30
+
31
+ end
@@ -1,27 +1,31 @@
1
1
  require File.join(File.dirname(__FILE__), '../../spec_helper')
2
2
 
3
3
  describe FbGraph::Connections::Activities, '#activities' 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/activities', 'users/activities/arjun_public')
7
7
  fake_json(:get, 'arjun/activities?access_token=access_token', 'users/activities/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').activities
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').activities
14
+ end.should raise_exception(FbGraph::Unauthorized)
15
+ end
14
16
  end
15
17
 
16
- it 'should return liked pages' do
17
- activities = FbGraph::User.new('arjun', :access_token => 'access_token').activities
18
- activities.first.should == FbGraph::Page.new(
19
- '378209722137',
20
- :name => 'Doing Things at the Last Minute',
21
- :category => '活動'
22
- )
23
- activities.each do |activity|
24
- activity.should be_instance_of(FbGraph::Page)
18
+ context 'when access_token is given' do
19
+ it 'should return activities as FbGraph::Page' do
20
+ activities = FbGraph::User.new('arjun', :access_token => 'access_token').activities
21
+ activities.first.should == FbGraph::Page.new(
22
+ '378209722137',
23
+ :name => 'Doing Things at the Last Minute',
24
+ :category => '活動'
25
+ )
26
+ activities.each do |activity|
27
+ activity.should be_instance_of(FbGraph::Page)
28
+ end
25
29
  end
26
30
  end
27
31
  end
@@ -1,34 +1,38 @@
1
1
  require File.join(File.dirname(__FILE__), '../../spec_helper')
2
2
 
3
3
  describe FbGraph::Connections::Albums, '#albums' 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, 'matake/albums', 'users/albums/matake_public')
7
7
  fake_json(:get, 'matake/albums?access_token=access_token', 'users/albums/matake_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('matake').albums
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('matake').albums
14
+ end.should raise_exception(FbGraph::Unauthorized)
15
+ end
14
16
  end
15
17
 
16
- it 'should return liked pages' do
17
- albums = FbGraph::User.new('matake', :access_token => 'access_token').albums
18
- albums.first.should == FbGraph::Album.new(
19
- '19351532276',
20
- :from => {
21
- :id => '579612276',
22
- :name => 'Nov Matake'
23
- },
24
- :name => 'モバイルアップロード',
25
- :link => 'http://www.facebook.com/album.php?aid=25463&id=579612276',
26
- :count => 3,
27
- :created_time => '2008-07-27T11:38:15+0000',
28
- :updated_time => '2009-02-07T16:09:53+0000'
29
- )
30
- albums.each do |album|
31
- album.should be_instance_of(FbGraph::Album)
18
+ context 'when access_token is given' do
19
+ it 'should return albums as FbGraph::Album' do
20
+ albums = FbGraph::User.new('matake', :access_token => 'access_token').albums
21
+ albums.first.should == FbGraph::Album.new(
22
+ '19351532276',
23
+ :from => {
24
+ :id => '579612276',
25
+ :name => 'Nov Matake'
26
+ },
27
+ :name => 'モバイルアップロード',
28
+ :link => 'http://www.facebook.com/album.php?aid=25463&id=579612276',
29
+ :count => 3,
30
+ :created_time => '2008-07-27T11:38:15+0000',
31
+ :updated_time => '2009-02-07T16:09:53+0000'
32
+ )
33
+ albums.each do |album|
34
+ album.should be_instance_of(FbGraph::Album)
35
+ end
32
36
  end
33
37
  end
34
38
  end
@@ -0,0 +1,32 @@
1
+ require File.join(File.dirname(__FILE__), '../../spec_helper')
2
+
3
+ describe FbGraph::Connections::Books, '#books' do
4
+ context 'when included by FbGraph::User' do
5
+ before(:all) do
6
+ fake_json(:get, 'matake/books', 'users/books/matake_public')
7
+ fake_json(:get, 'matake/books?access_token=access_token', 'users/books/matake_private')
8
+ end
9
+
10
+ context 'when no access_token given' do
11
+ it 'should raise FbGraph::Unauthorized' do
12
+ lambda do
13
+ FbGraph::User.new('matake').books
14
+ end.should raise_exception(FbGraph::Unauthorized)
15
+ end
16
+ end
17
+
18
+ context 'when access_token is given' do
19
+ 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
+ :name => 'Momo Michael Ende',
24
+ :category => 'Unknown'
25
+ )
26
+ books.each do |book|
27
+ book.should be_instance_of(FbGraph::Page)
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -1,31 +1,34 @@
1
1
  require File.join(File.dirname(__FILE__), '../../spec_helper')
2
2
 
3
3
  describe FbGraph::Connections::Events, '#events' 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, 'matake/events', 'users/events/matake_public')
7
7
  fake_json(:get, 'matake/events?access_token=access_token', 'users/events/matake_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('matake').events
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('matake').events
14
+ end.should raise_exception(FbGraph::Unauthorized)
15
+ end
14
16
  end
15
17
 
16
- it 'should return public own posts even when access_token is not given' do
17
- events = FbGraph::User.new('matake', :access_token => 'access_token').events
18
- events.first.should == FbGraph::Event.new(
19
- '116600818359630',
20
- :name => 'The Loyal We @ Rainy Day Bookstore and Cafe',
21
- :start_time => '2010-04-29T01:30:00+0000',
22
- :end_time => '2010-04-29T04:30:00+0000',
23
- :location => 'Nishi Azabu'
24
- )
25
- events.each do |event|
26
- event.should be_instance_of(FbGraph::Event)
18
+ context 'when access_token is given' do
19
+ it 'should return events as FbGraph::Event' do
20
+ events = FbGraph::User.new('matake', :access_token => 'access_token').events
21
+ events.first.should == FbGraph::Event.new(
22
+ '116600818359630',
23
+ :name => 'The Loyal We @ Rainy Day Bookstore and Cafe',
24
+ :start_time => '2010-04-29T01:30:00+0000',
25
+ :end_time => '2010-04-29T04:30:00+0000',
26
+ :location => 'Nishi Azabu'
27
+ )
28
+ events.each do |event|
29
+ event.should be_instance_of(FbGraph::Event)
30
+ end
27
31
  end
28
32
  end
29
-
30
33
  end
31
34
  end
@@ -1,34 +1,35 @@
1
1
  require File.join(File.dirname(__FILE__), '../../spec_helper')
2
2
 
3
3
  describe FbGraph::Connections::Feed, '#feed' 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/feed', 'users/feed/arjun_public')
7
7
  fake_json(:get, 'arjun/feed?access_token=access_token', 'users/feed/arjun_private')
8
8
  end
9
9
 
10
- it 'should return public wall posts even when access_token is not given' do
11
- posts = FbGraph::User.new('arjun').feed
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 on the user\'s wall as FbGraph::Post' do
12
+ posts = FbGraph::User.new('arjun').feed
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
@@ -1,7 +1,7 @@
1
1
  require File.join(File.dirname(__FILE__), '../../spec_helper')
2
2
 
3
3
  describe FbGraph::Connections::Friends, '#friends' 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, 'me/friends', 'users/friends/me_public')
7
7
  fake_json(:get, 'me/friends?access_token=access_token', 'users/friends/me_private')
@@ -9,34 +9,41 @@ describe FbGraph::Connections::Friends, '#friends' do
9
9
  fake_json(:get, 'arjun/friends?access_token=access_token', 'users/friends/arjun_private')
10
10
  end
11
11
 
12
- it 'should raise FbGraph::Exception when no access_token given' do
13
- lambda do
14
- FbGraph::User.new('arjun').friends
15
- end.should raise_exception(FbGraph::Exception)
12
+ context 'when no access_token given' do
13
+ it 'should raise FbGraph::Exception' do
14
+ lambda do
15
+ FbGraph::User.new('arjun').friends
16
+ end.should raise_exception(FbGraph::Exception)
17
+ end
16
18
  end
17
19
 
18
- it 'should raise FbGraph::Exception when identifier is not me' do
19
- lambda do
20
- FbGraph::User.new('arjun', :access_token => 'access_token').friends
21
- end.should raise_exception(FbGraph::Exception)
20
+ context 'when identifier is not me' do
21
+ it 'should raise FbGraph::Exception' do
22
+ lambda do
23
+ FbGraph::User.new('arjun', :access_token => 'access_token').friends
24
+ end.should raise_exception(FbGraph::Exception)
25
+ end
22
26
  end
23
27
 
24
- it 'should raise FbGraph::NotFound when identifier is me and no access_token is given' do
25
- lambda do
26
- FbGraph::User.new('me').friends
27
- end.should raise_exception(FbGraph::NotFound)
28
+ context 'when identifier is me and no access_token is given' do
29
+ it 'should raise FbGraph::NotFound' do
30
+ lambda do
31
+ FbGraph::User.new('me').friends
32
+ end.should raise_exception(FbGraph::NotFound)
33
+ end
28
34
  end
29
35
 
30
- it 'should return posts when identifier is me and access_token is given' do
31
- users = FbGraph::User.new('me', :access_token => 'access_token').friends
32
- users.first.should == FbGraph::User.new(
33
- '6401',
34
- :name => 'Kirk McMurray'
35
- )
36
- users.each do |user|
37
- user.should be_instance_of(FbGraph::User)
36
+ context 'when identifier is me and access_token is given' do
37
+ it 'should return friends as FbGraph::User' do
38
+ users = FbGraph::User.new('me', :access_token => 'access_token').friends
39
+ users.first.should == FbGraph::User.new(
40
+ '6401',
41
+ :name => 'Kirk McMurray'
42
+ )
43
+ users.each do |user|
44
+ user.should be_instance_of(FbGraph::User)
45
+ end
38
46
  end
39
47
  end
40
-
41
48
  end
42
49
  end
@@ -1,28 +1,31 @@
1
1
  require File.join(File.dirname(__FILE__), '../../spec_helper')
2
2
 
3
3
  describe FbGraph::Connections::Groups, '#groups' 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, 'matake/groups', 'users/groups/matake_public')
7
7
  fake_json(:get, 'matake/groups?access_token=access_token', 'users/groups/matake_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('matake').groups
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('matake').groups
14
+ end.should raise_exception(FbGraph::Unauthorized)
15
+ end
14
16
  end
15
17
 
16
- it 'should return public own posts even when access_token is not given' do
17
- groups = FbGraph::User.new('matake', :access_token => 'access_token').groups
18
- groups.first.should == FbGraph::Group.new(
19
- '115286585902',
20
- :name => 'iPhone 3G S'
21
- )
22
- groups.each do |group|
23
- group.should be_instance_of(FbGraph::Group)
18
+ context 'when access_token is given' do
19
+ it 'should return groups as FbGraph::Group' do
20
+ groups = FbGraph::User.new('matake', :access_token => 'access_token').groups
21
+ groups.first.should == FbGraph::Group.new(
22
+ '115286585902',
23
+ :name => 'iPhone 3G S'
24
+ )
25
+ groups.each do |group|
26
+ group.should be_instance_of(FbGraph::Group)
27
+ end
24
28
  end
25
29
  end
26
-
27
30
  end
28
31
  end
@@ -1,7 +1,7 @@
1
1
  require File.join(File.dirname(__FILE__), '../../spec_helper')
2
2
 
3
3
  describe FbGraph::Connections::Home, '#home' 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, 'me/home', 'users/home/me_public')
7
7
  fake_json(:get, 'me/home?access_token=access_token', 'users/home/me_private')
@@ -9,42 +9,49 @@ describe FbGraph::Connections::Home, '#home' do
9
9
  fake_json(:get, 'arjun/home?access_token=access_token', 'users/home/arjun_private')
10
10
  end
11
11
 
12
- it 'should raise FbGraph::Exception when no access_token given' do
13
- lambda do
14
- FbGraph::User.new('arjun').home
15
- end.should raise_exception(FbGraph::Exception)
12
+ context 'when no access_token given' do
13
+ it 'should raise FbGraph::Exception' do
14
+ lambda do
15
+ FbGraph::User.new('arjun').home
16
+ end.should raise_exception(FbGraph::Exception)
17
+ end
16
18
  end
17
19
 
18
- it 'should raise FbGraph::Exception when identifier is not me' do
19
- lambda do
20
- FbGraph::User.new('arjun', :access_token => 'access_token').home
21
- end.should raise_exception(FbGraph::Exception)
20
+ context 'when identifier is not me' do
21
+ it 'should raise FbGraph::Exception' do
22
+ lambda do
23
+ FbGraph::User.new('arjun', :access_token => 'access_token').home
24
+ end.should raise_exception(FbGraph::Exception)
25
+ end
22
26
  end
23
27
 
24
- it 'should raise FbGraph::NotFound when identifier is me and no access_token is given' do
25
- lambda do
26
- FbGraph::User.new('me').home
27
- end.should raise_exception(FbGraph::NotFound)
28
+ context 'when identifier is me and no access_token is given' do
29
+ it 'should raise FbGraph::NotFound' do
30
+ lambda do
31
+ FbGraph::User.new('me').home
32
+ end.should raise_exception(FbGraph::NotFound)
33
+ end
28
34
  end
29
35
 
30
- it 'should return posts when identifier is me and access_token is given' do
31
- posts = FbGraph::User.new('me', :access_token => 'access_token').home
32
- posts.first.should == FbGraph::Post.new(
33
- '634033380_112599768777073',
34
- :from => {
35
- :id => '634033380',
36
- :name => 'nishikokura hironobu'
37
- },
38
- :message => "こちらこそありがとうございました!僕はctrl+無変換ですwRT @_eskm: @pandeiro245 こないだの日曜はありがとうございました!面白い内容でした。ちなみにfnrirってCapsLockで起動ですが、英数変換と同じボタンでどうしてます?起動を違うボタンに変更",
39
- :icon => 'http://photos-h.ak.fbcdn.net/photos-ak-sf2p/v43/23/2231777543/app_2_2231777543_2528.gif',
40
- :attribution => 'Twitter',
41
- :created_time => '2010-04-27T13:06:14+0000',
42
- :updated_time => '2010-04-27T13:06:14+0000'
43
- )
44
- posts.each do |post|
45
- post.should be_instance_of(FbGraph::Post)
36
+ context 'when identifier is me and access_token is given' do
37
+ it 'should return public posts in the user\'s news feed as FbGraph::Post' do
38
+ posts = FbGraph::User.new('me', :access_token => 'access_token').home
39
+ posts.first.should == FbGraph::Post.new(
40
+ '634033380_112599768777073',
41
+ :from => {
42
+ :id => '634033380',
43
+ :name => 'nishikokura hironobu'
44
+ },
45
+ :message => "こちらこそありがとうございました!僕はctrl+無変換ですwRT @_eskm: @pandeiro245 こないだの日曜はありがとうございました!面白い内容でした。ちなみにfnrirってCapsLockで起動ですが、英数変換と同じボタンでどうしてます?起動を違うボタンに変更",
46
+ :icon => 'http://photos-h.ak.fbcdn.net/photos-ak-sf2p/v43/23/2231777543/app_2_2231777543_2528.gif',
47
+ :attribution => 'Twitter',
48
+ :created_time => '2010-04-27T13:06:14+0000',
49
+ :updated_time => '2010-04-27T13:06:14+0000'
50
+ )
51
+ posts.each do |post|
52
+ post.should be_instance_of(FbGraph::Post)
53
+ end
46
54
  end
47
55
  end
48
-
49
56
  end
50
57
  end