fb_graph 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +26 -2
- data/VERSION +1 -1
- data/fb_graph.gemspec +41 -6
- data/lib/fb_graph/album.rb +1 -1
- data/lib/fb_graph/collection.rb +32 -0
- data/lib/fb_graph/comparison.rb +9 -0
- data/lib/fb_graph/connections/activities.rb +1 -1
- data/lib/fb_graph/connections/albums.rb +1 -1
- data/lib/fb_graph/connections/attending.rb +1 -1
- data/lib/fb_graph/connections/books.rb +1 -1
- data/lib/fb_graph/connections/comments.rb +1 -1
- data/lib/fb_graph/connections/declined.rb +1 -1
- data/lib/fb_graph/connections/events.rb +1 -1
- data/lib/fb_graph/connections/feed.rb +1 -1
- data/lib/fb_graph/connections/friends.rb +1 -1
- data/lib/fb_graph/connections/groups.rb +1 -1
- data/lib/fb_graph/connections/home.rb +1 -1
- data/lib/fb_graph/connections/interests.rb +1 -1
- data/lib/fb_graph/connections/invited.rb +1 -1
- data/lib/fb_graph/connections/likes.rb +1 -1
- data/lib/fb_graph/connections/links.rb +1 -1
- data/lib/fb_graph/connections/maybe.rb +1 -1
- data/lib/fb_graph/connections/members.rb +1 -1
- data/lib/fb_graph/connections/movies.rb +1 -1
- data/lib/fb_graph/connections/music.rb +1 -1
- data/lib/fb_graph/connections/noreply.rb +1 -1
- data/lib/fb_graph/connections/notes.rb +1 -1
- data/lib/fb_graph/connections/photos.rb +1 -1
- data/lib/fb_graph/connections/posts.rb +1 -1
- data/lib/fb_graph/connections/statuses.rb +1 -1
- data/lib/fb_graph/connections/tagged.rb +1 -1
- data/lib/fb_graph/connections/television.rb +1 -1
- data/lib/fb_graph/connections/videos.rb +1 -1
- data/lib/fb_graph/event.rb +3 -1
- data/lib/fb_graph/group.rb +4 -3
- data/lib/fb_graph/link.rb +1 -1
- data/lib/fb_graph/node.rb +6 -10
- data/lib/fb_graph/photo.rb +2 -12
- data/lib/fb_graph/post.rb +1 -1
- data/lib/fb_graph/tag.rb +14 -0
- data/lib/fb_graph/user.rb +2 -2
- data/lib/fb_graph/venue.rb +17 -0
- data/lib/fb_graph.rb +8 -1
- data/spec/fake_json/users/albums/matake_private.json +34 -0
- data/spec/fake_json/users/albums/matake_public.json +6 -0
- data/spec/fake_json/users/events/matake_private.json +71 -0
- data/spec/fake_json/users/events/matake_public.json +6 -0
- data/spec/fake_json/users/groups/matake_private.json +48 -0
- data/spec/fake_json/users/groups/matake_public.json +6 -0
- data/spec/fake_json/users/home/me_private.json +208 -131
- data/spec/fake_json/users/home/me_private_next.json +382 -0
- data/spec/fake_json/users/home/me_private_previous.json +36 -0
- data/spec/fb_graph/album_spec.rb +41 -0
- data/spec/fb_graph/collection_spec.rb +37 -0
- data/spec/fb_graph/connections/activities_spec.rb +4 -4
- data/spec/fb_graph/connections/albums_spec.rb +35 -0
- data/spec/fb_graph/connections/events_spec.rb +31 -0
- data/spec/fb_graph/connections/feed_spec.rb +2 -2
- data/spec/fb_graph/connections/friends_spec.rb +7 -7
- data/spec/fb_graph/connections/groups_spec.rb +28 -0
- data/spec/fb_graph/connections/home_spec.rb +13 -13
- data/spec/fb_graph/connections/likes_spec.rb +3 -3
- data/spec/fb_graph/connections/posts_spec.rb +2 -2
- data/spec/fb_graph/connections/statuses_spec.rb +6 -6
- data/spec/fb_graph/connections/tagged_spec.rb +2 -2
- data/spec/fb_graph/event_spec.rb +50 -0
- data/spec/fb_graph/group_spec.rb +46 -0
- data/spec/fb_graph/link_spec.rb +33 -0
- data/spec/fb_graph/node_spec.rb +3 -3
- data/spec/fb_graph/note_spec.rb +35 -0
- data/spec/fb_graph/page_spec.rb +3 -3
- data/spec/fb_graph/photo_spec.rb +58 -0
- data/spec/fb_graph/post_spec.rb +6 -0
- data/spec/fb_graph/status_spec.rb +31 -0
- data/spec/fb_graph/user_spec.rb +6 -6
- data/spec/fb_graph/video_spec.rb +37 -0
- metadata +41 -6
- data/lib/fb_graph/connections/collection.rb +0 -31
- data/spec/fb_graph/connections/collection_spec.rb +0 -15
@@ -0,0 +1,28 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '../../spec_helper')
|
2
|
+
|
3
|
+
describe FbGraph::Connections::Groups, '#groups' do
|
4
|
+
describe 'when included by FbGraph::User' do
|
5
|
+
before(:all) do
|
6
|
+
fake_json(:get, 'matake/groups', 'users/groups/matake_public')
|
7
|
+
fake_json(:get, 'matake/groups?token=token', 'users/groups/matake_private')
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'should raise FbGraph::Unauthorized when no token given' do
|
11
|
+
lambda do
|
12
|
+
FbGraph::User.new('matake').groups
|
13
|
+
end.should raise_exception(FbGraph::Unauthorized)
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should return public own posts even when token is not given' do
|
17
|
+
groups = FbGraph::User.new('matake', :token => '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)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
@@ -4,12 +4,12 @@ describe FbGraph::Connections::Home, '#home' do
|
|
4
4
|
describe 'when included by FbGraph::User' do
|
5
5
|
before(:all) do
|
6
6
|
fake_json(:get, 'me/home', 'users/home/me_public')
|
7
|
-
fake_json(:get, 'me/home?
|
7
|
+
fake_json(:get, 'me/home?token=token', 'users/home/me_private')
|
8
8
|
fake_json(:get, 'arjun/home', 'users/home/arjun_public')
|
9
|
-
fake_json(:get, 'arjun/home?
|
9
|
+
fake_json(:get, 'arjun/home?token=token', 'users/home/arjun_private')
|
10
10
|
end
|
11
11
|
|
12
|
-
it 'should raise FbGraph::Exception when no
|
12
|
+
it 'should raise FbGraph::Exception when no token given' do
|
13
13
|
lambda do
|
14
14
|
FbGraph::User.new('arjun').home
|
15
15
|
end.should raise_exception(FbGraph::Exception)
|
@@ -17,29 +17,29 @@ describe FbGraph::Connections::Home, '#home' do
|
|
17
17
|
|
18
18
|
it 'should raise FbGraph::Exception when identifier is not me' do
|
19
19
|
lambda do
|
20
|
-
FbGraph::User.new('arjun', :
|
20
|
+
FbGraph::User.new('arjun', :token => 'token').home
|
21
21
|
end.should raise_exception(FbGraph::Exception)
|
22
22
|
end
|
23
23
|
|
24
|
-
it 'should raise FbGraph::NotFound when identifier is me and no
|
24
|
+
it 'should raise FbGraph::NotFound when identifier is me and no token is given' do
|
25
25
|
lambda do
|
26
26
|
FbGraph::User.new('me').home
|
27
27
|
end.should raise_exception(FbGraph::NotFound)
|
28
28
|
end
|
29
29
|
|
30
|
-
it 'should return posts when identifier is me and
|
31
|
-
posts = FbGraph::User.new('me', :
|
30
|
+
it 'should return posts when identifier is me and token is given' do
|
31
|
+
posts = FbGraph::User.new('me', :token => 'token').home
|
32
32
|
posts.first.should == FbGraph::Post.new(
|
33
|
-
'
|
33
|
+
'634033380_112599768777073',
|
34
34
|
:from => {
|
35
|
-
:id => '
|
36
|
-
:name => '
|
35
|
+
:id => '634033380',
|
36
|
+
:name => 'nishikokura hironobu'
|
37
37
|
},
|
38
|
-
:message => "
|
38
|
+
:message => "こちらこそありがとうございました!僕はctrl+無変換ですwRT @_eskm: @pandeiro245 こないだの日曜はありがとうございました!面白い内容でした。ちなみにfnrirってCapsLockで起動ですが、英数変換と同じボタンでどうしてます?起動を違うボタンに変更",
|
39
39
|
:icon => 'http://photos-h.ak.fbcdn.net/photos-ak-sf2p/v43/23/2231777543/app_2_2231777543_2528.gif',
|
40
40
|
:attribution => 'Twitter',
|
41
|
-
:created_time => '2010-04-
|
42
|
-
:updated_time => '2010-04-
|
41
|
+
:created_time => '2010-04-27T13:06:14+0000',
|
42
|
+
:updated_time => '2010-04-27T13:06:14+0000'
|
43
43
|
)
|
44
44
|
posts.each do |post|
|
45
45
|
post.should be_instance_of(FbGraph::Post)
|
@@ -4,17 +4,17 @@ describe FbGraph::Connections::Likes, '#likes' do
|
|
4
4
|
describe 'when included by FbGraph::User' do
|
5
5
|
before(:all) do
|
6
6
|
fake_json(:get, 'arjun/likes', 'users/likes/arjun_public')
|
7
|
-
fake_json(:get, 'arjun/likes?
|
7
|
+
fake_json(:get, 'arjun/likes?token=token', 'users/likes/arjun_private')
|
8
8
|
end
|
9
9
|
|
10
|
-
it 'should raise FbGraph::Unauthorized when no
|
10
|
+
it 'should raise FbGraph::Unauthorized when no token given' do
|
11
11
|
lambda do
|
12
12
|
FbGraph::User.new('arjun').likes
|
13
13
|
end.should raise_exception(FbGraph::Unauthorized)
|
14
14
|
end
|
15
15
|
|
16
16
|
it 'should return liked pages' do
|
17
|
-
likes = FbGraph::User.new('arjun', :
|
17
|
+
likes = FbGraph::User.new('arjun', :token => 'token').likes
|
18
18
|
likes.first.should == FbGraph::Page.new(
|
19
19
|
'378209722137',
|
20
20
|
:name => 'Doing Things at the Last Minute',
|
@@ -4,10 +4,10 @@ describe FbGraph::Connections::Posts, '#posts' do
|
|
4
4
|
describe 'when included by FbGraph::User' do
|
5
5
|
before(:all) do
|
6
6
|
fake_json(:get, 'arjun/posts', 'users/posts/arjun_public')
|
7
|
-
fake_json(:get, 'arjun/posts?
|
7
|
+
fake_json(:get, 'arjun/posts?token=token', 'users/posts/arjun_private')
|
8
8
|
end
|
9
9
|
|
10
|
-
it 'should return public own posts even when
|
10
|
+
it 'should return public own posts even when token is not given' do
|
11
11
|
posts = FbGraph::User.new('arjun').posts
|
12
12
|
posts.first.should == FbGraph::Post.new(
|
13
13
|
'7901103_121392141207495',
|
@@ -5,17 +5,17 @@ describe FbGraph::Connections::Statuses, '#statuses' do
|
|
5
5
|
describe 'when included by FbGraph::User' do
|
6
6
|
before(:all) do
|
7
7
|
fake_json(:get, 'arjun/statuses', 'users/statuses/arjun_public')
|
8
|
-
fake_json(:get, 'arjun/statuses?
|
8
|
+
fake_json(:get, 'arjun/statuses?token=token', 'users/statuses/arjun_private')
|
9
9
|
end
|
10
10
|
|
11
|
-
it 'should raise FbGraph::Unauthorized when no
|
11
|
+
it 'should raise FbGraph::Unauthorized when no token given' do
|
12
12
|
lambda do
|
13
13
|
FbGraph::User.new('arjun').statuses
|
14
14
|
end.should raise_exception(FbGraph::Unauthorized)
|
15
15
|
end
|
16
16
|
|
17
17
|
it 'should return statuses' do
|
18
|
-
statuses = FbGraph::User.new('arjun', :
|
18
|
+
statuses = FbGraph::User.new('arjun', :token => 'token').statuses
|
19
19
|
statuses.first.should == FbGraph::Status.new(
|
20
20
|
'113559395341627',
|
21
21
|
:from => {
|
@@ -34,17 +34,17 @@ describe FbGraph::Connections::Statuses, '#statuses' do
|
|
34
34
|
describe 'when included by FbGraph::Page' do
|
35
35
|
before(:all) do
|
36
36
|
fake_json(:get, 'platform/statuses', 'pages/statuses/platform_public')
|
37
|
-
fake_json(:get, 'platform/statuses?
|
37
|
+
fake_json(:get, 'platform/statuses?token=token', 'pages/statuses/platform_private')
|
38
38
|
end
|
39
39
|
|
40
|
-
it 'should raise FbGraph::Unauthorized when no
|
40
|
+
it 'should raise FbGraph::Unauthorized when no token given' do
|
41
41
|
lambda do
|
42
42
|
FbGraph::Page.new('platform').statuses
|
43
43
|
end.should raise_exception(FbGraph::Unauthorized)
|
44
44
|
end
|
45
45
|
|
46
46
|
it 'should return statuses with pagination info' do
|
47
|
-
statuses = FbGraph::Page.new('platform', :
|
47
|
+
statuses = FbGraph::Page.new('platform', :token => 'token').statuses
|
48
48
|
statuses.first.should == FbGraph::Status.new(
|
49
49
|
'111081598927600',
|
50
50
|
:from => {
|
@@ -4,10 +4,10 @@ describe FbGraph::Connections::Tagged, '#tagged' do
|
|
4
4
|
describe 'when included by FbGraph::User' do
|
5
5
|
before(:all) do
|
6
6
|
fake_json(:get, 'arjun/tagged', 'users/tagged/arjun_public')
|
7
|
-
fake_json(:get, 'arjun/tagged?
|
7
|
+
fake_json(:get, 'arjun/tagged?token=token', 'users/tagged/arjun_private')
|
8
8
|
end
|
9
9
|
|
10
|
-
it 'should return public own posts even when
|
10
|
+
it 'should return public own posts even when token is not given' do
|
11
11
|
posts = FbGraph::User.new('arjun').tagged
|
12
12
|
posts.first.should == FbGraph::Post.new(
|
13
13
|
'7901103_117809521578252',
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '../spec_helper')
|
2
|
+
|
3
|
+
describe FbGraph::Event, '#new' do
|
4
|
+
|
5
|
+
it 'should setup all supported attributes' do
|
6
|
+
attributes = {
|
7
|
+
:id => '12345',
|
8
|
+
:owner => {
|
9
|
+
:id => '23456',
|
10
|
+
:name => 'nov matake'
|
11
|
+
},
|
12
|
+
:name => 'event 1',
|
13
|
+
:description => 'an event for fb_graph test',
|
14
|
+
:start_time => '2010-03-14T21:00:00+0000',
|
15
|
+
:end_time => '2010-03-15T00:30:00+0000',
|
16
|
+
:location => 'Smart.fm office',
|
17
|
+
:venue => {
|
18
|
+
:street => 'Sakuragaoka',
|
19
|
+
:city => 'Shibuya',
|
20
|
+
:state => 'Tokyo',
|
21
|
+
:zip => '150-0031',
|
22
|
+
:country => 'Japan',
|
23
|
+
:latitude => '35.685',
|
24
|
+
:longitude => '139.751'
|
25
|
+
},
|
26
|
+
:privacy => 'OPEN',
|
27
|
+
:updated_time => '2010-01-02T15:37:41+0000'
|
28
|
+
}
|
29
|
+
event = FbGraph::Event.new(attributes.delete(:id), attributes)
|
30
|
+
event.identifier.should == '12345'
|
31
|
+
event.owner.should == FbGraph::User.new('23456', :name => 'nov matake')
|
32
|
+
event.name.should == 'event 1'
|
33
|
+
event.description.should == 'an event for fb_graph test'
|
34
|
+
event.start_time.should == '2010-03-14T21:00:00+0000'
|
35
|
+
event.end_time.should == '2010-03-15T00:30:00+0000'
|
36
|
+
event.location.should == 'Smart.fm office'
|
37
|
+
event.venue.should == FbGraph::Venue.new(
|
38
|
+
:street => 'Sakuragaoka',
|
39
|
+
:city => 'Shibuya',
|
40
|
+
:state => 'Tokyo',
|
41
|
+
:zip => '150-0031',
|
42
|
+
:country => 'Japan',
|
43
|
+
:latitude => '35.685',
|
44
|
+
:longitude => '139.751'
|
45
|
+
)
|
46
|
+
event.privacy.should == 'OPEN'
|
47
|
+
event.updated_time.should == '2010-01-02T15:37:41+0000'
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '../spec_helper')
|
2
|
+
|
3
|
+
describe FbGraph::Group, '#new' do
|
4
|
+
|
5
|
+
it 'should setup all supported attributes' do
|
6
|
+
attributes = {
|
7
|
+
:id => '12345',
|
8
|
+
:owner => {
|
9
|
+
:id => '23456',
|
10
|
+
:name => 'nov matake'
|
11
|
+
},
|
12
|
+
:name => 'group 1',
|
13
|
+
:description => 'a group for fb_graph test',
|
14
|
+
:link => 'http://www.facebook.com/group/12345',
|
15
|
+
:venue => {
|
16
|
+
:street => 'Sakuragaoka',
|
17
|
+
:city => 'Shibuya',
|
18
|
+
:state => 'Tokyo',
|
19
|
+
:zip => '150-0031',
|
20
|
+
:country => 'Japan',
|
21
|
+
:latitude => '35.685',
|
22
|
+
:longitude => '139.751'
|
23
|
+
},
|
24
|
+
:privacy => 'OPEN',
|
25
|
+
:updated_time => '2010-01-02T15:37:41+0000'
|
26
|
+
}
|
27
|
+
group = FbGraph::Group.new(attributes.delete(:id), attributes)
|
28
|
+
group.identifier.should == '12345'
|
29
|
+
group.owner.should == FbGraph::User.new('23456', :name => 'nov matake')
|
30
|
+
group.name.should == 'group 1'
|
31
|
+
group.description.should == 'a group for fb_graph test'
|
32
|
+
group.link.should == 'http://www.facebook.com/group/12345'
|
33
|
+
group.venue.should == FbGraph::Venue.new(
|
34
|
+
:street => 'Sakuragaoka',
|
35
|
+
:city => 'Shibuya',
|
36
|
+
:state => 'Tokyo',
|
37
|
+
:zip => '150-0031',
|
38
|
+
:country => 'Japan',
|
39
|
+
:latitude => '35.685',
|
40
|
+
:longitude => '139.751'
|
41
|
+
)
|
42
|
+
group.privacy.should == 'OPEN'
|
43
|
+
group.updated_time.should == '2010-01-02T15:37:41+0000'
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '../spec_helper')
|
2
|
+
|
3
|
+
describe FbGraph::Link, '#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
|
+
:link => 'http://www.facebook.com/link/12345',
|
13
|
+
:message => 'check this out!',
|
14
|
+
:updated_time => '2010-01-02T15:37:41+0000'
|
15
|
+
}
|
16
|
+
link = FbGraph::Link.new(attributes.delete(:id), attributes)
|
17
|
+
link.identifier.should == '12345'
|
18
|
+
link.from.should == FbGraph::User.new('23456', :name => 'nov matake')
|
19
|
+
link.link.should == 'http://www.facebook.com/link/12345'
|
20
|
+
link.message.should == 'check this out!'
|
21
|
+
link.updated_time.should == '2010-01-02T15:37:41+0000'
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should support page as from' do
|
25
|
+
page_link = FbGraph::Link.new('12345', :from => {
|
26
|
+
:id => '23456',
|
27
|
+
:name => 'Smart.fm',
|
28
|
+
:category => 'Web Site'
|
29
|
+
})
|
30
|
+
page_link.from.should == FbGraph::Page.new('23456', :name => 'Smart.fm', :category => 'Web Site')
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
data/spec/fb_graph/node_spec.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
require File.join(File.dirname(__FILE__), '../spec_helper')
|
2
2
|
|
3
|
-
describe FbGraph::Node, '#
|
3
|
+
describe FbGraph::Node, '#new' do
|
4
4
|
|
5
5
|
it 'should setup endpoint' do
|
6
6
|
FbGraph::Node.new('matake').endpoint.should == File.join(FbGraph::ROOT_URL, 'matake')
|
7
7
|
end
|
8
8
|
|
9
|
-
it 'should support
|
10
|
-
FbGraph::Node.new('matake', :
|
9
|
+
it 'should support token option' do
|
10
|
+
FbGraph::Node.new('matake', :token => 'token').token.should == 'token'
|
11
11
|
end
|
12
12
|
|
13
13
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '../spec_helper')
|
2
|
+
|
3
|
+
describe FbGraph::Note, '#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
|
+
:subject => 'TODO',
|
13
|
+
:message => 'later or never',
|
14
|
+
:created_time => '2010-01-02T15:37:40+0000',
|
15
|
+
:updated_time => '2010-01-02T15:37:41+0000'
|
16
|
+
}
|
17
|
+
note = FbGraph::Note.new(attributes.delete(:id), attributes)
|
18
|
+
note.identifier.should == '12345'
|
19
|
+
note.from.should == FbGraph::User.new('23456', :name => 'nov matake')
|
20
|
+
note.subject.should == 'TODO'
|
21
|
+
note.message.should == 'later or never'
|
22
|
+
note.created_time.should == '2010-01-02T15:37:40+0000'
|
23
|
+
note.updated_time.should == '2010-01-02T15:37:41+0000'
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'should support page as from' do
|
27
|
+
page_note = FbGraph::Note.new('12345', :from => {
|
28
|
+
:id => '23456',
|
29
|
+
:name => 'Smart.fm',
|
30
|
+
:category => 'Web Site'
|
31
|
+
})
|
32
|
+
page_note.from.should == FbGraph::Page.new('23456', :name => 'Smart.fm', :category => 'Web Site')
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
data/spec/fb_graph/page_spec.rb
CHANGED
@@ -3,7 +3,7 @@ require File.join(File.dirname(__FILE__), '../spec_helper')
|
|
3
3
|
describe FbGraph::Page, '.fetch' do
|
4
4
|
before(:all) do
|
5
5
|
fake_json(:get, 'platform', 'pages/platform_public')
|
6
|
-
fake_json(:get, 'platform?
|
6
|
+
fake_json(:get, 'platform?token=token', 'pages/platform_private')
|
7
7
|
end
|
8
8
|
|
9
9
|
it 'should get page attributes' do
|
@@ -13,7 +13,7 @@ describe FbGraph::Page, '.fetch' do
|
|
13
13
|
page.category.should == 'Technology'
|
14
14
|
end
|
15
15
|
|
16
|
-
it 'should not require
|
17
|
-
FbGraph::Page.fetch('platform', :
|
16
|
+
it 'should not require token' do
|
17
|
+
FbGraph::Page.fetch('platform', :token => 'token').should == FbGraph::Page.fetch('platform')
|
18
18
|
end
|
19
19
|
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '../spec_helper')
|
2
|
+
|
3
|
+
describe FbGraph::Photo, '#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
|
+
:tags => {
|
13
|
+
:data => [{
|
14
|
+
:id => '12345',
|
15
|
+
:name => 'nov matake',
|
16
|
+
:x => 32.5,
|
17
|
+
:y => 27.7778,
|
18
|
+
:created_time => '2010-01-10T15:37:40+0000'
|
19
|
+
}]
|
20
|
+
},
|
21
|
+
:name => 'photo 1',
|
22
|
+
:picture => 'http://www.facebook.com/matake/picture/album_size',
|
23
|
+
:source => 'http://www.facebook.com/matake/picture/original_size',
|
24
|
+
:height => 100,
|
25
|
+
:width => 200,
|
26
|
+
:link => 'http://www.facebook.com/photo/12345',
|
27
|
+
:created_time => '2010-01-02T15:37:40+0000',
|
28
|
+
:updated_time => '2010-01-02T15:37:41+0000'
|
29
|
+
}
|
30
|
+
photo = FbGraph::Photo.new(attributes.delete(:id), attributes)
|
31
|
+
photo.identifier.should == '12345'
|
32
|
+
photo.from.should == FbGraph::User.new('23456', :name => 'nov matake')
|
33
|
+
photo.tags.should == [FbGraph::Tag.new(
|
34
|
+
'12345',
|
35
|
+
:name => 'nov matake',
|
36
|
+
:x => 32.5,
|
37
|
+
:y => 27.7778,
|
38
|
+
:created_time => '2010-01-10T15:37:40+0000'
|
39
|
+
)]
|
40
|
+
photo.picture.should == 'http://www.facebook.com/matake/picture/album_size'
|
41
|
+
photo.source.should == 'http://www.facebook.com/matake/picture/original_size'
|
42
|
+
photo.height.should == 100
|
43
|
+
photo.width.should == 200
|
44
|
+
photo.link.should == 'http://www.facebook.com/photo/12345'
|
45
|
+
photo.created_time.should == '2010-01-02T15:37:40+0000'
|
46
|
+
photo.updated_time.should == '2010-01-02T15:37:41+0000'
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'should support page as from' do
|
50
|
+
page_photo = FbGraph::Photo.new('12345', :from => {
|
51
|
+
:id => '23456',
|
52
|
+
:name => 'Smart.fm',
|
53
|
+
:category => 'Web Site'
|
54
|
+
})
|
55
|
+
page_photo.from.should == FbGraph::Page.new('23456', :name => 'Smart.fm', :category => 'Web Site')
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '../spec_helper')
|
2
|
+
|
3
|
+
describe FbGraph::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 = FbGraph::Status.new(attributes.delete(:id), attributes)
|
16
|
+
status.identifier.should == '12345'
|
17
|
+
status.from.should == FbGraph::User.new('23456', :name => 'nov matake')
|
18
|
+
status.message.should == 'hello, how are you?'
|
19
|
+
status.updated_time.should == '2010-01-02T15:37:41+0000'
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'should support page as from' do
|
23
|
+
page_status = FbGraph::Status.new('12345', :from => {
|
24
|
+
:id => '23456',
|
25
|
+
:name => 'Smart.fm',
|
26
|
+
:category => 'Web Site'
|
27
|
+
})
|
28
|
+
page_status.from.should == FbGraph::Page.new('23456', :name => 'Smart.fm', :category => 'Web Site')
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
data/spec/fb_graph/user_spec.rb
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
require File.join(File.dirname(__FILE__), '../spec_helper')
|
2
2
|
|
3
3
|
describe FbGraph::User, '.me' do
|
4
|
-
it 'should return FbGraph::User instance with
|
5
|
-
FbGraph::User.me('
|
4
|
+
it 'should return FbGraph::User instance with token' do
|
5
|
+
FbGraph::User.me('token').should == FbGraph::User.new('me', :token => 'token')
|
6
6
|
end
|
7
7
|
end
|
8
8
|
|
9
9
|
describe FbGraph::User, '.fetch' do
|
10
10
|
before(:all) do
|
11
11
|
fake_json(:get, 'arjun', 'users/arjun_public')
|
12
|
-
fake_json(:get, 'arjun?
|
12
|
+
fake_json(:get, 'arjun?token=token', 'users/arjun_private')
|
13
13
|
end
|
14
14
|
|
15
|
-
it 'should get only public profile when no
|
15
|
+
it 'should get only public profile when no token given' do
|
16
16
|
user = FbGraph::User.fetch('arjun')
|
17
17
|
user.name.should == 'Arjun Banker'
|
18
18
|
user.first_name.should == 'Arjun'
|
@@ -21,8 +21,8 @@ describe FbGraph::User, '.fetch' do
|
|
21
21
|
user.link.should == 'http://www.facebook.com/Arjun'
|
22
22
|
end
|
23
23
|
|
24
|
-
it 'should get public + private profile when
|
25
|
-
user = FbGraph::User.fetch('arjun', :
|
24
|
+
it 'should get public + private profile when token given' do
|
25
|
+
user = FbGraph::User.fetch('arjun', :token => 'token')
|
26
26
|
# public
|
27
27
|
user.name.should == 'Arjun Banker'
|
28
28
|
user.first_name.should == 'Arjun'
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '../spec_helper')
|
2
|
+
|
3
|
+
describe FbGraph::Video, '#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 => 'check this out!',
|
13
|
+
:description => 'Smart.fm learning engine details',
|
14
|
+
:length => 3600,
|
15
|
+
:created_time => '2010-01-02T15:37:40+0000',
|
16
|
+
:updated_time => '2010-01-02T15:37:41+0000'
|
17
|
+
}
|
18
|
+
video = FbGraph::Video.new(attributes.delete(:id), attributes)
|
19
|
+
video.identifier.should == '12345'
|
20
|
+
video.from.should == FbGraph::User.new('23456', :name => 'nov matake')
|
21
|
+
video.message.should == 'check this out!'
|
22
|
+
video.description.should == 'Smart.fm learning engine details'
|
23
|
+
video.length.should == 3600
|
24
|
+
video.created_time.should == '2010-01-02T15:37:40+0000'
|
25
|
+
video.updated_time.should == '2010-01-02T15:37:41+0000'
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should support page as from' do
|
29
|
+
page_video = FbGraph::Video.new('12345', :from => {
|
30
|
+
:id => '23456',
|
31
|
+
:name => 'Smart.fm',
|
32
|
+
:category => 'Web Site'
|
33
|
+
})
|
34
|
+
page_video.from.should == FbGraph::Page.new('23456', :name => 'Smart.fm', :category => 'Web Site')
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|