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.
- data/.gitignore +21 -0
- data/.rspec +2 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +52 -0
- data/README.rdoc +1 -0
- data/Rakefile +8 -34
- data/VERSION +1 -1
- data/fb_graph.gemspec +15 -433
- data/lib/fb_graph/connections/family.rb +14 -0
- data/lib/fb_graph/connections/permissions.rb +12 -0
- data/lib/fb_graph/page/category_attributes.rb +1 -0
- data/lib/fb_graph/user.rb +4 -1
- data/lib/fb_graph.rb +0 -1
- data/spec/fb_graph/application_spec.rb +8 -14
- data/spec/fb_graph/auth_spec.rb +1 -1
- data/spec/fb_graph/checkin_spec.rb +15 -11
- data/spec/fb_graph/collection_spec.rb +8 -7
- data/spec/fb_graph/connection_spec.rb +36 -25
- data/spec/fb_graph/connections/accounts_spec.rb +30 -26
- data/spec/fb_graph/connections/activities_spec.rb +19 -18
- data/spec/fb_graph/connections/albums_spec.rb +40 -37
- data/spec/fb_graph/connections/app_requests_spec.rb +7 -7
- data/spec/fb_graph/connections/attending_spec.rb +12 -12
- data/spec/fb_graph/connections/books_spec.rb +18 -17
- data/spec/fb_graph/connections/checkins_spec.rb +91 -91
- data/spec/fb_graph/connections/comments_spec.rb +41 -48
- data/spec/fb_graph/connections/declined_spec.rb +13 -9
- data/spec/fb_graph/connections/events_spec.rb +31 -32
- data/spec/fb_graph/connections/family_spec.rb +34 -0
- data/spec/fb_graph/connections/feed_spec.rb +65 -70
- data/spec/fb_graph/connections/former_participants_spec.rb +8 -7
- data/spec/fb_graph/connections/friend_lists_spec.rb +7 -7
- data/spec/fb_graph/connections/friends_spec.rb +29 -24
- data/spec/fb_graph/connections/games_spec.rb +15 -15
- data/spec/fb_graph/connections/groups_spec.rb +17 -16
- data/spec/fb_graph/connections/home_spec.rb +40 -35
- data/spec/fb_graph/connections/insights_spec.rb +74 -70
- data/spec/fb_graph/connections/interests_spec.rb +7 -7
- data/spec/fb_graph/connections/invited_spec.rb +7 -7
- data/spec/fb_graph/connections/likes_spec.rb +23 -19
- data/spec/fb_graph/connections/links_spec.rb +17 -19
- data/spec/fb_graph/connections/maybe_spec.rb +10 -12
- data/spec/fb_graph/connections/members_spec.rb +7 -7
- data/spec/fb_graph/connections/messages_spec.rb +8 -7
- data/spec/fb_graph/connections/movies_spec.rb +7 -7
- data/spec/fb_graph/connections/music_spec.rb +7 -7
- data/spec/fb_graph/connections/noreply_spec.rb +7 -7
- data/spec/fb_graph/connections/notes_spec.rb +18 -16
- data/spec/fb_graph/connections/participants_spec.rb +8 -7
- data/spec/fb_graph/connections/permissions_spec.rb +18 -0
- data/spec/fb_graph/connections/photos_spec.rb +24 -24
- data/spec/fb_graph/connections/posts_spec.rb +23 -26
- data/spec/fb_graph/connections/senders_spec.rb +8 -7
- data/spec/fb_graph/connections/statuses_spec.rb +45 -43
- data/spec/fb_graph/connections/subscriptions_spec.rb +7 -7
- data/spec/fb_graph/connections/tagged_spec.rb +30 -33
- data/spec/fb_graph/connections/television_spec.rb +7 -7
- data/spec/fb_graph/connections/test_users_spec.rb +13 -9
- data/spec/fb_graph/connections/threads_spec.rb +7 -7
- data/spec/fb_graph/connections/videos_spec.rb +7 -7
- data/spec/fb_graph/page/local_business_spec.rb +4 -4
- data/spec/fb_graph/page/movie_spec.rb +4 -4
- data/spec/fb_graph/page/music_spec.rb +4 -4
- data/spec/fb_graph/page/person_spec.rb +4 -4
- data/spec/fb_graph/page/product_spec.rb +4 -4
- data/spec/fb_graph/page_spec.rb +8 -16
- data/spec/fb_graph/post_spec.rb +50 -46
- data/spec/fb_graph/query/core_spec.rb +39 -51
- data/spec/fb_graph/searchable_spec.rb +13 -9
- data/spec/fb_graph/test_user_spec.rb +5 -11
- data/spec/fb_graph/user_spec.rb +96 -91
- data/spec/helpers/webmock_helper.rb +71 -0
- data/spec/{fake_json → mock_json}/albums/photos/matake_private.json +0 -0
- data/spec/{fake_json → mock_json}/albums/photos/post_with_valid_access_token.json +0 -0
- data/spec/{fake_json → mock_json}/applications/feed/public.json +0 -0
- data/spec/{fake_json → mock_json}/applications/subscriptions/fb_graph_private.json +0 -0
- data/spec/{fake_json → mock_json}/applications/test_users/created.json +0 -0
- data/spec/{fake_json → mock_json}/applications/test_users/private.json +0 -0
- data/spec/{fake_json → mock_json}/checkins/search_private.json +0 -0
- data/spec/{fake_json → mock_json}/checkins/search_public.json +0 -0
- data/spec/{fake_json → mock_json}/events/attending/post_with_valid_access_token.json +0 -0
- data/spec/{fake_json → mock_json}/events/attending/smartday_private.json +0 -0
- data/spec/{fake_json → mock_json}/events/declined/post_with_valid_access_token.json +0 -0
- data/spec/{fake_json → mock_json}/events/declined/smartday_private.json +0 -0
- data/spec/{fake_json → mock_json}/events/invited/smartday_private.json +0 -0
- data/spec/{fake_json → mock_json}/events/maybe/post_with_valid_access_token.json +0 -0
- data/spec/{fake_json → mock_json}/events/maybe/smartday_private.json +0 -0
- data/spec/{fake_json → mock_json}/events/noreply/smartday_private.json +0 -0
- data/spec/{fake_json → mock_json}/groups/members/emacs_private.json +0 -0
- data/spec/{fake_json → mock_json}/pages/categories/local_business.json +0 -0
- data/spec/{fake_json → mock_json}/pages/categories/movie.json +0 -0
- data/spec/{fake_json → mock_json}/pages/categories/music.json +0 -0
- data/spec/{fake_json → mock_json}/pages/categories/person.json +0 -0
- data/spec/{fake_json → mock_json}/pages/categories/product.json +0 -0
- data/spec/{fake_json → mock_json}/pages/checkins/gowalla_private.json +0 -0
- data/spec/{fake_json → mock_json}/pages/checkins/gowalla_public.json +0 -0
- data/spec/{fake_json → mock_json}/pages/insights/FbGraph_private.json +0 -0
- data/spec/{fake_json → mock_json}/pages/insights/FbGraph_public.json +0 -0
- data/spec/{fake_json → mock_json}/pages/insights/page_like_adds/FbGraph_private.json +0 -0
- data/spec/{fake_json → mock_json}/pages/insights/page_like_adds/day/FbGraph_private.json +0 -0
- data/spec/{fake_json → mock_json}/pages/notes/post_with_valid_access_token.json +0 -0
- data/spec/{fake_json → mock_json}/pages/platform_private.json +0 -0
- data/spec/{fake_json → mock_json}/pages/platform_public.json +0 -0
- data/spec/{fake_json → mock_json}/pages/search_fb_graph.json +0 -0
- data/spec/{fake_json → mock_json}/pages/search_google.json +0 -0
- data/spec/{fake_json → mock_json}/pages/statuses/platform_private.json +0 -0
- data/spec/{fake_json → mock_json}/pages/statuses/platform_public.json +0 -0
- data/spec/{fake_json → mock_json}/posts/comments/post_with_invalid_access_token.json +0 -0
- data/spec/{fake_json → mock_json}/posts/comments/post_with_valid_access_token.json +0 -0
- data/spec/{fake_json → mock_json}/posts/comments/post_without_access_token.json +0 -0
- data/spec/{fake_json → mock_json}/posts/likes/post_with_invalid_access_token.json +0 -0
- data/spec/{fake_json → mock_json}/posts/likes/post_with_valid_access_token.json +0 -0
- data/spec/{fake_json → mock_json}/posts/likes/post_without_access_token.json +0 -0
- data/spec/{fake_json → mock_json}/posts/no_comments.json +0 -0
- data/spec/{fake_json → mock_json}/posts/platform_private.json +0 -0
- data/spec/{fake_json → mock_json}/posts/platform_public.json +0 -0
- data/spec/{fake_json → mock_json}/posts/to_application.json +0 -0
- data/spec/{fake_json → mock_json}/posts/to_event.json +0 -0
- data/spec/{fake_json → mock_json}/posts/to_group.json +0 -0
- data/spec/{fake_json → mock_json}/query/user/with_invalid_token.json +0 -0
- data/spec/{fake_json → mock_json}/query/user/with_valid_token.json +0 -0
- data/spec/{fake_json → mock_json}/query/user/without_token.json +0 -0
- data/spec/{fake_json → mock_json}/statuses/with_likes.json +0 -0
- data/spec/{fake_json → mock_json}/thread/former_participants/private.json +0 -0
- data/spec/{fake_json → mock_json}/thread/messages/private.json +0 -0
- data/spec/{fake_json → mock_json}/thread/participants/private.json +0 -0
- data/spec/{fake_json → mock_json}/thread/senders/private.json +0 -0
- data/spec/{fake_json → mock_json}/token_response.json +0 -0
- data/spec/{fake_json → mock_json}/true.json +0 -0
- data/spec/{fake_json → mock_json}/users/accounts/matake_private.json +0 -0
- data/spec/{fake_json → mock_json}/users/accounts/matake_private_with_manage_pages_permission.json +0 -0
- data/spec/{fake_json → mock_json}/users/accounts/matake_public.json +0 -0
- data/spec/{fake_json → mock_json}/users/activities/arjun_private.json +0 -0
- data/spec/{fake_json → mock_json}/users/activities/arjun_public.json +0 -0
- data/spec/{fake_json → mock_json}/users/albums/matake_private.json +0 -0
- data/spec/{fake_json → mock_json}/users/albums/matake_public.json +0 -0
- data/spec/{fake_json → mock_json}/users/albums/post_with_valid_access_token.json +0 -0
- data/spec/{fake_json → mock_json}/users/app_requests/me_private.json +0 -0
- data/spec/{fake_json → mock_json}/users/arjun_private.json +0 -0
- data/spec/{fake_json → mock_json}/users/arjun_public.json +0 -0
- data/spec/{fake_json → mock_json}/users/books/matake_private.json +0 -0
- data/spec/{fake_json → mock_json}/users/books/matake_public.json +0 -0
- data/spec/{fake_json → mock_json}/users/checkins/mattt_private.json +0 -0
- data/spec/{fake_json → mock_json}/users/checkins/mattt_public.json +0 -0
- data/spec/{fake_json → mock_json}/users/checkins/posted.json +0 -0
- data/spec/{fake_json → mock_json}/users/events/matake_private.json +0 -0
- data/spec/{fake_json → mock_json}/users/events/matake_public.json +0 -0
- data/spec/{fake_json → mock_json}/users/events/post_with_valid_access_token.json +0 -0
- data/spec/mock_json/users/family/family_without_access_token.json +6 -0
- data/spec/mock_json/users/family/me_public.json +19 -0
- data/spec/{fake_json → mock_json}/users/feed/arjun_private.json +0 -0
- data/spec/{fake_json → mock_json}/users/feed/arjun_public.json +0 -0
- data/spec/{fake_json → mock_json}/users/feed/post_with_invalid_access_token.json +0 -0
- data/spec/{fake_json → mock_json}/users/feed/post_with_valid_access_token.json +0 -0
- data/spec/{fake_json → mock_json}/users/feed/post_without_access_token.json +0 -0
- data/spec/{fake_json → mock_json}/users/friend_lists/matake.json +0 -0
- data/spec/{fake_json → mock_json}/users/friends/arjun_private.json +0 -0
- data/spec/{fake_json → mock_json}/users/friends/arjun_public.json +0 -0
- data/spec/{fake_json → mock_json}/users/friends/me_private.json +0 -0
- data/spec/{fake_json → mock_json}/users/friends/me_public.json +0 -0
- data/spec/{fake_json → mock_json}/users/games/matake_private.json +0 -0
- data/spec/{fake_json → mock_json}/users/groups/matake_private.json +0 -0
- data/spec/{fake_json → mock_json}/users/groups/matake_public.json +0 -0
- data/spec/{fake_json → mock_json}/users/home/arjun_private.json +0 -0
- data/spec/{fake_json → mock_json}/users/home/arjun_public.json +0 -0
- data/spec/{fake_json → mock_json}/users/home/me_private.json +0 -0
- data/spec/{fake_json → mock_json}/users/home/me_private_next.json +0 -0
- data/spec/{fake_json → mock_json}/users/home/me_private_previous.json +0 -0
- data/spec/{fake_json → mock_json}/users/home/me_public.json +0 -0
- data/spec/{fake_json → mock_json}/users/interests/matake_private.json +0 -0
- data/spec/{fake_json → mock_json}/users/likes/arjun_private.json +0 -0
- data/spec/{fake_json → mock_json}/users/likes/arjun_public.json +0 -0
- data/spec/{fake_json → mock_json}/users/links/matake_private.json +0 -0
- data/spec/{fake_json → mock_json}/users/links/post_with_valid_access_token.json +0 -0
- data/spec/{fake_json → mock_json}/users/me_private.json +0 -0
- data/spec/{fake_json → mock_json}/users/me_public.json +0 -0
- data/spec/{fake_json → mock_json}/users/movies/matake_private.json +0 -0
- data/spec/{fake_json → mock_json}/users/music/matake_private.json +0 -0
- data/spec/{fake_json → mock_json}/users/notes/matake_private.json +0 -0
- data/spec/mock_json/users/permissions/me_private.json +70 -0
- data/spec/{fake_json → mock_json}/users/posts/arjun_private.json +0 -0
- data/spec/{fake_json → mock_json}/users/posts/arjun_public.json +0 -0
- data/spec/{fake_json → mock_json}/users/statuses/arjun_private.json +0 -0
- data/spec/{fake_json → mock_json}/users/statuses/arjun_public.json +0 -0
- data/spec/{fake_json → mock_json}/users/tagged/arjun_private.json +0 -0
- data/spec/{fake_json → mock_json}/users/tagged/arjun_public.json +0 -0
- data/spec/{fake_json → mock_json}/users/television/matake_private.json +0 -0
- data/spec/{fake_json → mock_json}/users/threads/me_private.json +0 -0
- data/spec/{fake_json → mock_json}/users/videos/kirk_private.json +0 -0
- data/spec/spec_helper.rb +2 -7
- metadata +267 -128
- data/.rspec-tm +0 -1
- data/spec/helpers/fake_json_helper.rb +0 -37
- data/spec/spec.opts +0 -3
@@ -2,40 +2,40 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe FbGraph::Connections::Photos, '#photos' do
|
4
4
|
context 'when included by FbGraph::Album' do
|
5
|
-
before do
|
6
|
-
fake_json(:get, '12345/photos?access_token=access_token', 'albums/photos/matake_private')
|
7
|
-
end
|
8
|
-
|
9
5
|
it 'should return photos as FbGraph::Photo' do
|
10
|
-
|
11
|
-
|
12
|
-
|
6
|
+
mock_graph :get, '12345/photos', 'albums/photos/matake_private', :params => {
|
7
|
+
:access_token => 'access_token'
|
8
|
+
} do
|
9
|
+
photos = FbGraph::Album.new('12345', :access_token => 'access_token').photos
|
10
|
+
photos.each do |photo|
|
11
|
+
photo.should be_instance_of(FbGraph::Photo)
|
12
|
+
end
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
18
|
describe FbGraph::Connections::Photos, '#photo!' do
|
19
|
-
before do
|
20
|
-
fake_json(:post, '12345/photos', 'albums/photos/post_with_valid_access_token')
|
21
|
-
end
|
22
|
-
|
23
19
|
it 'should return generated photo' do
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
20
|
+
mock_graph :post, '12345/photos', 'albums/photos/post_with_valid_access_token' do
|
21
|
+
photo = FbGraph::Album.new('12345', :access_token => 'valid').photo!(
|
22
|
+
:image => Tempfile.new('image_file'),
|
23
|
+
:message => 'Hello, where is photo?'
|
24
|
+
)
|
25
|
+
photo.identifier.should == 401111132276
|
26
|
+
photo.name.should == 'Hello, where is photo?'
|
27
|
+
photo.access_token.should == 'valid'
|
28
|
+
end
|
31
29
|
end
|
32
30
|
|
33
31
|
it 'should support Tag' do
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
32
|
+
mock_graph :post, '12345/photos', 'albums/photos/post_with_valid_access_token' do
|
33
|
+
photo = FbGraph::Album.new('12345', :access_token => 'valid').photo!(
|
34
|
+
:image => Tempfile.new('image_file'),
|
35
|
+
:message => 'Hello, where is photo?',
|
36
|
+
:tags => [FbGraph::Tag.new(:id => 12345, :name => 'me', :x => 0, :y => 10)]
|
37
|
+
)
|
38
|
+
photo.tags.should == [FbGraph::Tag.new(:id => 12345, :name => 'me', :x => 0, :y => 10)]
|
39
|
+
end
|
40
40
|
end
|
41
41
|
end
|
@@ -2,34 +2,31 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe FbGraph::Connections::Posts, '#posts' do
|
4
4
|
context 'when included by FbGraph::User' do
|
5
|
-
before do
|
6
|
-
fake_json(:get, 'arjun/posts', 'users/posts/arjun_public')
|
7
|
-
fake_json(:get, 'arjun/posts?access_token=access_token', 'users/posts/arjun_private')
|
8
|
-
end
|
9
|
-
|
10
5
|
context 'when no access_token given' do
|
11
6
|
it 'should return public posts the user created as FbGraph::Post' do
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
:
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
:
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
7
|
+
mock_graph :get, 'arjun/posts', 'users/posts/arjun_public' do
|
8
|
+
posts = FbGraph::User.new('arjun').posts
|
9
|
+
posts.first.should == FbGraph::Post.new(
|
10
|
+
'7901103_121392141207495',
|
11
|
+
:from => {
|
12
|
+
:id => '7901103',
|
13
|
+
:name => 'Arjun Banker'
|
14
|
+
},
|
15
|
+
: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',
|
16
|
+
:link => 'http://www.ted.com/talks/wade_davis_on_endangered_cultures.html',
|
17
|
+
:name => 'Wade Davis on endangered cultures | Video on TED.com',
|
18
|
+
:caption => 'www.ted.com',
|
19
|
+
: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.',
|
20
|
+
:icon => 'http://static.ak.fbcdn.net/rsrc.php/z9XZ8/hash/976ulj6z.gif',
|
21
|
+
:created_time => '2010-04-25T04:05:32+0000',
|
22
|
+
:updated_time => '2010-04-25T04:05:32+0000',
|
23
|
+
:privacy => {
|
24
|
+
:value => 'EVERYONE'
|
25
|
+
}
|
26
|
+
)
|
27
|
+
posts.each do |post|
|
28
|
+
post.should be_instance_of(FbGraph::Post)
|
29
|
+
end
|
33
30
|
end
|
34
31
|
end
|
35
32
|
end
|
@@ -1,10 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe FbGraph::Connections::Senders, '#senders' do
|
4
|
-
before do
|
5
|
-
fake_json(:get, '12345/senders?access_token=access_token&no_cache=true', 'thread/senders/private')
|
6
|
-
end
|
7
|
-
|
8
4
|
it 'should use cached contents as default' do
|
9
5
|
lambda do
|
10
6
|
FbGraph::Thread.new(12345, :access_token => 'access_token').senders
|
@@ -18,9 +14,14 @@ describe FbGraph::Connections::Senders, '#senders' do
|
|
18
14
|
end
|
19
15
|
|
20
16
|
it 'should return senders as FbGraph::User' do
|
21
|
-
|
22
|
-
|
23
|
-
|
17
|
+
mock_graph :get, '12345/senders', 'thread/senders/private', :params => {
|
18
|
+
:access_token => 'access_token',
|
19
|
+
:no_cache => 'true'
|
20
|
+
} do
|
21
|
+
senders = FbGraph::Thread.new(12345, :access_token => 'access_token').senders(:no_cache => true)
|
22
|
+
senders.each do |sender|
|
23
|
+
sender.should be_instance_of(FbGraph::User)
|
24
|
+
end
|
24
25
|
end
|
25
26
|
end
|
26
27
|
end
|
@@ -3,69 +3,71 @@ require 'spec_helper'
|
|
3
3
|
describe FbGraph::Connections::Statuses, '#statuses' do
|
4
4
|
|
5
5
|
context 'when included by FbGraph::User' do
|
6
|
-
before do
|
7
|
-
fake_json(:get, 'arjun/statuses', 'users/statuses/arjun_public', :status => [401, 'Unauthorized'])
|
8
|
-
fake_json(:get, 'arjun/statuses?access_token=access_token', 'users/statuses/arjun_private')
|
9
|
-
end
|
10
|
-
|
11
6
|
context 'when no access_token given' do
|
12
7
|
it 'should raise FbGraph::Unauthorized' do
|
13
|
-
|
14
|
-
|
15
|
-
|
8
|
+
mock_graph :get, 'arjun/statuses', 'users/statuses/arjun_public', :status => [401, 'Unauthorized'] do
|
9
|
+
lambda do
|
10
|
+
FbGraph::User.new('arjun').statuses
|
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 statuses as FbGraph::Status' do
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
:access_token => 'access_token'
|
25
|
-
|
26
|
-
|
27
|
-
:
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
18
|
+
mock_graph :get, 'arjun/statuses', 'users/statuses/arjun_private', :params => {
|
19
|
+
:access_token => 'access_token'
|
20
|
+
} do
|
21
|
+
statuses = FbGraph::User.new('arjun', :access_token => 'access_token').statuses
|
22
|
+
statuses.first.should == FbGraph::Status.new(
|
23
|
+
'113559395341627',
|
24
|
+
:access_token => 'access_token',
|
25
|
+
:from => {
|
26
|
+
:id => '7901103',
|
27
|
+
:name => 'Arjun Banker'
|
28
|
+
},
|
29
|
+
:message => 'http://www.facebook.com/photo.php?pid=60538827&l=79b44ffb74&id=7901103',
|
30
|
+
:updated_time => '2010-04-21T21:10:16+0000'
|
31
|
+
)
|
32
|
+
statuses.each do |status|
|
33
|
+
status.should be_instance_of(FbGraph::Status)
|
34
|
+
end
|
34
35
|
end
|
35
36
|
end
|
36
37
|
end
|
37
38
|
end
|
38
39
|
|
39
40
|
context 'when included by FbGraph::Page' do
|
40
|
-
before do
|
41
|
-
fake_json(:get, 'platform/statuses', 'pages/statuses/platform_public', :status => [401, 'Unauthorized'])
|
42
|
-
fake_json(:get, 'platform/statuses?access_token=access_token', 'pages/statuses/platform_private')
|
43
|
-
end
|
44
|
-
|
45
41
|
context 'when no access_token given' do
|
46
42
|
it 'should raise FbGraph::Unauthorized' do
|
47
|
-
|
48
|
-
|
49
|
-
|
43
|
+
mock_graph :get, 'platform/statuses', 'pages/statuses/platform_public', :status => [401, 'Unauthorized'] do
|
44
|
+
lambda do
|
45
|
+
FbGraph::Page.new('platform').statuses
|
46
|
+
end.should raise_exception(FbGraph::Unauthorized)
|
47
|
+
end
|
50
48
|
end
|
51
49
|
end
|
52
50
|
|
53
51
|
context 'when access_token is given' do
|
54
52
|
it 'should return statuses as FbGraph::Status' do
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
:access_token => 'access_token'
|
59
|
-
|
60
|
-
|
61
|
-
:
|
62
|
-
:
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
53
|
+
mock_graph :get, 'platform/statuses', 'pages/statuses/platform_private', :params => {
|
54
|
+
:access_token => 'access_token'
|
55
|
+
} do
|
56
|
+
statuses = FbGraph::Page.new('platform', :access_token => 'access_token').statuses
|
57
|
+
statuses.first.should == FbGraph::Status.new(
|
58
|
+
'111081598927600',
|
59
|
+
:access_token => 'access_token',
|
60
|
+
:from => {
|
61
|
+
:id => '19292868552',
|
62
|
+
:name => 'Facebook Platform',
|
63
|
+
:category => 'Technology'
|
64
|
+
},
|
65
|
+
:message => 'Here\'s more information on the new social plugins announced at f8 today - http://bit.ly/db8ahS',
|
66
|
+
:updated_time => '2010-04-21T20:17:04+0000'
|
67
|
+
)
|
68
|
+
statuses.each do |status|
|
69
|
+
status.should be_instance_of(FbGraph::Status)
|
70
|
+
end
|
69
71
|
end
|
70
72
|
end
|
71
73
|
end
|
@@ -2,15 +2,15 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe FbGraph::Connections::Subscriptions, '#subscriptions' do
|
4
4
|
context 'when included by FbGraph::Application' do
|
5
|
-
before do
|
6
|
-
fake_json(:get, 'fb_graph/subscriptions?access_token=access_token', 'applications/subscriptions/fb_graph_private')
|
7
|
-
end
|
8
|
-
|
9
5
|
context 'when access_token is given' do
|
10
6
|
it 'should return liked pages as FbGraph::Page' do
|
11
|
-
|
12
|
-
|
13
|
-
|
7
|
+
mock_graph :get, 'fb_graph/subscriptions', 'applications/subscriptions/fb_graph_private', :params => {
|
8
|
+
:access_token => 'access_token'
|
9
|
+
} do
|
10
|
+
subscriptions = FbGraph::Application.new('fb_graph', :access_token => 'access_token').subscriptions
|
11
|
+
subscriptions.each do |subscription|
|
12
|
+
subscription.should be_instance_of(FbGraph::Subscription)
|
13
|
+
end
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
@@ -3,41 +3,38 @@ require 'spec_helper'
|
|
3
3
|
|
4
4
|
describe FbGraph::Connections::Tagged, '#tagged' do
|
5
5
|
context 'when included by FbGraph::User' do
|
6
|
-
before do
|
7
|
-
fake_json(:get, 'arjun/tagged', 'users/tagged/arjun_public')
|
8
|
-
fake_json(:get, 'arjun/tagged?access_token=access_token', 'users/tagged/arjun_private')
|
9
|
-
end
|
10
|
-
|
11
6
|
context 'when no access_token given' do
|
12
7
|
it 'should return posts the user has been tagged as FbGraph::Post' do
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
:
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
:
|
22
|
-
:
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
:
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
8
|
+
mock_graph :get, 'arjun/tagged', 'users/tagged/arjun_public' do
|
9
|
+
posts = FbGraph::User.new('arjun').tagged
|
10
|
+
posts.first.should == FbGraph::Post.new(
|
11
|
+
'7901103_117809521578252',
|
12
|
+
:from => {
|
13
|
+
:id => '1404401889',
|
14
|
+
:name => 'Elli Mooney'
|
15
|
+
},
|
16
|
+
:to => {
|
17
|
+
:data => [{
|
18
|
+
:id => '7901103',
|
19
|
+
:name => 'Arjun Banker'
|
20
|
+
}]
|
21
|
+
},
|
22
|
+
:message => '...uh oh, here comes a privacy issue....',
|
23
|
+
: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',
|
24
|
+
:link => 'http://venturebeat.com/2010/04/23/blippy-credit-card-citibank/',
|
25
|
+
:name => 'Blippy users’ credit card numbers found on Google | VentureBeat',
|
26
|
+
:caption => 'venturebeat.com',
|
27
|
+
:description => '[Update: Blippy cofounder Philip Kaplan emailed a response. CNET News is reporting that the cards in question were issued by ...',
|
28
|
+
:icon => 'http://static.ak.fbcdn.net/rsrc.php/zB010/hash/9yvl71tw.gif',
|
29
|
+
:created_time => '2010-04-24T08:07:59+0000',
|
30
|
+
:updated_time => '2010-04-24T08:07:59+0000',
|
31
|
+
:privacy => {
|
32
|
+
:value => 'EVERYONE'
|
33
|
+
}
|
34
|
+
)
|
35
|
+
posts.each do |post|
|
36
|
+
post.should be_instance_of(FbGraph::Post)
|
37
|
+
end
|
41
38
|
end
|
42
39
|
end
|
43
40
|
end
|
@@ -1,14 +1,14 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe FbGraph::Connections::Television, '#television' do
|
4
|
-
before do
|
5
|
-
fake_json(:get, 'matake/television?access_token=access_token', 'users/television/matake_private')
|
6
|
-
end
|
7
|
-
|
8
4
|
it 'should return television pages as FbGraph::Page' do
|
9
|
-
|
10
|
-
|
11
|
-
|
5
|
+
mock_graph :get, 'matake/television', 'users/television/matake_private', :params => {
|
6
|
+
:access_token => 'access_token'
|
7
|
+
} do
|
8
|
+
pages = FbGraph::User.new('matake', :access_token => 'access_token').television
|
9
|
+
pages.each do |page|
|
10
|
+
page.should be_instance_of(FbGraph::Page)
|
11
|
+
end
|
12
12
|
end
|
13
13
|
end
|
14
14
|
end
|
@@ -3,7 +3,6 @@ require 'spec_helper'
|
|
3
3
|
describe FbGraph::Connections::TestUsers, '#test_users' do
|
4
4
|
before do
|
5
5
|
@app = FbGraph::Application.new('client_id', :secret => 'secret')
|
6
|
-
fake_json(:get, 'client_id/accounts/test-users?access_token=access_token', 'applications/test_users/private')
|
7
6
|
end
|
8
7
|
|
9
8
|
context 'when access_token is not given' do
|
@@ -16,10 +15,14 @@ describe FbGraph::Connections::TestUsers, '#test_users' do
|
|
16
15
|
|
17
16
|
context 'when access_token is given' do
|
18
17
|
it 'should return test_users as FbGraph::TestUser' do
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
18
|
+
mock_graph :get, 'client_id/accounts/test-users', 'applications/test_users/private', :params => {
|
19
|
+
:access_token => 'access_token'
|
20
|
+
} do
|
21
|
+
@app.access_token = 'access_token'
|
22
|
+
test_users = @app.test_users
|
23
|
+
test_users.each do |test_user|
|
24
|
+
test_user.should be_instance_of(FbGraph::TestUser)
|
25
|
+
end
|
23
26
|
end
|
24
27
|
end
|
25
28
|
end
|
@@ -28,7 +31,6 @@ end
|
|
28
31
|
describe FbGraph::Connections::TestUsers, '#test_user!' do
|
29
32
|
before do
|
30
33
|
@app = FbGraph::Application.new('client_id', :secret => 'secret')
|
31
|
-
fake_json(:post, 'client_id/accounts/test-users', 'applications/test_users/created')
|
32
34
|
end
|
33
35
|
|
34
36
|
context 'when access_token is not given' do
|
@@ -41,9 +43,11 @@ describe FbGraph::Connections::TestUsers, '#test_user!' do
|
|
41
43
|
|
42
44
|
context 'when access_token is given' do
|
43
45
|
it 'should return a FbGraph::TestUser' do
|
44
|
-
|
45
|
-
|
46
|
-
|
46
|
+
mock_graph :post, 'client_id/accounts/test-users', 'applications/test_users/created' do
|
47
|
+
@app.access_token = 'access_token'
|
48
|
+
test_user = @app.test_user!
|
49
|
+
test_user.should be_instance_of FbGraph::TestUser
|
50
|
+
end
|
47
51
|
end
|
48
52
|
end
|
49
53
|
end
|
@@ -1,14 +1,14 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe FbGraph::Connections::Threads, '#threads' do
|
4
|
-
before do
|
5
|
-
fake_json(:get, 'me/threads?access_token=access_token', 'users/threads/me_private')
|
6
|
-
end
|
7
|
-
|
8
4
|
it 'should return threads as FbGraph::Thread' do
|
9
|
-
|
10
|
-
|
11
|
-
|
5
|
+
mock_graph :get, 'me/threads', 'users/threads/me_private', :params => {
|
6
|
+
:access_token => 'access_token'
|
7
|
+
} do
|
8
|
+
threads = FbGraph::User.me('access_token').threads
|
9
|
+
threads.each do |thread|
|
10
|
+
thread.should be_instance_of(FbGraph::Thread)
|
11
|
+
end
|
12
12
|
end
|
13
13
|
end
|
14
14
|
end
|
@@ -1,14 +1,14 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe FbGraph::Connections::Videos, '#videos' do
|
4
|
-
before do
|
5
|
-
fake_json(:get, 'kirk/videos?access_token=access_token', 'users/videos/kirk_private')
|
6
|
-
end
|
7
|
-
|
8
4
|
it 'should return videos as FbGraph::Video' do
|
9
|
-
|
10
|
-
|
11
|
-
|
5
|
+
mock_graph :get, 'kirk/videos', 'users/videos/kirk_private', :params => {
|
6
|
+
:access_token => 'access_token'
|
7
|
+
} do
|
8
|
+
videos = FbGraph::User.new('kirk', :access_token => 'access_token').videos
|
9
|
+
videos.each do |video|
|
10
|
+
video.should be_instance_of(FbGraph::Video)
|
11
|
+
end
|
12
12
|
end
|
13
13
|
end
|
14
14
|
end
|
@@ -3,11 +3,11 @@ require 'spec_helper'
|
|
3
3
|
|
4
4
|
describe FbGraph::Page do
|
5
5
|
context 'for local_business category' do
|
6
|
-
|
7
|
-
|
6
|
+
let :page do
|
7
|
+
mock_graph :get, 'local_business', 'pages/categories/local_business' do
|
8
|
+
FbGraph::Page.new('local_business').fetch
|
9
|
+
end
|
8
10
|
end
|
9
|
-
|
10
|
-
let(:page) { FbGraph::Page.new('local_business').fetch }
|
11
11
|
subject { page }
|
12
12
|
|
13
13
|
[
|
@@ -2,11 +2,11 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe FbGraph::Page do
|
4
4
|
context 'for people category' do
|
5
|
-
|
6
|
-
|
5
|
+
let :page do
|
6
|
+
mock_graph :get, 'movie', 'pages/categories/movie' do
|
7
|
+
FbGraph::Page.new('movie').fetch
|
8
|
+
end
|
7
9
|
end
|
8
|
-
|
9
|
-
let(:page) { FbGraph::Page.new('movie').fetch }
|
10
10
|
subject { page }
|
11
11
|
|
12
12
|
[
|
@@ -2,11 +2,11 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe FbGraph::Page do
|
4
4
|
context 'for music category' do
|
5
|
-
|
6
|
-
|
5
|
+
let :page do
|
6
|
+
mock_graph :get, 'music', 'pages/categories/music' do
|
7
|
+
FbGraph::Page.new('music').fetch
|
8
|
+
end
|
7
9
|
end
|
8
|
-
|
9
|
-
let(:page) { FbGraph::Page.new('music').fetch }
|
10
10
|
subject { page }
|
11
11
|
|
12
12
|
[
|
@@ -2,11 +2,11 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe FbGraph::Page do
|
4
4
|
context 'for person category' do
|
5
|
-
|
6
|
-
|
5
|
+
let :page do
|
6
|
+
mock_graph :get, 'person', 'pages/categories/person'do
|
7
|
+
FbGraph::Page.new('person').fetch
|
8
|
+
end
|
7
9
|
end
|
8
|
-
|
9
|
-
let(:page) { FbGraph::Page.new('person').fetch }
|
10
10
|
subject { page }
|
11
11
|
|
12
12
|
[
|
@@ -2,11 +2,11 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe FbGraph::Page do
|
4
4
|
context 'for product category' do
|
5
|
-
|
6
|
-
|
5
|
+
let :page do
|
6
|
+
mock_graph :get, 'product', 'pages/categories/product' do
|
7
|
+
FbGraph::Page.new('product').fetch
|
8
|
+
end
|
7
9
|
end
|
8
|
-
|
9
|
-
let(:page) { FbGraph::Page.new('product').fetch }
|
10
10
|
subject { page }
|
11
11
|
|
12
12
|
[
|
data/spec/fb_graph/page_spec.rb
CHANGED
@@ -21,22 +21,14 @@ describe FbGraph::Page do
|
|
21
21
|
its(:username) { should == attributes[:username] }
|
22
22
|
|
23
23
|
describe '.fetch' do
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
context 'when access_token is given' do
|
30
|
-
subject { FbGraph::Page.fetch('platform') }
|
31
|
-
its(:identifier) { should == '19292868552' }
|
32
|
-
its(:name) { should == 'Facebook Platform' }
|
33
|
-
its(:category) { should == 'Technology' }
|
34
|
-
its(:like_count) { should == 578214 }
|
35
|
-
end
|
36
|
-
|
37
|
-
context 'otherwise' do
|
38
|
-
subject { FbGraph::Page.fetch('platform', :access_token => 'access_token') }
|
39
|
-
its(:like_count) { should == 578214 }
|
24
|
+
subject do
|
25
|
+
mock_graph :get, 'platform', 'pages/platform_public' do
|
26
|
+
FbGraph::Page.fetch('platform')
|
27
|
+
end
|
40
28
|
end
|
29
|
+
its(:identifier) { should == '19292868552' }
|
30
|
+
its(:name) { should == 'Facebook Platform' }
|
31
|
+
its(:category) { should == 'Technology' }
|
32
|
+
its(:like_count) { should == 578214 }
|
41
33
|
end
|
42
34
|
end
|