meta_graph 0.0.2
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/.gitignore +9 -0
- data/Gemfile +3 -0
- data/README.md +3 -0
- data/VERSION +1 -0
- data/lib/meta_graph.rb +17 -0
- data/lib/meta_graph/client.rb +46 -0
- data/lib/meta_graph/collection.rb +27 -0
- data/lib/meta_graph/graph_accessor.rb +13 -0
- data/lib/meta_graph/hash_accessor.rb +55 -0
- data/lib/meta_graph/node.rb +116 -0
- data/lib/meta_graph/resource.rb +90 -0
- data/meta_graph.gemspec +15 -0
- data/spec/json/116314101712416.json +12 -0
- data/spec/json/125808504153906.json +11 -0
- data/spec/json/164489816910252.json +30 -0
- data/spec/json/me.json +364 -0
- data/spec/json/me/likes.json +643 -0
- data/spec/meta_graph/client_spec.rb +97 -0
- data/spec/spec_helper.rb +19 -0
- metadata +111 -0
@@ -0,0 +1,97 @@
|
|
1
|
+
#-*- coding: utf-8 -*-
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe MetaGraph::Client do
|
5
|
+
before do
|
6
|
+
@client = MetaGraph::Client.new(MetaGraph::RSPEC_ACCESS_TOKEN)
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'should read the access token from client' do
|
10
|
+
@client.access_token.should == MetaGraph::RSPEC_ACCESS_TOKEN
|
11
|
+
end
|
12
|
+
|
13
|
+
context 'when get a connection from Graph API' do
|
14
|
+
before do
|
15
|
+
regist_mock 'me/likes'
|
16
|
+
@likes = @client.fetch('me/likes')
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'should access collection' do
|
20
|
+
@likes.should have(106).items
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
context 'when get a data from Graph API' do
|
25
|
+
before do
|
26
|
+
regist_mock :me
|
27
|
+
@me = @client.me
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should access user's string fields" do
|
31
|
+
@me.id.should == '100001529256922'
|
32
|
+
@me.name.should == 'Kengo Tateishi'
|
33
|
+
end
|
34
|
+
|
35
|
+
context 'when access collections' do
|
36
|
+
before do
|
37
|
+
regist_mock 'me/likes'
|
38
|
+
@likes = @me.likes
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'should get collection size' do
|
42
|
+
@likes.should have(106).items
|
43
|
+
end
|
44
|
+
|
45
|
+
context 'when read a value contained id key' do
|
46
|
+
before do
|
47
|
+
regist_mock '116314101712416'
|
48
|
+
@like = @likes[90]
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'should get specified collection' do
|
52
|
+
@like.id.should == '116314101712416'
|
53
|
+
@like.name.should == 'となりのトトロ'
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
context 'when read a array value' do
|
59
|
+
before do
|
60
|
+
@works = @me.work
|
61
|
+
@favorite_teams = @me.favorite_teams
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'should access users array parameter' do
|
65
|
+
@works.should have(4).items
|
66
|
+
@favorite_teams.should have(1).item
|
67
|
+
end
|
68
|
+
|
69
|
+
context 'when read a value contained id key' do
|
70
|
+
before do
|
71
|
+
regist_mock '164489816910252'
|
72
|
+
@employer = @works[0].employer
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'should read a value from Graph API' do
|
76
|
+
@employer.id.should == '164489816910252'
|
77
|
+
@employer.name.should == 'Paperboy&co.'
|
78
|
+
@employer.location.zip.should == '1508512'
|
79
|
+
@employer.location.country.should == 'Japan'
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
context 'when read a value contained id key' do
|
85
|
+
before do
|
86
|
+
regist_mock '125808504153906'
|
87
|
+
@hometown = @me.hometown
|
88
|
+
end
|
89
|
+
|
90
|
+
it 'should access fields of its data' do
|
91
|
+
@hometown.id.should == '125808504153906'
|
92
|
+
@hometown.name.should == 'Tosu-shi, Saga, Japan'
|
93
|
+
@hometown.link.should == 'https://www.facebook.com/pages/Tosu-shi-Saga-Japan/125808504153906'
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'webmock/rspec'
|
2
|
+
require 'meta_graph'
|
3
|
+
|
4
|
+
module MetaGraph
|
5
|
+
RSPEC_ACCESS_TOKEN = 'This is dummy access token.'
|
6
|
+
end
|
7
|
+
|
8
|
+
def regist_mock(path, method = :get)
|
9
|
+
url = MetaGraph::GRAPH_API_END_POINT + path.to_s
|
10
|
+
|
11
|
+
query = {
|
12
|
+
access_token: MetaGraph::RSPEC_ACCESS_TOKEN,
|
13
|
+
metadata: 1
|
14
|
+
}
|
15
|
+
|
16
|
+
body = open(File.dirname(__FILE__) + "/json/#{path}.json", 'r').read
|
17
|
+
|
18
|
+
stub_request(method, url).with(query: query).to_return(body: body)
|
19
|
+
end
|
metadata
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: meta_graph
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Kengo Tateishi
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-01-04 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: httpclient
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rspec
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: webmock
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
description: A lightweight client of Facebook Graph API
|
63
|
+
email: embrace.ddd.flake.peace@gmail.com
|
64
|
+
executables: []
|
65
|
+
extensions: []
|
66
|
+
extra_rdoc_files: []
|
67
|
+
files:
|
68
|
+
- .gitignore
|
69
|
+
- Gemfile
|
70
|
+
- README.md
|
71
|
+
- VERSION
|
72
|
+
- lib/meta_graph.rb
|
73
|
+
- lib/meta_graph/client.rb
|
74
|
+
- lib/meta_graph/collection.rb
|
75
|
+
- lib/meta_graph/graph_accessor.rb
|
76
|
+
- lib/meta_graph/hash_accessor.rb
|
77
|
+
- lib/meta_graph/node.rb
|
78
|
+
- lib/meta_graph/resource.rb
|
79
|
+
- meta_graph.gemspec
|
80
|
+
- spec/json/116314101712416.json
|
81
|
+
- spec/json/125808504153906.json
|
82
|
+
- spec/json/164489816910252.json
|
83
|
+
- spec/json/me.json
|
84
|
+
- spec/json/me/likes.json
|
85
|
+
- spec/meta_graph/client_spec.rb
|
86
|
+
- spec/spec_helper.rb
|
87
|
+
homepage: https://github.com/tkengo/meta_graph
|
88
|
+
licenses: []
|
89
|
+
post_install_message:
|
90
|
+
rdoc_options: []
|
91
|
+
require_paths:
|
92
|
+
- lib
|
93
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
94
|
+
none: false
|
95
|
+
requirements:
|
96
|
+
- - ! '>='
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
|
+
none: false
|
101
|
+
requirements:
|
102
|
+
- - ! '>='
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
requirements: []
|
106
|
+
rubyforge_project:
|
107
|
+
rubygems_version: 1.8.23
|
108
|
+
signing_key:
|
109
|
+
specification_version: 3
|
110
|
+
summary: Meta Graph
|
111
|
+
test_files: []
|