1
0
Fork 0
mirror of https://github.com/nov/fb_graph2 synced 2023-03-27 23:22:15 -04:00

more specs

This commit is contained in:
nov 2014-06-03 15:25:04 +09:00
parent faff7034ba
commit b11bf90f35
13 changed files with 222 additions and 3 deletions

View file

@ -39,7 +39,12 @@ module FbGraph2
def initialize(id, attributes = {})
super
# TODO: handle custom attributes.
if attributes.include? :category_list
attributes[:category_list].collect do |page_category|
PageCategory.new page_category[:id], page_category
end
end
# TODO: handle other custom attributes.
end
end
end

View file

@ -0,0 +1,7 @@
module FbGraph2
class PageCategory < Node
register_attributes(
raw: [:name]
)
end
end

View file

@ -0,0 +1,18 @@
require 'spec_helper'
describe FbGraph2::Edge::Books do
context 'included in User' do
describe '#books' do
let(:me) { FbGraph2::User.me('token') }
it 'should return an Array of FbGraph2::Page with page token' do
pages = mock_graph :get, 'me/books', 'user/books', access_token: 'token' do
me.books
end
pages.should_not be_blank
pages.each do |page|
page.should be_instance_of FbGraph2::Page
end
end
end
end
end

View file

@ -0,0 +1,18 @@
require 'spec_helper'
describe FbGraph2::Edge::Interests do
context 'included in User' do
describe '#interests' do
let(:me) { FbGraph2::User.me('token') }
it 'should return an Array of FbGraph2::Page with page token' do
pages = mock_graph :get, 'me/interests', 'user/interests', access_token: 'token' do
me.interests
end
pages.should_not be_blank
pages.each do |page|
page.should be_instance_of FbGraph2::Page
end
end
end
end
end

View file

@ -0,0 +1,18 @@
require 'spec_helper'
describe FbGraph2::Edge::Movies do
context 'included in User' do
describe '#movies' do
let(:me) { FbGraph2::User.me('token') }
it 'should return an Array of FbGraph2::Page with page token' do
pages = mock_graph :get, 'me/movies', 'user/movies', access_token: 'token' do
me.movies
end
pages.should_not be_blank
pages.each do |page|
page.should be_instance_of FbGraph2::Page
end
end
end
end
end

View file

@ -0,0 +1,18 @@
require 'spec_helper'
describe FbGraph2::Edge::Music do
context 'included in User' do
describe '#music' do
let(:me) { FbGraph2::User.me('token') }
it 'should return an Array of FbGraph2::Page with page token' do
pages = mock_graph :get, 'me/music', 'user/music', access_token: 'token' do
me.music
end
pages.should_not be_blank
pages.each do |page|
page.should be_instance_of FbGraph2::Page
end
end
end
end
end

View file

@ -4,7 +4,6 @@ describe FbGraph2::Edge::Notifications do
context 'included in User' do
describe '#notifications' do
let(:me) { FbGraph2::User.me('token') }
it 'should return an Array of FbGraph2::Notification' do
notifications = mock_graph :get, 'me/notifications', 'user/notifications', access_token: 'token' do
me.notifications
@ -18,7 +17,6 @@ describe FbGraph2::Edge::Notifications do
describe '#notification!' do
let(:user) { FbGraph2::User.new('user_id') }
it 'should return true' do
mock_graph :post, 'user_id/notifications', 'success_true', access_token: 'app_token', params: {
href: 'href', template: 'template'

View file

@ -0,0 +1,18 @@
require 'spec_helper'
describe FbGraph2::Edge::Television do
context 'included in User' do
describe '#television' do
let(:me) { FbGraph2::User.me('token') }
it 'should return an Array of FbGraph2::Page with page token' do
pages = mock_graph :get, 'me/television', 'user/television', access_token: 'token' do
me.television
end
pages.should_not be_blank
pages.each do |page|
page.should be_instance_of FbGraph2::Page
end
end
end
end
end

View file

@ -0,0 +1,11 @@
{
"data": [{
"category": "Book",
"name": "Predictably Irrational",
"created_time": "2011-07-27T15:49:06+0000",
"id": "113167718696752"
}],
"paging": {
"next": "https://graph.facebook.com/v2.0/579612276/books?limit=25&offset=25&__after_id=enc_AewjHX22qV_-BoIxoRMWHPno7BxZHunbqYgaxlHlJnH0x_Gza1bYpFD6V7Vve1HL-21x7kD5E_3QMLzdjM9pmK_f"
}
}

View file

@ -0,0 +1,41 @@
{
"data": [{
"category": "Interest",
"name": "#idcon 14th ~ BYOResume or DEAD! ~",
"created_time": "2012-09-03T17:18:16+0000",
"id": "309562105809363"
}, {
"category": "Interest",
"name": "Heroku Meetup #6 Japan Heroku Lab",
"created_time": "2012-09-03T03:07:14+0000",
"id": "102424793243222"
}, {
"category": "Interest",
"name": "Activity Streams",
"created_time": "2011-06-30T22:57:47+0000",
"id": "114998808528822"
}, {
"category": "Company",
"name": "Social Web",
"created_time": "2011-06-18T02:52:35+0000",
"id": "105645299472577"
}, {
"category": "Interest",
"name": "Open ID",
"created_time": "2011-01-05T00:21:56+0000",
"id": "106260522746492"
}, {
"category": "Interest",
"name": "Open Social",
"created_time": "2011-01-05T00:21:52+0000",
"id": "107119605991729"
}, {
"category": "Interest",
"name": "OAuth",
"created_time": "2010-07-04T06:17:52+0000",
"id": "104064209632570"
}],
"paging": {
"next": "https://graph.facebook.com/v2.0/579612276/interests?limit=25&offset=25&__after_id=enc_AezLYldJHiKEyShbuOdR82cv0TtL4DwoXvFHvxocLB9dyJjlw96DIz3jwBNiERXgDjzAH_sT_ZhHU9QGJNxiOe3P"
}
}

View file

@ -0,0 +1,11 @@
{
"data": [{
"category": "Movie",
"name": "The Social Network",
"created_time": "2011-01-05T00:17:17+0000",
"id": "105460422821089"
}],
"paging": {
"next": "https://graph.facebook.com/v2.0/579612276/movies?limit=25&offset=25&__after_id=enc_AewDz_Z8KNKb51zhWhUMYOJjref9qTPZpk1jT2P9sAXIzWmNSJSUU56XyMbJASE2c8qPbE1-WoFS8o6eCgs6K4Ui"
}
}

View file

@ -0,0 +1,45 @@
{
"data": [{
"category": "Music",
"name": "斉藤和義",
"created_time": "2011-07-31T05:30:44+0000",
"id": "108827045813193"
}, {
"category": "Musician/band",
"name": "L'arc~en~Ciel",
"created_time": "2011-07-31T05:28:30+0000",
"id": "12039028077"
}, {
"category": "Musician/band",
"name": "Utada Hikaru",
"created_time": "2010-05-10T06:57:25+0000",
"id": "105806242793688"
}, {
"category": "Musician/band",
"category_list": [{
"id": "180164648685982",
"name": "Bands & Musicians"
}],
"name": "Avril Lavigne",
"created_time": "2009-01-22T18:03:07+0000",
"id": "5413509299"
}, {
"category": "Musician/band",
"name": "Bank Band",
"created_time": "2009-01-22T17:47:26+0000",
"id": "28534671472"
}, {
"category": "Musician/band",
"name": "The Yellow Monkey",
"created_time": "2009-01-22T17:36:46+0000",
"id": "32548904409"
}, {
"category": "Musician/band",
"name": "Mr. Children",
"created_time": "2009-01-22T17:36:26+0000",
"id": "27868140174"
}],
"paging": {
"next": "https://graph.facebook.com/v2.0/579612276/music?limit=25&offset=25&__after_id=enc_AeyVKBfCEuM8ZXcswQ4tW_IGxEZSp9qkwAdtOM37T5EWpk1I8POJ2Kn5tSqM2lWyx0Q"
}
}

View file

@ -0,0 +1,11 @@
{
"data": [{
"category": "Tv show",
"name": "Mobile Suit Zeta Gundam",
"created_time": "2014-06-03T06:08:35+0000",
"id": "105508046150348"
}],
"paging": {
"next": "https://graph.facebook.com/v2.0/579612276/television?limit=25&offset=25&__after_id=enc_AewK-s0422fW15xZjOu3LxDtrkej8NQumXBW2ugVt3EuK52YArNQIKzoyq72k0V_vQ3_DGUsIp7COPzF82p_h4BK"
}
}