facebook-client 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -31,7 +31,7 @@ GEM
31
31
  rspec-expectations (2.14.0)
32
32
  diff-lcs (>= 1.1.3, < 2.0)
33
33
  rspec-instafail (0.2.4)
34
- rspec-mocks (2.14.1)
34
+ rspec-mocks (2.14.2)
35
35
  saddle (0.0.38)
36
36
  activesupport (>= 3.0)
37
37
  faraday (~> 0.8.7)
data/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
  ## Usage
5
5
 
6
6
  client = Facebook::Client.create(
7
- :oauth2_access_token => YOUR_USER_ACCESS_TOKEN
7
+ :access_token => YOUR_USER_ACCESS_TOKEN
8
8
  )
9
9
  user = client.people.me
10
10
  user = client.people.by_id(123)
@@ -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'
@@ -1,3 +1,5 @@
1
+ # encoding: UTF-8
2
+
1
3
  require 'saddle/endpoint'
2
4
 
3
5
 
@@ -1,3 +1,5 @@
1
+ # encoding: UTF-8
2
+
1
3
  require 'saddle/endpoint'
2
4
 
3
5
 
@@ -1,3 +1,4 @@
1
+ # encoding: UTF-8
1
2
 
2
3
  ##
3
4
  # Exceptions for using the Facebook client
@@ -1,3 +1,5 @@
1
+ # encoding: UTF-8
2
+
1
3
  require 'faraday'
2
4
 
3
5
  require 'facebook-client/exceptions'
@@ -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
@@ -1,3 +1,5 @@
1
+ # encoding: UTF-8
2
+
1
3
  module Facebook
2
- VERSION = '0.0.1'
4
+ VERSION = '0.0.2'
3
5
  end
@@ -1 +1,3 @@
1
+ # encoding: UTF-8
2
+
1
3
  TEST_ACCESS_TOKEN = 'XXX_YOUR_OAUTH2_ACCESS_TOKEN_XXX'
@@ -1,3 +1,5 @@
1
+ # encoding: UTF-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
 
@@ -1,3 +1,5 @@
1
+ # encoding: UTF-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
 
@@ -1,3 +1,5 @@
1
+ # encoding: UTF-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
 
@@ -1,3 +1,5 @@
1
+ # encoding: UTF-8
2
+
1
3
  require 'facebook-client'
2
4
 
3
5
 
@@ -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.1
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-07-31 00:00:00.000000000 Z
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