koala 1.8.0 → 1.9.0rc1
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.
- checksums.yaml +4 -4
- data/.travis.yml +2 -2
- data/Gemfile +5 -9
- data/changelog.md +22 -3
- data/koala.gemspec +0 -2
- data/lib/koala.rb +5 -0
- data/lib/koala/api.rb +12 -2
- data/lib/koala/api/graph_api.rb +4 -1
- data/lib/koala/version.rb +1 -1
- data/readme.md +17 -4
- data/spec/cases/api_spec.rb +81 -24
- data/spec/cases/error_spec.rb +16 -16
- data/spec/cases/graph_api_batch_spec.rb +103 -103
- data/spec/cases/graph_api_spec.rb +33 -10
- data/spec/cases/graph_collection_spec.rb +35 -35
- data/spec/cases/http_service_spec.rb +92 -92
- data/spec/cases/koala_spec.rb +9 -9
- data/spec/cases/legacy_spec.rb +22 -22
- data/spec/cases/multipart_request_spec.rb +20 -21
- data/spec/cases/oauth_spec.rb +125 -125
- data/spec/cases/realtime_updates_spec.rb +44 -44
- data/spec/cases/test_users_spec.rb +58 -58
- data/spec/cases/uploadable_io_spec.rb +36 -36
- data/spec/cases/utils_spec.rb +11 -11
- data/spec/spec_helper.rb +0 -19
- data/spec/support/custom_matchers.rb +3 -3
- data/spec/support/graph_api_shared_examples.rb +117 -114
- data/spec/support/koala_test.rb +3 -8
- data/spec/support/rest_api_shared_examples.rb +18 -19
- data/spec/support/uploadable_io_shared_examples.rb +10 -10
- metadata +20 -50
- data/spec/support/ordered_hash.rb +0 -201
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 19a19ff9100a2e1c3374404311fa53f597cd5267
|
4
|
+
data.tar.gz: fc6230dc12b06d9c774f01a1159e125549103f9f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 150c78781dfc53db7a56f964f2499c37c8f1fadd81dd9844f309fa8d52a4a8463623efab79803ed94a9fc8f926e1e85dcd9249bb8b088473e92a1fb1a44a5181
|
7
|
+
data.tar.gz: b3b2d5a6daa041cd2916e4455aef83feb1577522539ce216fa570961e767f4f98854df00e9f205549560c72048dcbca601b1b7f8626275ec91eb41c4b98461f5
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
@@ -1,21 +1,17 @@
|
|
1
1
|
source "https://rubygems.org"
|
2
2
|
|
3
3
|
group :development do
|
4
|
+
gem 'debugger'
|
4
5
|
gem "yard"
|
5
6
|
end
|
6
7
|
|
7
8
|
group :development, :test do
|
9
|
+
gem "rake"
|
8
10
|
gem "typhoeus" unless defined? JRUBY_VERSION
|
11
|
+
end
|
9
12
|
|
10
|
-
|
11
|
-
gem '
|
12
|
-
gem 'guard-rspec'
|
13
|
-
|
14
|
-
if RUBY_PLATFORM =~ /darwin/
|
15
|
-
# OS X integration
|
16
|
-
gem "ruby_gntp"
|
17
|
-
gem "rb-fsevent"
|
18
|
-
end
|
13
|
+
group :test do
|
14
|
+
gem "rspec", '~> 3.0.0.beta1'
|
19
15
|
end
|
20
16
|
|
21
17
|
gem "jruby-openssl" if defined? JRUBY_VERSION
|
data/changelog.md
CHANGED
@@ -1,3 +1,21 @@
|
|
1
|
+
v1.9.0
|
2
|
+
======
|
3
|
+
|
4
|
+
Updated Methods:
|
5
|
+
* API#new now takes an optional access_token, which will be used to generate
|
6
|
+
the appsecret_proof parameters ([thanks,
|
7
|
+
nchelluri!](https://github.com/arsduo/koala/pull/323))
|
8
|
+
|
9
|
+
Testing Improvements:
|
10
|
+
* Add 2.1.0 to travis.yml and update specs to pass w/o deprecation on RSpec 3.0
|
11
|
+
([thanks](https://github.com/arsduo/koala/pull/350),
|
12
|
+
[petergoldstein](https://github.com/arsduo/koala/pull/348)!)
|
13
|
+
* With 1.9.0+ only support, removed the OrderedHash patch
|
14
|
+
|
15
|
+
Documentation Improvements:
|
16
|
+
* Make it clear that connections take a singlar form in API#put_connection
|
17
|
+
(thanks, [josephdburdick](https://github.com/arsduo/koala/pull/349)!)
|
18
|
+
|
1
19
|
v1.8.0
|
2
20
|
=========
|
3
21
|
|
@@ -14,12 +32,13 @@ New methods:
|
|
14
32
|
* OAuth#generate_client_code lets you get long-lived user tokens for client apps (thanks, binarygeek!)
|
15
33
|
|
16
34
|
Updated methods:
|
17
|
-
* API#new now takes an optional access_token, which will be used to generate
|
18
|
-
the appsecret_proof parameters ([thanks,
|
19
|
-
nchelluri!](https://github.com/arsduo/koala/pull/323))
|
20
35
|
* GraphCollection#next_page and #previous_page can now take additional
|
21
36
|
parameters ([thanks, gacha!](https://github.com/arsduo/koala/pull/330))
|
22
37
|
|
38
|
+
NOTE: the appsecret_proof update from nchelluri was originally listed in the
|
39
|
+
changelog for 1.8.0, but didn't make it in. It's now properly in the changelog
|
40
|
+
for 1.9.0.
|
41
|
+
|
23
42
|
Internal Improvements:
|
24
43
|
* FIXED: TestUser#delete_all will avoid infinite loops if the user hashes
|
25
44
|
change ([thanks, chunkerchunker!](https://github.com/arsduo/koala/pull/331))
|
data/koala.gemspec
CHANGED
data/lib/koala.rb
CHANGED
data/lib/koala/api.rb
CHANGED
@@ -1,19 +1,26 @@
|
|
1
1
|
# graph_batch_api and legacy are required at the bottom, since they depend on API being defined
|
2
2
|
require 'koala/api/graph_api'
|
3
3
|
require 'koala/api/rest_api'
|
4
|
+
require 'openssl'
|
4
5
|
|
5
6
|
module Koala
|
6
7
|
module Facebook
|
7
8
|
class API
|
8
9
|
# Creates a new API client.
|
9
10
|
# @param [String] access_token access token
|
11
|
+
# @param [String] app_secret app secret, for tying your access tokens to your app secret
|
12
|
+
# If you provide an app secret, your requests will be
|
13
|
+
# signed by default, unless you pass appsecret_proof:
|
14
|
+
# false as an option to the API call. (See
|
15
|
+
# https://developers.facebook.com/docs/graph-api/securing-requests/)
|
10
16
|
# @note If no access token is provided, you can only access some public information.
|
11
17
|
# @return [Koala::Facebook::API] the API client
|
12
|
-
def initialize(access_token = nil)
|
18
|
+
def initialize(access_token = nil, app_secret = nil)
|
13
19
|
@access_token = access_token
|
20
|
+
@app_secret = app_secret
|
14
21
|
end
|
15
22
|
|
16
|
-
attr_reader :access_token
|
23
|
+
attr_reader :access_token, :app_secret
|
17
24
|
|
18
25
|
include GraphAPIMethods
|
19
26
|
include RestAPIMethods
|
@@ -45,6 +52,9 @@ module Koala
|
|
45
52
|
# This is explicitly needed in batch requests so GraphCollection
|
46
53
|
# results preserve any specific access tokens provided
|
47
54
|
args["access_token"] ||= @access_token || @app_access_token if @access_token || @app_access_token
|
55
|
+
if options.delete(:appsecret_proof) && args["access_token"] && @app_secret
|
56
|
+
args["appsecret_proof"] = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new("sha256"), @app_secret, args["access_token"])
|
57
|
+
end
|
48
58
|
|
49
59
|
# Translate any arrays in the params into comma-separated strings
|
50
60
|
args = sanitize_request_parameters(args)
|
data/lib/koala/api/graph_api.rb
CHANGED
@@ -119,7 +119,8 @@ module Koala
|
|
119
119
|
|
120
120
|
# Write an object to the Graph for a specific user.
|
121
121
|
# See {http://developers.facebook.com/docs/api#publishing Facebook's documentation}
|
122
|
-
# for all the supported writeable objects.
|
122
|
+
# for all the supported writeable objects. It is important to note that objects
|
123
|
+
# take the singular form, i.e. "event" when using put_connections.
|
123
124
|
#
|
124
125
|
# @note (see #get_connection)
|
125
126
|
#
|
@@ -495,6 +496,8 @@ module Koala
|
|
495
496
|
#
|
496
497
|
# @return the result from Facebook
|
497
498
|
def graph_call(path, args = {}, verb = "get", options = {}, &post_processing)
|
499
|
+
# enable appsecret_proof by default
|
500
|
+
options = {:appsecret_proof => true}.merge(options) if @app_secret
|
498
501
|
result = api(path, args, verb, options) do |response|
|
499
502
|
error = check_response(response.status, response.body)
|
500
503
|
raise error if error
|
data/lib/koala/version.rb
CHANGED
data/readme.md
CHANGED
@@ -41,12 +41,19 @@ profile = @graph.get_object("me")
|
|
41
41
|
friends = @graph.get_connections("me", "friends")
|
42
42
|
@graph.put_connections("me", "feed", :message => "I am writing on my wall!")
|
43
43
|
|
44
|
-
#
|
44
|
+
# Three-part queries are easy too!
|
45
45
|
@graph.get_connections("me", "mutualfriends/#{friend_id}")
|
46
46
|
|
47
|
-
#
|
48
|
-
# see https://developers.facebook.com/docs/beta/opengraph/tutorial/
|
47
|
+
# You can use the Timeline API:
|
48
|
+
# (see https://developers.facebook.com/docs/beta/opengraph/tutorial/)
|
49
49
|
@graph.put_connections("me", "namespace:action", :object => object_url)
|
50
|
+
|
51
|
+
# For extra security (recommended), you can provide an appsecret parameter,
|
52
|
+
# tying your access tokens to your app secret.
|
53
|
+
# (See https://developers.facebook.com/docs/reference/api/securing-graph-api/
|
54
|
+
# You'll need to turn on 'Require proof on all calls' in the advanced section
|
55
|
+
# of your app's settings when doing this.
|
56
|
+
@graph = Koala::Facebook::API.new(oauth_access_token, app_secret)
|
50
57
|
```
|
51
58
|
|
52
59
|
The response of most requests is the JSON data returned from the Facebook servers as a Hash.
|
@@ -223,14 +230,20 @@ The <a href="https://github.com/arsduo/koala/wiki/HTTP-Services">HTTP Services w
|
|
223
230
|
|
224
231
|
See examples, ask questions
|
225
232
|
-----
|
233
|
+
|
226
234
|
Some resources to help you as you play with Koala and the Graph API:
|
227
235
|
|
228
236
|
* Complete Koala documentation <a href="https://github.com/arsduo/koala/wiki">on the wiki</a>
|
229
|
-
*
|
237
|
+
* Facebook's <a href="http://facebook.stackoverflow.com/">Stack Overflow site</a> is a stupendous place to ask questions, filled with people who will help you figure out what's up with the Facebook API.
|
230
238
|
* Facebook's <a href="http://developers.facebook.com/tools/explorer/">Graph API Explorer</a>, where you can play with the Graph API in your browser
|
231
239
|
* The Koala-powered <a href="http://oauth.twoalex.com" target="_blank">OAuth Playground</a>, where you can easily generate OAuth access tokens and any other data needed to test out the APIs or OAuth
|
232
240
|
* Follow Koala on <a href="http://www.facebook.com/pages/Koala/315368291823667">Facebook</a> and <a href="https://twitter.com/#!/koala_fb">Twitter</a> for SDK updates and occasional news about Facebook API changes.
|
233
241
|
|
242
|
+
*Note*: I use the Koala issues tracker on Github to triage and address issues
|
243
|
+
with the gem itself; if you need help using the Facebook API, the above
|
244
|
+
resources will be far more effective. Depending on how much time I have, Github
|
245
|
+
issues filed about how to use the Facebook API may be closed with a reference
|
246
|
+
to the Facebook Stack Overflow page.
|
234
247
|
|
235
248
|
Testing
|
236
249
|
-----
|
data/spec/cases/api_spec.rb
CHANGED
@@ -6,7 +6,7 @@ describe "Koala::Facebook::API" do
|
|
6
6
|
end
|
7
7
|
|
8
8
|
it "doesn't include an access token if none was given" do
|
9
|
-
Koala.
|
9
|
+
expect(Koala).to receive(:make_request).with(
|
10
10
|
anything,
|
11
11
|
hash_not_including('access_token' => 1),
|
12
12
|
anything,
|
@@ -20,7 +20,7 @@ describe "Koala::Facebook::API" do
|
|
20
20
|
token = 'adfadf'
|
21
21
|
service = Koala::Facebook::API.new token
|
22
22
|
|
23
|
-
Koala.
|
23
|
+
expect(Koala).to receive(:make_request).with(
|
24
24
|
anything,
|
25
25
|
hash_including('access_token' => token),
|
26
26
|
anything,
|
@@ -33,7 +33,13 @@ describe "Koala::Facebook::API" do
|
|
33
33
|
it "has an attr_reader for access token" do
|
34
34
|
token = 'adfadf'
|
35
35
|
service = Koala::Facebook::API.new token
|
36
|
-
service.access_token.
|
36
|
+
expect(service.access_token).to eq(token)
|
37
|
+
end
|
38
|
+
|
39
|
+
it "has an attr_reader for app_secret" do
|
40
|
+
secret = double
|
41
|
+
service = Koala::Facebook::API.new(@token, secret)
|
42
|
+
expect(service.app_secret).to eq(secret)
|
37
43
|
end
|
38
44
|
|
39
45
|
it "gets the attribute of a Koala::HTTPService::Response given by the http_component parameter" do
|
@@ -41,24 +47,24 @@ describe "Koala::Facebook::API" do
|
|
41
47
|
|
42
48
|
response = double('Mock KoalaResponse', :body => '', :status => 200)
|
43
49
|
result = double("result")
|
44
|
-
response.
|
45
|
-
Koala.
|
50
|
+
allow(response).to receive(http_component).and_return(result)
|
51
|
+
allow(Koala).to receive(:make_request).and_return(response)
|
46
52
|
|
47
|
-
@service.api('anything', {}, 'get', :http_component => http_component).
|
53
|
+
expect(@service.api('anything', {}, 'get', :http_component => http_component)).to eq(result)
|
48
54
|
end
|
49
55
|
|
50
56
|
it "returns the entire response if http_component => :response" do
|
51
57
|
http_component = :response
|
52
58
|
response = double('Mock KoalaResponse', :body => '', :status => 200)
|
53
|
-
Koala.
|
54
|
-
@service.api('anything', {}, 'get', :http_component => http_component).
|
59
|
+
allow(Koala).to receive(:make_request).and_return(response)
|
60
|
+
expect(@service.api('anything', {}, 'get', :http_component => http_component)).to eq(response)
|
55
61
|
end
|
56
62
|
|
57
63
|
it "turns arrays of non-enumerables into comma-separated arguments" do
|
58
64
|
args = [12345, {:foo => [1, 2, "3", :four]}]
|
59
65
|
expected = ["/12345", {:foo => "1,2,3,four"}, "get", {}]
|
60
66
|
response = double('Mock KoalaResponse', :body => '', :status => 200)
|
61
|
-
Koala.
|
67
|
+
expect(Koala).to receive(:make_request).with(*expected).and_return(response)
|
62
68
|
@service.api(*args)
|
63
69
|
end
|
64
70
|
|
@@ -70,57 +76,57 @@ describe "Koala::Facebook::API" do
|
|
70
76
|
# or raise an exception
|
71
77
|
expected = ["/12345", params, "get", {}]
|
72
78
|
response = double('Mock KoalaResponse', :body => '', :status => 200)
|
73
|
-
Koala.
|
79
|
+
expect(Koala).to receive(:make_request).with(*expected).and_return(response)
|
74
80
|
@service.api(*args)
|
75
81
|
end
|
76
82
|
|
77
83
|
it "returns the body of the request as JSON if no http_component is given" do
|
78
84
|
response = double('response', :body => 'body', :status => 200)
|
79
|
-
Koala.
|
85
|
+
allow(Koala).to receive(:make_request).and_return(response)
|
80
86
|
|
81
87
|
json_body = double('JSON body')
|
82
|
-
MultiJson.
|
88
|
+
allow(MultiJson).to receive(:load).and_return([json_body])
|
83
89
|
|
84
|
-
@service.api('anything').
|
90
|
+
expect(@service.api('anything')).to eq(json_body)
|
85
91
|
end
|
86
92
|
|
87
93
|
it "executes an error checking block if provided" do
|
88
94
|
response = Koala::HTTPService::Response.new(200, '{}', {})
|
89
|
-
Koala.
|
95
|
+
allow(Koala).to receive(:make_request).and_return(response)
|
90
96
|
|
91
97
|
yield_test = double('Yield Tester')
|
92
|
-
yield_test.
|
98
|
+
expect(yield_test).to receive(:pass)
|
93
99
|
|
94
100
|
@service.api('anything', {}, "get") do |arg|
|
95
101
|
yield_test.pass
|
96
|
-
arg.
|
102
|
+
expect(arg).to eq(response)
|
97
103
|
end
|
98
104
|
end
|
99
105
|
|
100
106
|
it "raises an API error if the HTTP response code is greater than or equal to 500" do
|
101
|
-
Koala.
|
107
|
+
allow(Koala).to receive(:make_request).and_return(Koala::HTTPService::Response.new(500, 'response body', {}))
|
102
108
|
|
103
|
-
|
109
|
+
expect { @service.api('anything') }.to raise_exception(Koala::Facebook::APIError)
|
104
110
|
end
|
105
111
|
|
106
112
|
it "handles rogue true/false as responses" do
|
107
|
-
Koala.
|
108
|
-
@service.api('anything').
|
113
|
+
expect(Koala).to receive(:make_request).and_return(Koala::HTTPService::Response.new(200, 'true', {}))
|
114
|
+
expect(@service.api('anything')).to be_truthy
|
109
115
|
|
110
|
-
Koala.
|
111
|
-
@service.api('anything').
|
116
|
+
expect(Koala).to receive(:make_request).and_return(Koala::HTTPService::Response.new(200, 'false', {}))
|
117
|
+
expect(@service.api('anything')).to be_falsey
|
112
118
|
end
|
113
119
|
|
114
120
|
describe "with regard to leading slashes" do
|
115
121
|
it "adds a leading / to the path if not present" do
|
116
122
|
path = "anything"
|
117
|
-
Koala.
|
123
|
+
expect(Koala).to receive(:make_request).with("/#{path}", anything, anything, anything).and_return(Koala::HTTPService::Response.new(200, 'true', {}))
|
118
124
|
@service.api(path)
|
119
125
|
end
|
120
126
|
|
121
127
|
it "doesn't change the path if a leading / is present" do
|
122
128
|
path = "/anything"
|
123
|
-
Koala.
|
129
|
+
expect(Koala).to receive(:make_request).with(path, anything, anything, anything).and_return(Koala::HTTPService::Response.new(200, 'true', {}))
|
124
130
|
@service.api(path)
|
125
131
|
end
|
126
132
|
end
|
@@ -150,4 +156,55 @@ describe "Koala::Facebook::API" do
|
|
150
156
|
it_should_behave_like "Koala GraphAPI without an access token"
|
151
157
|
it_should_behave_like "Koala GraphAPI with GraphCollection"
|
152
158
|
end
|
159
|
+
|
160
|
+
context '#api' do
|
161
|
+
let(:access_token) { 'access_token' }
|
162
|
+
let(:api) { Koala::Facebook::API.new(access_token) }
|
163
|
+
let(:path) { '/path' }
|
164
|
+
let(:appsecret) { 'appsecret' }
|
165
|
+
let(:token_args) { { 'access_token' => access_token } }
|
166
|
+
let(:appsecret_proof_args) { { 'appsecret_proof' => OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha256'), appsecret, access_token) } }
|
167
|
+
let(:verb) { 'get' }
|
168
|
+
let(:response) { Koala::HTTPService::Response.new(200, '', '') }
|
169
|
+
|
170
|
+
describe "the appsecret_proof arguments" do
|
171
|
+
describe "with an API access token present" do
|
172
|
+
describe "and with an appsecret included on API initialization " do
|
173
|
+
let(:api) { Koala::Facebook::API.new(access_token, appsecret) }
|
174
|
+
|
175
|
+
it "will be included by default" do
|
176
|
+
Koala.should_receive(:make_request).with(path, token_args.merge(appsecret_proof_args), verb, {}).and_return(response)
|
177
|
+
api.api(path, {}, verb, :appsecret_proof => true)
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
describe "but without an appsecret included on API initialization" do
|
182
|
+
it "will not be included" do
|
183
|
+
Koala.should_receive(:make_request).with(path, token_args, verb, {}).and_return(response)
|
184
|
+
api.api(path, {}, verb, :appsecret_proof => true)
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
describe "but without an API access token present" do
|
190
|
+
describe "and with an appsecret included on API initialization " do
|
191
|
+
let(:api) { Koala::Facebook::API.new(nil, appsecret) }
|
192
|
+
|
193
|
+
it "will not be included" do
|
194
|
+
Koala.should_receive(:make_request).with(path, {}, verb, {}).and_return(response)
|
195
|
+
api.api(path, {}, verb, :appsecret_proof => true)
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
describe "but without an appsecret included on API initialization" do
|
200
|
+
let(:api) { Koala::Facebook::API.new }
|
201
|
+
|
202
|
+
it "will not be included" do
|
203
|
+
Koala.should_receive(:make_request).with(path, {}, verb, {}).and_return(response)
|
204
|
+
api.api(path, {}, verb, :appsecret_proof => true)
|
205
|
+
end
|
206
|
+
end
|
207
|
+
end
|
208
|
+
end
|
209
|
+
end
|
153
210
|
end
|
data/spec/cases/error_spec.rb
CHANGED
@@ -2,23 +2,23 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Koala::Facebook::APIError do
|
4
4
|
it "is a Koala::KoalaError" do
|
5
|
-
Koala::Facebook::APIError.new(nil, nil).
|
5
|
+
expect(Koala::Facebook::APIError.new(nil, nil)).to be_a(Koala::KoalaError)
|
6
6
|
end
|
7
7
|
|
8
8
|
[:fb_error_type, :fb_error_code, :fb_error_subcode, :fb_error_message, :http_status, :response_body].each do |accessor|
|
9
9
|
it "has an accessor for #{accessor}" do
|
10
|
-
Koala::Facebook::APIError.instance_methods.map(&:to_sym).
|
11
|
-
Koala::Facebook::APIError.instance_methods.map(&:to_sym).
|
10
|
+
expect(Koala::Facebook::APIError.instance_methods.map(&:to_sym)).to include(accessor)
|
11
|
+
expect(Koala::Facebook::APIError.instance_methods.map(&:to_sym)).to include(:"#{accessor}=")
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
15
|
it "sets http_status to the provided status" do
|
16
16
|
error_response = '{ "error": {"type": "foo", "other_details": "bar"} }'
|
17
|
-
Koala::Facebook::APIError.new(400, error_response).response_body.
|
17
|
+
expect(Koala::Facebook::APIError.new(400, error_response).response_body).to eq(error_response)
|
18
18
|
end
|
19
19
|
|
20
20
|
it "sets response_body to the provided response body" do
|
21
|
-
Koala::Facebook::APIError.new(400, '').http_status.
|
21
|
+
expect(Koala::Facebook::APIError.new(400, '').http_status).to eq(400)
|
22
22
|
end
|
23
23
|
|
24
24
|
context "with an error_info hash" do
|
@@ -39,12 +39,12 @@ describe Koala::Facebook::APIError do
|
|
39
39
|
:fb_error_subcode => 'subcode'
|
40
40
|
}.each_pair do |accessor, value|
|
41
41
|
it "sets #{accessor} to #{value}" do
|
42
|
-
error.send(accessor).
|
42
|
+
expect(error.send(accessor)).to eq(value)
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
46
|
it "sets the error message \"type: error_info['type'], code: error_info['code'], error_subcode: error_info['error_subcode'], message: error_info['message'] [HTTP http_status]\"" do
|
47
|
-
error.message.
|
47
|
+
expect(error.message).to eq("type: type, code: 1, error_subcode: subcode, message: message [HTTP 400]")
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
@@ -52,7 +52,7 @@ describe Koala::Facebook::APIError do
|
|
52
52
|
it "sets the error message \"error_info [HTTP http_status]\"" do
|
53
53
|
error_info = "Facebook is down."
|
54
54
|
error = Koala::Facebook::APIError.new(400, '', error_info)
|
55
|
-
error.message.
|
55
|
+
expect(error.message).to eq("Facebook is down. [HTTP 400]")
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
@@ -66,7 +66,7 @@ describe Koala::Facebook::APIError do
|
|
66
66
|
:fb_error_code => 1,
|
67
67
|
:fb_error_subcode => 'subcode'
|
68
68
|
}.each_pair do |accessor, value|
|
69
|
-
error.send(accessor).
|
69
|
+
expect(error.send(accessor)).to eq(value)
|
70
70
|
end
|
71
71
|
end
|
72
72
|
end
|
@@ -75,42 +75,42 @@ end
|
|
75
75
|
|
76
76
|
describe Koala::KoalaError do
|
77
77
|
it "is a StandardError" do
|
78
|
-
Koala::KoalaError.new.
|
78
|
+
expect(Koala::KoalaError.new).to be_a(StandardError)
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
82
82
|
describe Koala::Facebook::OAuthSignatureError do
|
83
83
|
it "is a Koala::KoalaError" do
|
84
|
-
Koala::KoalaError.new.
|
84
|
+
expect(Koala::KoalaError.new).to be_a(Koala::KoalaError)
|
85
85
|
end
|
86
86
|
end
|
87
87
|
|
88
88
|
describe Koala::Facebook::BadFacebookResponse do
|
89
89
|
it "is a Koala::Facebook::APIError" do
|
90
|
-
Koala::Facebook::BadFacebookResponse.new(nil, nil).
|
90
|
+
expect(Koala::Facebook::BadFacebookResponse.new(nil, nil)).to be_a(Koala::Facebook::APIError)
|
91
91
|
end
|
92
92
|
end
|
93
93
|
|
94
94
|
describe Koala::Facebook::OAuthTokenRequestError do
|
95
95
|
it "is a Koala::Facebook::APIError" do
|
96
|
-
Koala::Facebook::OAuthTokenRequestError.new(nil, nil).
|
96
|
+
expect(Koala::Facebook::OAuthTokenRequestError.new(nil, nil)).to be_a(Koala::Facebook::APIError)
|
97
97
|
end
|
98
98
|
end
|
99
99
|
|
100
100
|
describe Koala::Facebook::ServerError do
|
101
101
|
it "is a Koala::Facebook::APIError" do
|
102
|
-
Koala::Facebook::ServerError.new(nil, nil).
|
102
|
+
expect(Koala::Facebook::ServerError.new(nil, nil)).to be_a(Koala::Facebook::APIError)
|
103
103
|
end
|
104
104
|
end
|
105
105
|
|
106
106
|
describe Koala::Facebook::ClientError do
|
107
107
|
it "is a Koala::Facebook::APIError" do
|
108
|
-
Koala::Facebook::ClientError.new(nil, nil).
|
108
|
+
expect(Koala::Facebook::ClientError.new(nil, nil)).to be_a(Koala::Facebook::APIError)
|
109
109
|
end
|
110
110
|
end
|
111
111
|
|
112
112
|
describe Koala::Facebook::AuthenticationError do
|
113
113
|
it "is a Koala::Facebook::ClientError" do
|
114
|
-
Koala::Facebook::AuthenticationError.new(nil, nil).
|
114
|
+
expect(Koala::Facebook::AuthenticationError.new(nil, nil)).to be_a(Koala::Facebook::ClientError)
|
115
115
|
end
|
116
116
|
end
|