facebook-client 0.0.1 → 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/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/lib/facebook-client.rb +4 -0
- data/lib/facebook-client/endpoints/fql.rb +2 -0
- data/lib/facebook-client/endpoints/user.rb +2 -0
- data/lib/facebook-client/exceptions.rb +1 -0
- data/lib/facebook-client/middleware/exception_raiser.rb +2 -0
- data/lib/facebook-client/stub.rb +143 -0
- data/lib/facebook-client/version.rb +3 -1
- data/spec/_creds.stub.rb +2 -0
- data/spec/integration/fql_spec.rb +2 -0
- data/spec/integration/user_spec.rb +2 -0
- data/spec/middleware/exception_raiser_spec.rb +2 -0
- data/spec/spec_helper.rb +2 -0
- data/spec/stub/stub_spec.rb +30 -0
- metadata +5 -2
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
data/lib/facebook-client.rb
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
|
|
1
3
|
require 'saddle'
|
|
2
4
|
require 'saddle/middleware/authentication/oauth2'
|
|
3
5
|
|
|
4
6
|
require 'facebook-client/exceptions'
|
|
5
7
|
require 'facebook-client/middleware/exception_raiser'
|
|
8
|
+
require 'facebook-client/stub'
|
|
6
9
|
require 'facebook-client/version'
|
|
7
10
|
|
|
8
11
|
|
|
@@ -10,6 +13,7 @@ require 'facebook-client/version'
|
|
|
10
13
|
module Facebook
|
|
11
14
|
|
|
12
15
|
class Client < Saddle::Client
|
|
16
|
+
extend Facebook::Stub
|
|
13
17
|
|
|
14
18
|
def self.host
|
|
15
19
|
'graph.facebook.com'
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
|
|
3
|
+
require 'facebook-client/endpoints/fql'
|
|
4
|
+
require 'facebook-client/endpoints/user'
|
|
5
|
+
|
|
6
|
+
# This allows us to stub out live calls when testing from calling projects
|
|
7
|
+
|
|
8
|
+
module Facebook
|
|
9
|
+
module Stub
|
|
10
|
+
|
|
11
|
+
# Setup stubbing for all endpoints
|
|
12
|
+
def stub!
|
|
13
|
+
Facebook::Endpoints::FQL.any_instance.stub(:query).and_return( Stub::Data::TEST_FQL_RESPONSE )
|
|
14
|
+
|
|
15
|
+
Facebook::Endpoints::User.any_instance.stub(:me).and_return( Stub::Data::TEST_USER )
|
|
16
|
+
Facebook::Endpoints::User.any_instance.stub(:by_id).and_return( Stub::Data::TEST_USER )
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# Test data for stubs to return
|
|
20
|
+
module Data
|
|
21
|
+
TEST_FQL_RESPONSE = [{}.freeze].freeze
|
|
22
|
+
|
|
23
|
+
TEST_USER = {
|
|
24
|
+
'id' => "1",
|
|
25
|
+
'name' => "Squirrely BooBoo",
|
|
26
|
+
'first_name' => "Squirrely",
|
|
27
|
+
'last_name' => "BooBoo",
|
|
28
|
+
'link' => "https://www.facebook.com/mLewisLogic",
|
|
29
|
+
'username' => "mLewisLogic",
|
|
30
|
+
'birthday' => "12/12/1923",
|
|
31
|
+
'hometown' => {
|
|
32
|
+
'id' => "109748972377870",
|
|
33
|
+
'name' => "Syracuse, New York",
|
|
34
|
+
},
|
|
35
|
+
'location' => {
|
|
36
|
+
'id' => "114952118516947",
|
|
37
|
+
'name' => "San Francisco, California",
|
|
38
|
+
},
|
|
39
|
+
'quotes' =>
|
|
40
|
+
"The Church says: the body is a sin.\n" +
|
|
41
|
+
"Science says: the body is a machine.\n" +
|
|
42
|
+
"Advertising says: The body is a business.\n" +
|
|
43
|
+
"The Body says: I am a fiesta.\n" +
|
|
44
|
+
" ― Eduardo Hughes Galeano",
|
|
45
|
+
'sports' => [
|
|
46
|
+
{
|
|
47
|
+
'id' => "108167272538953",
|
|
48
|
+
'name' => "Table tennis"
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
'id' => "107496599279538",
|
|
52
|
+
'name' => "Snowboarding",
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
'education' => [
|
|
56
|
+
{
|
|
57
|
+
'school' => {
|
|
58
|
+
'id' => "110481998980842",
|
|
59
|
+
'name' => "Christian Brothers Academy",
|
|
60
|
+
},
|
|
61
|
+
'year' => {
|
|
62
|
+
'id' => "194603703904595",
|
|
63
|
+
'name' => "2003",
|
|
64
|
+
},
|
|
65
|
+
'type' => 'High School',
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
'school' => {
|
|
69
|
+
'id' => "12355161929",
|
|
70
|
+
'name' => "Rochester Institute of Technology",
|
|
71
|
+
},
|
|
72
|
+
'year' => {
|
|
73
|
+
'id' => "141778012509913",
|
|
74
|
+
'name' => "2008",
|
|
75
|
+
},
|
|
76
|
+
'concentration' => [
|
|
77
|
+
{
|
|
78
|
+
'id' => "112377098773944",
|
|
79
|
+
'name' => "Computer Engineering",
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
'id' => "108384569189012",
|
|
83
|
+
'name' => "Sociology",
|
|
84
|
+
}
|
|
85
|
+
],
|
|
86
|
+
'type' => "College",
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
'school' => {
|
|
90
|
+
'id' => "5755052206",
|
|
91
|
+
'name' => "University of Sydney",
|
|
92
|
+
},
|
|
93
|
+
'year' => {
|
|
94
|
+
'id' => "137616982934053",
|
|
95
|
+
'name' => "2006",
|
|
96
|
+
},
|
|
97
|
+
'concentration' => [
|
|
98
|
+
{
|
|
99
|
+
'id' => "108384569189012",
|
|
100
|
+
'name' => "Sociology",
|
|
101
|
+
}
|
|
102
|
+
],
|
|
103
|
+
'type' => "College",
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
'school' => {
|
|
107
|
+
'id' => "12355161929",
|
|
108
|
+
'name' => "Rochester Institute of Technology",
|
|
109
|
+
},
|
|
110
|
+
'degree' => {
|
|
111
|
+
'id' => "109903862418964",
|
|
112
|
+
'name' => "Master of Science",
|
|
113
|
+
},
|
|
114
|
+
'year' => {
|
|
115
|
+
'id' => "141778012509913",
|
|
116
|
+
'name' => "2008",
|
|
117
|
+
},
|
|
118
|
+
'concentration' => [
|
|
119
|
+
{
|
|
120
|
+
'id' => "112377098773944",
|
|
121
|
+
'name' => "Computer Engineering",
|
|
122
|
+
}
|
|
123
|
+
],
|
|
124
|
+
'type' => "Graduate School",
|
|
125
|
+
}
|
|
126
|
+
],
|
|
127
|
+
'gender' => "male",
|
|
128
|
+
'email' => "squirrely.booboo@gmail.com",
|
|
129
|
+
'timezone' => -7,
|
|
130
|
+
'locale' => "en_US",
|
|
131
|
+
'languages' => [
|
|
132
|
+
{
|
|
133
|
+
'id' => "106059522759137",
|
|
134
|
+
'name' => "English",
|
|
135
|
+
}
|
|
136
|
+
],
|
|
137
|
+
'verified' => true,
|
|
138
|
+
'updated_time' => "2013-06-15T04:06:53+0000",
|
|
139
|
+
}.freeze
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
end
|
|
143
|
+
end
|
data/spec/_creds.stub.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
describe Facebook::Stub do
|
|
8
|
+
context 'can stub out calls' do
|
|
9
|
+
|
|
10
|
+
before :each do
|
|
11
|
+
Facebook::Client.stub!
|
|
12
|
+
@client = Facebook::Client.create
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
describe 'and return test data' do
|
|
16
|
+
it 'for client.user.me' do
|
|
17
|
+
@client.user.me.should == Facebook::Stub::Data::TEST_USER
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it 'for client.user.by_id' do
|
|
21
|
+
@client.user.by_id(123).should == Facebook::Stub::Data::TEST_USER
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it 'for client.fql.query' do
|
|
25
|
+
@client.fql.query('test').should == Facebook::Stub::Data::TEST_FQL_RESPONSE
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
end
|
|
30
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: facebook-client
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.2
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2013-
|
|
12
|
+
date: 2013-08-01 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: saddle
|
|
@@ -46,12 +46,14 @@ files:
|
|
|
46
46
|
- lib/facebook-client/endpoints/user.rb
|
|
47
47
|
- lib/facebook-client/exceptions.rb
|
|
48
48
|
- lib/facebook-client/middleware/exception_raiser.rb
|
|
49
|
+
- lib/facebook-client/stub.rb
|
|
49
50
|
- lib/facebook-client/version.rb
|
|
50
51
|
- spec/_creds.stub.rb
|
|
51
52
|
- spec/integration/fql_spec.rb
|
|
52
53
|
- spec/integration/user_spec.rb
|
|
53
54
|
- spec/middleware/exception_raiser_spec.rb
|
|
54
55
|
- spec/spec_helper.rb
|
|
56
|
+
- spec/stub/stub_spec.rb
|
|
55
57
|
homepage: https://github.com/airbnb/facebook-client
|
|
56
58
|
licenses:
|
|
57
59
|
- MIT
|
|
@@ -83,3 +85,4 @@ test_files:
|
|
|
83
85
|
- spec/integration/user_spec.rb
|
|
84
86
|
- spec/middleware/exception_raiser_spec.rb
|
|
85
87
|
- spec/spec_helper.rb
|
|
88
|
+
- spec/stub/stub_spec.rb
|