gs_graph 2.6.5
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitattributes +22 -0
- data/.gitignore +26 -0
- data/.rspec +2 -0
- data/.travis.yml +3 -0
- data/Gemfile +11 -0
- data/Gemfile.lock +95 -0
- data/LICENSE +20 -0
- data/README.rdoc +314 -0
- data/Rakefile +25 -0
- data/VERSION +1 -0
- data/assets/fb_graph.ai +1726 -6
- data/assets/fb_graph.png +0 -0
- data/gs_graph.gemspec +28 -0
- data/lib/gs_graph.rb +174 -0
- data/lib/gs_graph/achievement.rb +44 -0
- data/lib/gs_graph/action.rb +12 -0
- data/lib/gs_graph/ad_account.rb +51 -0
- data/lib/gs_graph/ad_campaign.rb +39 -0
- data/lib/gs_graph/ad_campaign_stat.rb +22 -0
- data/lib/gs_graph/ad_connection_object.rb +53 -0
- data/lib/gs_graph/ad_creative.rb +44 -0
- data/lib/gs_graph/ad_group.rb +51 -0
- data/lib/gs_graph/ad_group_stat.rb +22 -0
- data/lib/gs_graph/ad_keyword.rb +20 -0
- data/lib/gs_graph/ad_keyword_suggestion.rb +8 -0
- data/lib/gs_graph/ad_keyword_valid.rb +23 -0
- data/lib/gs_graph/ad_preview.rb +10 -0
- data/lib/gs_graph/ad_user.rb +58 -0
- data/lib/gs_graph/age_range.rb +12 -0
- data/lib/gs_graph/album.rb +59 -0
- data/lib/gs_graph/app_request.rb +24 -0
- data/lib/gs_graph/application.rb +119 -0
- data/lib/gs_graph/auth.rb +88 -0
- data/lib/gs_graph/auth/cookie.rb +20 -0
- data/lib/gs_graph/auth/signed_request.rb +44 -0
- data/lib/gs_graph/broad_targeting_category.rb +13 -0
- data/lib/gs_graph/checkin.rb +51 -0
- data/lib/gs_graph/collection.rb +55 -0
- data/lib/gs_graph/comment.rb +24 -0
- data/lib/gs_graph/comparison.rb +13 -0
- data/lib/gs_graph/connection.rb +37 -0
- data/lib/gs_graph/connections.rb +3 -0
- data/lib/gs_graph/connections/accounts.rb +23 -0
- data/lib/gs_graph/connections/achievements.rb +21 -0
- data/lib/gs_graph/connections/activities.rb +14 -0
- data/lib/gs_graph/connections/ad_accounts.rb +15 -0
- data/lib/gs_graph/connections/ad_campaign_stats.rb +22 -0
- data/lib/gs_graph/connections/ad_campaigns.rb +30 -0
- data/lib/gs_graph/connections/ad_connection_objects.rb +14 -0
- data/lib/gs_graph/connections/ad_creatives.rb +14 -0
- data/lib/gs_graph/connections/ad_group_stats.rb +22 -0
- data/lib/gs_graph/connections/ad_groups.rb +35 -0
- data/lib/gs_graph/connections/ad_previews.rb +10 -0
- data/lib/gs_graph/connections/admins.rb +10 -0
- data/lib/gs_graph/connections/albums.rb +21 -0
- data/lib/gs_graph/connections/app_notifications.rb +10 -0
- data/lib/gs_graph/connections/app_requests.rb +21 -0
- data/lib/gs_graph/connections/attending.rb +26 -0
- data/lib/gs_graph/connections/banned.rb +31 -0
- data/lib/gs_graph/connections/blocked.rb +36 -0
- data/lib/gs_graph/connections/books.rb +14 -0
- data/lib/gs_graph/connections/broad_targeting_categories.rb +14 -0
- data/lib/gs_graph/connections/checkins.rb +21 -0
- data/lib/gs_graph/connections/comments.rb +21 -0
- data/lib/gs_graph/connections/conversations.rb +14 -0
- data/lib/gs_graph/connections/declined.rb +25 -0
- data/lib/gs_graph/connections/docs.rb +14 -0
- data/lib/gs_graph/connections/events.rb +21 -0
- data/lib/gs_graph/connections/family.rb +14 -0
- data/lib/gs_graph/connections/feed.rb +21 -0
- data/lib/gs_graph/connections/former_participants.rb +14 -0
- data/lib/gs_graph/connections/friend_lists.rb +21 -0
- data/lib/gs_graph/connections/friend_requests.rb +12 -0
- data/lib/gs_graph/connections/friends.rb +14 -0
- data/lib/gs_graph/connections/games.rb +14 -0
- data/lib/gs_graph/connections/groups.rb +14 -0
- data/lib/gs_graph/connections/home.rb +14 -0
- data/lib/gs_graph/connections/inbox.rb +20 -0
- data/lib/gs_graph/connections/insights.rb +27 -0
- data/lib/gs_graph/connections/interests.rb +14 -0
- data/lib/gs_graph/connections/invited.rb +36 -0
- data/lib/gs_graph/connections/likes.rb +29 -0
- data/lib/gs_graph/connections/links.rb +21 -0
- data/lib/gs_graph/connections/maybe.rb +25 -0
- data/lib/gs_graph/connections/members.rb +22 -0
- data/lib/gs_graph/connections/messages.rb +22 -0
- data/lib/gs_graph/connections/milestones.rb +21 -0
- data/lib/gs_graph/connections/movies.rb +14 -0
- data/lib/gs_graph/connections/music.rb +14 -0
- data/lib/gs_graph/connections/mutual_friends.rb +26 -0
- data/lib/gs_graph/connections/noreply.rb +23 -0
- data/lib/gs_graph/connections/notes.rb +21 -0
- data/lib/gs_graph/connections/notifications.rb +18 -0
- data/lib/gs_graph/connections/offers.rb +22 -0
- data/lib/gs_graph/connections/outbox.rb +20 -0
- data/lib/gs_graph/connections/participants.rb +14 -0
- data/lib/gs_graph/connections/payments.rb +14 -0
- data/lib/gs_graph/connections/permissions.rb +16 -0
- data/lib/gs_graph/connections/photos.rb +21 -0
- data/lib/gs_graph/connections/picture.rb +39 -0
- data/lib/gs_graph/connections/pokes.rb +12 -0
- data/lib/gs_graph/connections/posts.rb +14 -0
- data/lib/gs_graph/connections/promotable_posts.rb +14 -0
- data/lib/gs_graph/connections/question_options.rb +14 -0
- data/lib/gs_graph/connections/questions.rb +22 -0
- data/lib/gs_graph/connections/reach_estimates.rb +12 -0
- data/lib/gs_graph/connections/roles.rb +36 -0
- data/lib/gs_graph/connections/scores.rb +22 -0
- data/lib/gs_graph/connections/senders.rb +14 -0
- data/lib/gs_graph/connections/settings.rb +65 -0
- data/lib/gs_graph/connections/statuses.rb +14 -0
- data/lib/gs_graph/connections/subscribed_to.rb +14 -0
- data/lib/gs_graph/connections/subscribers.rb +14 -0
- data/lib/gs_graph/connections/subscriptions.rb +53 -0
- data/lib/gs_graph/connections/tabs.rb +23 -0
- data/lib/gs_graph/connections/tagged.rb +14 -0
- data/lib/gs_graph/connections/tags.rb +23 -0
- data/lib/gs_graph/connections/television.rb +14 -0
- data/lib/gs_graph/connections/test_users.rb +19 -0
- data/lib/gs_graph/connections/threads.rb +14 -0
- data/lib/gs_graph/connections/user_achievements.rb +22 -0
- data/lib/gs_graph/connections/user_likes.rb +19 -0
- data/lib/gs_graph/connections/videos.rb +21 -0
- data/lib/gs_graph/connections/votes.rb +9 -0
- data/lib/gs_graph/cover.rb +10 -0
- data/lib/gs_graph/debugger.rb +28 -0
- data/lib/gs_graph/device.rb +11 -0
- data/lib/gs_graph/doc.rb +18 -0
- data/lib/gs_graph/domain.rb +32 -0
- data/lib/gs_graph/education.rb +32 -0
- data/lib/gs_graph/event.rb +52 -0
- data/lib/gs_graph/exception.rb +139 -0
- data/lib/gs_graph/friend_list.rb +13 -0
- data/lib/gs_graph/friend_request.rb +14 -0
- data/lib/gs_graph/group.rb +29 -0
- data/lib/gs_graph/image.rb +11 -0
- data/lib/gs_graph/insight.rb +13 -0
- data/lib/gs_graph/klass.rb +31 -0
- data/lib/gs_graph/link.rb +32 -0
- data/lib/gs_graph/location.rb +20 -0
- data/lib/gs_graph/message.rb +30 -0
- data/lib/gs_graph/milestone.rb +26 -0
- data/lib/gs_graph/node.rb +149 -0
- data/lib/gs_graph/note.rb +32 -0
- data/lib/gs_graph/notification.rb +32 -0
- data/lib/gs_graph/offer.rb +33 -0
- data/lib/gs_graph/open_graph.rb +3 -0
- data/lib/gs_graph/open_graph/action.rb +42 -0
- data/lib/gs_graph/open_graph/application_context.rb +10 -0
- data/lib/gs_graph/open_graph/object.rb +29 -0
- data/lib/gs_graph/open_graph/user_context.rb +21 -0
- data/lib/gs_graph/order.rb +55 -0
- data/lib/gs_graph/page.rb +57 -0
- data/lib/gs_graph/page/category_attributes.rb +117 -0
- data/lib/gs_graph/photo.rb +48 -0
- data/lib/gs_graph/picture.rb +14 -0
- data/lib/gs_graph/place.rb +7 -0
- data/lib/gs_graph/poke.rb +19 -0
- data/lib/gs_graph/post.rb +117 -0
- data/lib/gs_graph/privacy.rb +27 -0
- data/lib/gs_graph/project.rb +4 -0
- data/lib/gs_graph/promotable_post.rb +34 -0
- data/lib/gs_graph/property.rb +13 -0
- data/lib/gs_graph/query.rb +47 -0
- data/lib/gs_graph/question.rb +26 -0
- data/lib/gs_graph/question_option.rb +22 -0
- data/lib/gs_graph/reach_estimate.rb +22 -0
- data/lib/gs_graph/role.rb +13 -0
- data/lib/gs_graph/score.rb +16 -0
- data/lib/gs_graph/searchable.rb +33 -0
- data/lib/gs_graph/searchable/result.rb +31 -0
- data/lib/gs_graph/serialization.rb +19 -0
- data/lib/gs_graph/status.rb +27 -0
- data/lib/gs_graph/subscription.rb +14 -0
- data/lib/gs_graph/tab.rb +17 -0
- data/lib/gs_graph/tag.rb +30 -0
- data/lib/gs_graph/tagged_object.rb +23 -0
- data/lib/gs_graph/targeting.rb +23 -0
- data/lib/gs_graph/test_user.rb +24 -0
- data/lib/gs_graph/thread.rb +71 -0
- data/lib/gs_graph/user.rb +153 -0
- data/lib/gs_graph/user_achievement.rb +35 -0
- data/lib/gs_graph/venue.rb +14 -0
- data/lib/gs_graph/video.rb +41 -0
- data/lib/gs_graph/work.rb +48 -0
- data/lib/patch/rack/oauth2/access_token.rb +11 -0
- data/lib/patch/rack/oauth2/access_token/introspectable.rb +37 -0
- data/lib/patch/rack/oauth2/client.rb +13 -0
- data/lib/patch/rack/oauth2/grant/fb_exchange_token.rb +11 -0
- data/lib/patch/rack/oauth2/util.rb +14 -0
- data/spec/gs_graph/achievement_spec.rb +59 -0
- data/spec/gs_graph/ad_account_spec.rb +124 -0
- data/spec/gs_graph/ad_campaign_spec.rb +99 -0
- data/spec/gs_graph/ad_connection_object_spec.rb +71 -0
- data/spec/gs_graph/ad_creative_spec.rb +87 -0
- data/spec/gs_graph/ad_group_spec.rb +95 -0
- data/spec/gs_graph/ad_keyword_spec.rb +27 -0
- data/spec/gs_graph/ad_keyword_suggestion_spec.rb +17 -0
- data/spec/gs_graph/ad_keyword_valid_spec.rb +19 -0
- data/spec/gs_graph/ad_user_spec.rb +67 -0
- data/spec/gs_graph/album_spec.rb +93 -0
- data/spec/gs_graph/app_request_spec.rb +40 -0
- data/spec/gs_graph/application_spec.rb +251 -0
- data/spec/gs_graph/auth/cookie_spec.rb +29 -0
- data/spec/gs_graph/auth/signed_request_spec.rb +22 -0
- data/spec/gs_graph/auth_spec.rb +223 -0
- data/spec/gs_graph/broad_targeting_category_spec.rb +17 -0
- data/spec/gs_graph/checkin_spec.rb +42 -0
- data/spec/gs_graph/collection_spec.rb +50 -0
- data/spec/gs_graph/comment_spec.rb +31 -0
- data/spec/gs_graph/connection_spec.rb +42 -0
- data/spec/gs_graph/connections/accounts_spec.rb +78 -0
- data/spec/gs_graph/connections/achievements_spec.rb +27 -0
- data/spec/gs_graph/connections/activities_spec.rb +34 -0
- data/spec/gs_graph/connections/ad_accounts_spec.rb +28 -0
- data/spec/gs_graph/connections/ad_campaign_stat_spec.rb +35 -0
- data/spec/gs_graph/connections/ad_campaigns_spec.rb +36 -0
- data/spec/gs_graph/connections/ad_connection_objects_spec.rb +20 -0
- data/spec/gs_graph/connections/ad_creatives_spec.rb +29 -0
- data/spec/gs_graph/connections/ad_group_stat_spec.rb +54 -0
- data/spec/gs_graph/connections/ad_groups_spec.rb +92 -0
- data/spec/gs_graph/connections/ad_previews_spec.rb +18 -0
- data/spec/gs_graph/connections/admins_spec.rb +20 -0
- data/spec/gs_graph/connections/albums_spec.rb +63 -0
- data/spec/gs_graph/connections/app_notifications_spec.rb +23 -0
- data/spec/gs_graph/connections/app_requests_spec.rb +28 -0
- data/spec/gs_graph/connections/attending_spec.rb +47 -0
- data/spec/gs_graph/connections/banned_spec.rb +63 -0
- data/spec/gs_graph/connections/blocked_spec.rb +56 -0
- data/spec/gs_graph/connections/books_spec.rb +32 -0
- data/spec/gs_graph/connections/broad_targeting_categories_spec.rb +18 -0
- data/spec/gs_graph/connections/checkins_spec.rb +153 -0
- data/spec/gs_graph/connections/comments_spec.rb +75 -0
- data/spec/gs_graph/connections/conversations_spec.rb +19 -0
- data/spec/gs_graph/connections/declined_spec.rb +47 -0
- data/spec/gs_graph/connections/docs_spec.rb +14 -0
- data/spec/gs_graph/connections/events_spec.rb +52 -0
- data/spec/gs_graph/connections/family_spec.rb +32 -0
- data/spec/gs_graph/connections/feed_spec.rb +124 -0
- data/spec/gs_graph/connections/former_participants_spec.rb +44 -0
- data/spec/gs_graph/connections/friend_lists_spec.rb +26 -0
- data/spec/gs_graph/connections/friend_requests_spec.rb +16 -0
- data/spec/gs_graph/connections/friends_spec.rb +51 -0
- data/spec/gs_graph/connections/games_spec.rb +20 -0
- data/spec/gs_graph/connections/groups_spec.rb +31 -0
- data/spec/gs_graph/connections/home_spec.rb +62 -0
- data/spec/gs_graph/connections/inbox_spec.rb +16 -0
- data/spec/gs_graph/connections/insights_spec.rb +104 -0
- data/spec/gs_graph/connections/interests_spec.rb +12 -0
- data/spec/gs_graph/connections/invited_spec.rb +84 -0
- data/spec/gs_graph/connections/likes_spec.rb +127 -0
- data/spec/gs_graph/connections/links_spec.rb +31 -0
- data/spec/gs_graph/connections/maybe_spec.rb +47 -0
- data/spec/gs_graph/connections/members_spec.rb +57 -0
- data/spec/gs_graph/connections/messages_spec.rb +58 -0
- data/spec/gs_graph/connections/milestones_spec.rb +40 -0
- data/spec/gs_graph/connections/movies_spec.rb +12 -0
- data/spec/gs_graph/connections/music_spec.rb +12 -0
- data/spec/gs_graph/connections/mutual_friends_spec.rb +28 -0
- data/spec/gs_graph/connections/noreply_spec.rb +39 -0
- data/spec/gs_graph/connections/notes_spec.rb +31 -0
- data/spec/gs_graph/connections/notifications_spec.rb +30 -0
- data/spec/gs_graph/connections/outbox_spec.rb +16 -0
- data/spec/gs_graph/connections/participants_spec.rb +42 -0
- data/spec/gs_graph/connections/payments_spec.rb +17 -0
- data/spec/gs_graph/connections/permissions_spec.rb +44 -0
- data/spec/gs_graph/connections/photos_spec.rb +39 -0
- data/spec/gs_graph/connections/picture_spec.rb +92 -0
- data/spec/gs_graph/connections/pokes_spec.rb +16 -0
- data/spec/gs_graph/connections/posts_spec.rb +34 -0
- data/spec/gs_graph/connections/promotable_posts_spec.rb +24 -0
- data/spec/gs_graph/connections/question_options_spec.rb +14 -0
- data/spec/gs_graph/connections/questions_spec.rb +31 -0
- data/spec/gs_graph/connections/reach_estimates_spec.rb +18 -0
- data/spec/gs_graph/connections/roles_spec.rb +59 -0
- data/spec/gs_graph/connections/scores_spec.rb +40 -0
- data/spec/gs_graph/connections/senders_spec.rb +42 -0
- data/spec/gs_graph/connections/settings_spec.rb +62 -0
- data/spec/gs_graph/connections/statuses_spec.rb +72 -0
- data/spec/gs_graph/connections/subscribed_to_spec.rb +12 -0
- data/spec/gs_graph/connections/subscribers_spec.rb +12 -0
- data/spec/gs_graph/connections/subscriptions_spec.rb +47 -0
- data/spec/gs_graph/connections/tabs_spec.rb +47 -0
- data/spec/gs_graph/connections/tagged_spec.rb +42 -0
- data/spec/gs_graph/connections/tags_spec.rb +30 -0
- data/spec/gs_graph/connections/television_spec.rb +12 -0
- data/spec/gs_graph/connections/test_users_spec.rb +65 -0
- data/spec/gs_graph/connections/threads_spec.rb +12 -0
- data/spec/gs_graph/connections/user_achievements_spec.rb +37 -0
- data/spec/gs_graph/connections/user_likes_spec.rb +55 -0
- data/spec/gs_graph/connections/videos_spec.rb +27 -0
- data/spec/gs_graph/connections/votes_spec.rb +15 -0
- data/spec/gs_graph/debugger_spec.rb +33 -0
- data/spec/gs_graph/doc_spec.rb +27 -0
- data/spec/gs_graph/domain_spec.rb +23 -0
- data/spec/gs_graph/education_spec.rb +61 -0
- data/spec/gs_graph/event_spec.rb +70 -0
- data/spec/gs_graph/exception_spec.rb +310 -0
- data/spec/gs_graph/friend_list_spec.rb +22 -0
- data/spec/gs_graph/group_spec.rb +28 -0
- data/spec/gs_graph/image_spec.rb +16 -0
- data/spec/gs_graph/insight_spec.rb +18 -0
- data/spec/gs_graph/link_spec.rb +41 -0
- data/spec/gs_graph/location_spec.rb +28 -0
- data/spec/gs_graph/message_spec.rb +47 -0
- data/spec/gs_graph/node_spec.rb +91 -0
- data/spec/gs_graph/note_spec.rb +37 -0
- data/spec/gs_graph/notification_spec.rb +59 -0
- data/spec/gs_graph/offer_spec.rb +30 -0
- data/spec/gs_graph/open_graph/action_spec.rb +112 -0
- data/spec/gs_graph/open_graph/application_context_spec.rb +28 -0
- data/spec/gs_graph/open_graph/object_spec.rb +76 -0
- data/spec/gs_graph/open_graph/user_context_spec.rb +33 -0
- data/spec/gs_graph/order_spec.rb +66 -0
- data/spec/gs_graph/page/local_business_spec.rb +88 -0
- data/spec/gs_graph/page/movie_spec.rb +25 -0
- data/spec/gs_graph/page/music_spec.rb +25 -0
- data/spec/gs_graph/page/person_spec.rb +23 -0
- data/spec/gs_graph/page/product_spec.rb +36 -0
- data/spec/gs_graph/page_spec.rb +81 -0
- data/spec/gs_graph/photo_spec.rb +85 -0
- data/spec/gs_graph/place_spec.rb +8 -0
- data/spec/gs_graph/post_spec.rb +238 -0
- data/spec/gs_graph/privacy_spec.rb +33 -0
- data/spec/gs_graph/project_spec.rb +46 -0
- data/spec/gs_graph/promotable_post_spec.rb +57 -0
- data/spec/gs_graph/qeustion_option_spec.rb +35 -0
- data/spec/gs_graph/query_spec.rb +73 -0
- data/spec/gs_graph/question_spec.rb +73 -0
- data/spec/gs_graph/reach_estimate_spec.rb +48 -0
- data/spec/gs_graph/searchable_spec.rb +47 -0
- data/spec/gs_graph/seriarization_spec.rb +29 -0
- data/spec/gs_graph/status_spec.rb +31 -0
- data/spec/gs_graph/subscription_spec.rb +5 -0
- data/spec/gs_graph/tag_spec.rb +34 -0
- data/spec/gs_graph/tagged_object_spec.rb +45 -0
- data/spec/gs_graph/targeting_spec.rb +34 -0
- data/spec/gs_graph/test_user_spec.rb +50 -0
- data/spec/gs_graph/thread_spec.rb +86 -0
- data/spec/gs_graph/user_achievement_spec.rb +53 -0
- data/spec/gs_graph/user_spec.rb +185 -0
- data/spec/gs_graph/venue_spec.rb +23 -0
- data/spec/gs_graph/video_spec.rb +31 -0
- data/spec/gs_graph/work_spec.rb +101 -0
- data/spec/gs_graph_spec.rb +57 -0
- data/spec/spec_helper.rb +9 -0
- metadata +538 -0
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GSGraph::QuestionOption do
|
4
|
+
|
5
|
+
describe '.new' do
|
6
|
+
it 'should setup all supported attributes' do
|
7
|
+
attributes = {
|
8
|
+
:id => '12345',
|
9
|
+
:from => {
|
10
|
+
:id => '23456',
|
11
|
+
:name => 'Mahmoud Khaled'
|
12
|
+
},
|
13
|
+
:name => 'option 1',
|
14
|
+
:votes => 5,
|
15
|
+
:object => {:name => "Ruby programming language",
|
16
|
+
:category => "Interest",
|
17
|
+
:id => "109932262369283"
|
18
|
+
},
|
19
|
+
:created_time => '2009-12-29T15:24:50+0000'
|
20
|
+
}
|
21
|
+
question = GSGraph::QuestionOption.new(attributes.delete(:id), attributes)
|
22
|
+
question.identifier.should == '12345'
|
23
|
+
question.from.should == GSGraph::User.new('23456', :name => 'Mahmoud Khaled')
|
24
|
+
question.name.should == 'option 1'
|
25
|
+
question.vote_count.should == 5
|
26
|
+
question.object.should be_instance_of(GSGraph::Page)
|
27
|
+
question.object.name.should == "Ruby programming language"
|
28
|
+
question.object.category.should == "Interest"
|
29
|
+
question.object.identifier.should == "109932262369283"
|
30
|
+
question.created_time.should == Time.parse('2009-12-29T15:24:50+0000')
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GSGraph::Query do
|
4
|
+
let(:raw_query) { 'SELECT name FROM user WHERE uid = me()' }
|
5
|
+
|
6
|
+
describe '.new' do
|
7
|
+
let(:query) { GSGraph::Query.new(raw_query, 'access_token') }
|
8
|
+
|
9
|
+
it 'should setup query and access_token' do
|
10
|
+
query.query.should == raw_query
|
11
|
+
query.access_token.should == 'access_token'
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '.fetch' do
|
16
|
+
let(:query) { GSGraph::Query.new(raw_query) }
|
17
|
+
|
18
|
+
context 'when no access token given' do
|
19
|
+
it 'should return blank Array' do
|
20
|
+
mock_fql raw_query, 'query/user/without_token' do
|
21
|
+
response = query.fetch
|
22
|
+
response.should == []
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context 'when invalid access token given' do
|
28
|
+
it 'should raise exception' do
|
29
|
+
mock_fql raw_query, 'query/user/with_invalid_token', :access_token => 'invalid', :status => [400, 'Bad Request'] do
|
30
|
+
lambda do
|
31
|
+
query.fetch('invalid')
|
32
|
+
end.should raise_error GSGraph::Exception
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context 'when valid access token given' do
|
38
|
+
it 'should return an Collection of Hash' do
|
39
|
+
mock_fql raw_query, 'query/user/with_valid_token', :access_token => 'valid' do
|
40
|
+
response = query.fetch('valid')
|
41
|
+
response.should be_instance_of GSGraph::Collection
|
42
|
+
response.should == [{'name' => 'Nov Matake'}]
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
context 'when multiquery given' do
|
48
|
+
let(:raw_query) do
|
49
|
+
{
|
50
|
+
:query1 => 'SELECT name FROM user WHERE uid = me()',
|
51
|
+
:query2 => 'SELECT name FROM user WHERE uid = me()'
|
52
|
+
}
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'should return an Hash of Array of Hash' do
|
56
|
+
mock_fql raw_query.to_json, 'query/user/multi_query', :access_token => 'valid' do
|
57
|
+
response = query.fetch('valid')
|
58
|
+
response.should be_instance_of ActiveSupport::HashWithIndifferentAccess
|
59
|
+
response.each do |key, value|
|
60
|
+
value.should be_instance_of Array
|
61
|
+
value.each do |result|
|
62
|
+
result.should be_instance_of ActiveSupport::HashWithIndifferentAccess
|
63
|
+
end
|
64
|
+
end
|
65
|
+
response.should == {
|
66
|
+
"query1" => [{"name" => "Nov Matake"}],
|
67
|
+
"query2" => [{"name" => "Nov Matake"}]
|
68
|
+
}
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GSGraph::Question do
|
4
|
+
|
5
|
+
describe '.new' do
|
6
|
+
it 'should setup all supported attributes' do
|
7
|
+
attributes = {
|
8
|
+
:id => '12345',
|
9
|
+
:from => {
|
10
|
+
:id => '23456',
|
11
|
+
:name => 'Mahmoud Khaled'
|
12
|
+
},
|
13
|
+
:question => 'question 1',
|
14
|
+
:created_time => '2009-12-29T15:24:50+0000',
|
15
|
+
:updated_time => '2010-01-02T15:37:41+0000',
|
16
|
+
:options => {
|
17
|
+
:data => [
|
18
|
+
{
|
19
|
+
:id => "34567",
|
20
|
+
:from => {
|
21
|
+
:name => "Mahmoud Khaled",
|
22
|
+
:id => "23456"
|
23
|
+
},
|
24
|
+
:name => "option 1",
|
25
|
+
:votes => 2,
|
26
|
+
:created_time => "2011-11-07T19:49:51+0000"
|
27
|
+
},
|
28
|
+
{
|
29
|
+
:id => "34568",
|
30
|
+
:from => {
|
31
|
+
:name => "Mustafa Badawy",
|
32
|
+
:id => "23457"
|
33
|
+
},
|
34
|
+
:name => "option 2",
|
35
|
+
:votes => 0,
|
36
|
+
:created_time => "2011-11-07T19:49:48+0000"
|
37
|
+
}
|
38
|
+
]
|
39
|
+
}
|
40
|
+
}
|
41
|
+
question = GSGraph::Question.new(attributes.delete(:id), attributes)
|
42
|
+
question.identifier.should == '12345'
|
43
|
+
question.from.should == GSGraph::User.new('23456', :name => 'Mahmoud Khaled')
|
44
|
+
question.question.should == 'question 1'
|
45
|
+
question.created_time.should == Time.parse('2009-12-29T15:24:50+0000')
|
46
|
+
question.updated_time.should == Time.parse('2010-01-02T15:37:41+0000')
|
47
|
+
question.question_options.should == [
|
48
|
+
GSGraph::QuestionOption.new(
|
49
|
+
'34567',
|
50
|
+
:from => {
|
51
|
+
:id => '23456',
|
52
|
+
:name => 'Mahmoud Khaled',
|
53
|
+
},
|
54
|
+
:name => "option 1",
|
55
|
+
:votes => 2,
|
56
|
+
:created_time => "2011-11-07T19:49:51+0000"
|
57
|
+
),
|
58
|
+
GSGraph::QuestionOption.new(
|
59
|
+
'34568',
|
60
|
+
:from => {
|
61
|
+
:id => '23457',
|
62
|
+
:name => 'Mustafa Badawy',
|
63
|
+
},
|
64
|
+
:name => "option 2",
|
65
|
+
:votes => 0,
|
66
|
+
:created_time => "2011-11-07T19:49:48+0000"
|
67
|
+
)
|
68
|
+
]
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GSGraph::ReachEstimate, '.new' do
|
4
|
+
let(:attributes) {
|
5
|
+
{
|
6
|
+
:users => 5503300,
|
7
|
+
:bid_estimations => [
|
8
|
+
{
|
9
|
+
:location => 3,
|
10
|
+
:cpc_min => 27,
|
11
|
+
:cpc_median => 37,
|
12
|
+
:cpc_max => 48,
|
13
|
+
:cpm_min => 8,
|
14
|
+
:cpm_median => 11,
|
15
|
+
:cpm_max => 14
|
16
|
+
}
|
17
|
+
],
|
18
|
+
:imp_estimates => []
|
19
|
+
}
|
20
|
+
}
|
21
|
+
|
22
|
+
let(:attributes_through_ad_group) {
|
23
|
+
{
|
24
|
+
:data => attributes
|
25
|
+
}
|
26
|
+
}
|
27
|
+
it 'should setup all supported attributes' do
|
28
|
+
estimate = GSGraph::ReachEstimate.new(attributes)
|
29
|
+
estimate.users.should == 5503300
|
30
|
+
estimate.cpc_min.should == 27
|
31
|
+
estimate.cpc_median.should == 37
|
32
|
+
estimate.cpc_max.should == 48
|
33
|
+
estimate.cpm_min.should == 8
|
34
|
+
estimate.cpm_median.should == 11
|
35
|
+
estimate.cpm_max.should == 14
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'should setup all supported attributes through AdGroup' do
|
39
|
+
estimate = GSGraph::ReachEstimate.new(attributes_through_ad_group)
|
40
|
+
estimate.users.should == 5503300
|
41
|
+
estimate.cpc_min.should == 27
|
42
|
+
estimate.cpc_median.should == 37
|
43
|
+
estimate.cpc_max.should == 48
|
44
|
+
estimate.cpm_min.should == 8
|
45
|
+
estimate.cpm_median.should == 11
|
46
|
+
estimate.cpm_max.should == 14
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GSGraph::Searchable do
|
4
|
+
describe '.search' do
|
5
|
+
context 'when included by GSGraph::Page' do
|
6
|
+
it 'should with type=page' do
|
7
|
+
lambda do
|
8
|
+
GSGraph::Searchable.search('GSGraph')
|
9
|
+
end.should request_to('search?q=GSGraph')
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe '#search' do
|
15
|
+
context 'when included by GSGraph::Page' do
|
16
|
+
it 'should with type=page' do
|
17
|
+
lambda do
|
18
|
+
GSGraph::Page.search('GSGraph')
|
19
|
+
end.should request_to('search?q=GSGraph&type=page')
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe GSGraph::Searchable::Result do
|
26
|
+
let :gs_graph do
|
27
|
+
mock_graph :get, 'search?q=fbgraph&type=page', 'pages/search_gs_graph' do
|
28
|
+
GSGraph::Page.search('fbgraph')
|
29
|
+
end
|
30
|
+
end
|
31
|
+
let :google_page2 do
|
32
|
+
mock_graph :get, 'search?limit=25&offset=25&q=google&type=page', 'pages/search_google' do
|
33
|
+
GSGraph::Page.search('google', :limit => 25, :offset => 25)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'should support pagination' do
|
38
|
+
gs_graph.next.should == []
|
39
|
+
gs_graph.previous.should == []
|
40
|
+
lambda do
|
41
|
+
google_page2.next
|
42
|
+
end.should request_to('search?limit=25&offset=50&q=google&type=page')
|
43
|
+
lambda do
|
44
|
+
google_page2.previous
|
45
|
+
end.should request_to('search?limit=25&offset=0&q=google&type=page')
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
class Klass1
|
4
|
+
include GSGraph::Serialization
|
5
|
+
attr_accessor :att1, :att2
|
6
|
+
end
|
7
|
+
|
8
|
+
class Klass2 < Klass1
|
9
|
+
def to_hash(options = {})
|
10
|
+
{:att1 => self.att1, :att2 => self.att2}
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe GSGraph::Serialization do
|
15
|
+
before do
|
16
|
+
@node1 = Klass1.new
|
17
|
+
@node2 = Klass2.new
|
18
|
+
@node1.att1 = "hello"
|
19
|
+
@node2.att1 = "hello"
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'should require to_hash' do
|
23
|
+
lambda do
|
24
|
+
@node1.to_json
|
25
|
+
end.should raise_error(StandardError, 'Define Klass1#to_hash!')
|
26
|
+
@node2.to_hash == {:att1 => 'hello', :att2 => nil}
|
27
|
+
@node2.to_json == {:att1 => 'hello'}.to_json
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GSGraph::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 = GSGraph::Status.new(attributes.delete(:id), attributes)
|
16
|
+
status.identifier.should == '12345'
|
17
|
+
status.from.should == GSGraph::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 = GSGraph::Status.new('12345', :from => {
|
24
|
+
:id => '23456',
|
25
|
+
:name => 'Smart.fm',
|
26
|
+
:category => 'Web Site'
|
27
|
+
})
|
28
|
+
page_status.from.should == GSGraph::Page.new('23456', :name => 'Smart.fm', :category => 'Web Site')
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GSGraph::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 = GSGraph::Tag.new(attributes)
|
14
|
+
tag.user.should == GSGraph::User.new('7901103', :name => "Arjun Banker")
|
15
|
+
tag.name.should == 'Arjun Banker'
|
16
|
+
tag.x.should == 32.5
|
17
|
+
tag.y.should == 27.7778
|
18
|
+
tag.created_time.should == Time.parse("2010-04-22T08:24:26+0000")
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'should not setup user if id is blank' do
|
22
|
+
attributes = {
|
23
|
+
:id => "",
|
24
|
+
:name => "Arjun Banker",
|
25
|
+
:x => 32.5,
|
26
|
+
:y => 27.7778,
|
27
|
+
:created_time => "2010-04-22T08:24:26+0000"
|
28
|
+
}
|
29
|
+
tag = GSGraph::Tag.new(attributes)
|
30
|
+
tag.user.should be_nil
|
31
|
+
tag.name.should == 'Arjun Banker'
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GSGraph::TaggedObject do
|
4
|
+
let :attributes do
|
5
|
+
MultiJson.load(json).with_indifferent_access
|
6
|
+
end
|
7
|
+
let :json do
|
8
|
+
<<-JSON
|
9
|
+
{
|
10
|
+
"id": "1575327134",
|
11
|
+
"name": "Jr Nov",
|
12
|
+
"offset": 43,
|
13
|
+
"length": 6
|
14
|
+
}
|
15
|
+
JSON
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should setup all supported attributes' do
|
19
|
+
tagged_object = GSGraph::TaggedObject.new attributes[:id], attributes
|
20
|
+
tagged_object.identifier.should == '1575327134'
|
21
|
+
tagged_object.name.should == 'Jr Nov'
|
22
|
+
tagged_object.offset.should == 43
|
23
|
+
tagged_object.length.should == 6
|
24
|
+
end
|
25
|
+
|
26
|
+
describe '#fetch' do
|
27
|
+
context 'when tagged object is an User' do
|
28
|
+
it 'should return User' do
|
29
|
+
mock_graph :get, 'object_id', 'users/arjun_public' do
|
30
|
+
object = GSGraph::TaggedObject.new('object_id').fetch
|
31
|
+
object.should be_instance_of GSGraph::User
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
context 'when tagged object is a Page' do
|
37
|
+
it 'should return Page' do
|
38
|
+
mock_graph :get, 'object_id', 'pages/platform_public' do
|
39
|
+
object = GSGraph::TaggedObject.new('object_id').fetch
|
40
|
+
object.should be_instance_of GSGraph::Page
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GSGraph::Targeting, '.new' do
|
4
|
+
it 'should setup all supported attributes' do
|
5
|
+
attributes = {
|
6
|
+
:country => 'jp',
|
7
|
+
:city => 'Tokyo',
|
8
|
+
:region => 'Tokyo',
|
9
|
+
:locale => 9
|
10
|
+
}
|
11
|
+
targeting = GSGraph::Targeting.new(attributes)
|
12
|
+
targeting.country.should == 'jp'
|
13
|
+
targeting.city.should == 'Tokyo'
|
14
|
+
targeting.region.should == 'Tokyo'
|
15
|
+
targeting.locale.should == 9
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe GSGraph::Targeting, '.to_json' do
|
20
|
+
it 'should return JSON object' do
|
21
|
+
attributes = {
|
22
|
+
:country => 'jp',
|
23
|
+
:city => 'Tokyo',
|
24
|
+
:locale => 9,
|
25
|
+
:region => 'Tokyo'
|
26
|
+
}
|
27
|
+
targeting = GSGraph::Targeting.new(attributes)
|
28
|
+
hash = MultiJson.load(targeting.to_json).with_indifferent_access
|
29
|
+
hash[:country].should == attributes[:country]
|
30
|
+
hash[:city].should == attributes[:city]
|
31
|
+
hash[:locale].should == attributes[:locale]
|
32
|
+
hash[:region].should == attributes[:region]
|
33
|
+
end
|
34
|
+
end
|