koala 1.2.1 → 1.3.0

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.
Files changed (55) hide show
  1. data/.gitignore +3 -1
  2. data/.rspec +1 -0
  3. data/.travis.yml +4 -0
  4. data/.yardopts +3 -0
  5. data/CHANGELOG +28 -0
  6. data/Gemfile +14 -0
  7. data/Guardfile +6 -0
  8. data/koala.gemspec +3 -3
  9. data/lib/koala/api/batch_operation.rb +83 -0
  10. data/lib/koala/api/graph_api.rb +476 -0
  11. data/lib/koala/{graph_batch_api.rb → api/graph_batch_api.rb} +22 -17
  12. data/lib/koala/api/graph_collection.rb +107 -0
  13. data/lib/koala/api/legacy.rb +26 -0
  14. data/lib/koala/{rest_api.rb → api/rest_api.rb} +34 -13
  15. data/lib/koala/api.rb +93 -0
  16. data/lib/koala/http_service/multipart_request.rb +41 -0
  17. data/lib/koala/http_service/response.rb +18 -0
  18. data/lib/koala/http_service/uploadable_io.rb +187 -0
  19. data/lib/koala/http_service.rb +69 -20
  20. data/lib/koala/oauth.rb +170 -36
  21. data/lib/koala/realtime_updates.rb +89 -51
  22. data/lib/koala/test_users.rb +122 -32
  23. data/lib/koala/utils.rb +11 -4
  24. data/lib/koala/version.rb +1 -1
  25. data/lib/koala.rb +16 -96
  26. data/readme.md +9 -9
  27. data/spec/cases/api_spec.rb +19 -12
  28. data/spec/cases/error_spec.rb +10 -0
  29. data/spec/cases/graph_api_batch_spec.rb +100 -58
  30. data/spec/cases/graph_collection_spec.rb +23 -7
  31. data/spec/cases/http_service_spec.rb +5 -26
  32. data/spec/cases/koala_spec.rb +22 -4
  33. data/spec/cases/legacy_spec.rb +115 -0
  34. data/spec/cases/multipart_request_spec.rb +7 -7
  35. data/spec/cases/oauth_spec.rb +134 -48
  36. data/spec/cases/realtime_updates_spec.rb +154 -47
  37. data/spec/cases/test_users_spec.rb +276 -219
  38. data/spec/cases/uploadable_io_spec.rb +1 -1
  39. data/spec/cases/utils_spec.rb +29 -5
  40. data/spec/fixtures/mock_facebook_responses.yml +41 -30
  41. data/spec/spec_helper.rb +3 -0
  42. data/spec/support/custom_matchers.rb +28 -0
  43. data/spec/support/graph_api_shared_examples.rb +192 -14
  44. data/spec/support/koala_test.rb +10 -1
  45. data/spec/support/mock_http_service.rb +2 -2
  46. data/spec/support/rest_api_shared_examples.rb +5 -165
  47. metadata +75 -99
  48. data/lib/koala/batch_operation.rb +0 -74
  49. data/lib/koala/graph_api.rb +0 -270
  50. data/lib/koala/graph_collection.rb +0 -59
  51. data/lib/koala/multipart_request.rb +0 -35
  52. data/lib/koala/uploadable_io.rb +0 -181
  53. data/spec/cases/graph_and_rest_api_spec.rb +0 -22
  54. data/spec/cases/graph_api_spec.rb +0 -22
  55. data/spec/cases/rest_api_spec.rb +0 -22
@@ -0,0 +1,115 @@
1
+ require 'spec_helper'
2
+
3
+ # Support for legacy / deprecated interfaces
4
+ describe "legacy APIs" do
5
+
6
+ it "deprecates the REST API" do
7
+ api = Koala::Facebook::API.new
8
+ api.stub(:api)
9
+ Koala::Utils.should_receive(:deprecate)
10
+ api.rest_call("stuff")
11
+ end
12
+
13
+ describe Koala::Facebook::GraphAPI do
14
+ describe "class consolidation" do
15
+ before :each do
16
+ Koala::Utils.stub(:deprecate) # avoid actual messages to stderr
17
+ end
18
+
19
+ it "still allows you to instantiate a GraphAndRestAPI object" do
20
+ api = Koala::Facebook::GraphAPI.new("token").should be_a(Koala::Facebook::GraphAPI)
21
+ end
22
+
23
+ it "ultimately creates an API object" do
24
+ api = Koala::Facebook::GraphAPI.new("token").should be_a(Koala::Facebook::API)
25
+ end
26
+
27
+ it "fires a depreciation warning" do
28
+ Koala::Utils.should_receive(:deprecate)
29
+ api = Koala::Facebook::GraphAPI.new("token")
30
+ end
31
+ end
32
+ end
33
+
34
+ describe Koala::Facebook::RestAPI do
35
+ describe "class consolidation" do
36
+ before :each do
37
+ Koala::Utils.stub(:deprecate) # avoid actual messages to stderr
38
+ end
39
+
40
+ it "still allows you to instantiate a GraphAndRestAPI object" do
41
+ api = Koala::Facebook::RestAPI.new("token").should be_a(Koala::Facebook::RestAPI)
42
+ end
43
+
44
+ it "ultimately creates an API object" do
45
+ api = Koala::Facebook::RestAPI.new("token").should be_a(Koala::Facebook::API)
46
+ end
47
+
48
+ it "fires a depreciation warning" do
49
+ Koala::Utils.should_receive(:deprecate)
50
+ api = Koala::Facebook::RestAPI.new("token")
51
+ end
52
+ end
53
+ end
54
+
55
+ describe Koala::Facebook::GraphAndRestAPI do
56
+ describe "class consolidation" do
57
+ before :each do
58
+ Koala::Utils.stub(:deprecate) # avoid actual messages to stderr
59
+ end
60
+
61
+ it "still allows you to instantiate a GraphAndRestAPI object" do
62
+ api = Koala::Facebook::GraphAndRestAPI.new("token").should be_a(Koala::Facebook::GraphAndRestAPI)
63
+ end
64
+
65
+ it "ultimately creates an API object" do
66
+ api = Koala::Facebook::GraphAndRestAPI.new("token").should be_a(Koala::Facebook::API)
67
+ end
68
+
69
+ it "fires a depreciation warning" do
70
+ Koala::Utils.should_receive(:deprecate)
71
+ api = Koala::Facebook::GraphAndRestAPI.new("token")
72
+ end
73
+ end
74
+ end
75
+
76
+ {:typhoeus => Koala::TyphoeusService, :net_http => Koala::NetHTTPService}.each_pair do |adapter, module_class|
77
+ describe module_class.to_s do
78
+ it "responds to deprecated_interface" do
79
+ module_class.should respond_to(:deprecated_interface)
80
+ end
81
+
82
+ it "issues a deprecation warning" do
83
+ Koala::Utils.should_receive(:deprecate)
84
+ module_class.deprecated_interface
85
+ end
86
+
87
+ it "sets the default adapter to #{adapter}" do
88
+ module_class.deprecated_interface
89
+ Faraday.default_adapter.should == adapter
90
+ end
91
+ end
92
+ end
93
+
94
+ describe "moved classes" do
95
+ it "allows you to access Koala::HTTPService::MultipartRequest through the Koala module" do
96
+ Koala::MultipartRequest.should == Koala::HTTPService::MultipartRequest
97
+ end
98
+
99
+ it "allows you to access Koala::Response through the Koala module" do
100
+ Koala::Response.should == Koala::HTTPService::Response
101
+ end
102
+
103
+ it "allows you to access Koala::Response through the Koala module" do
104
+ Koala::UploadableIO.should == Koala::HTTPService::UploadableIO
105
+ end
106
+
107
+ it "allows you to access Koala::Facebook::GraphBatchAPI::BatchOperation through the Koala::Facebook module" do
108
+ Koala::Facebook::BatchOperation.should == Koala::Facebook::GraphBatchAPI::BatchOperation
109
+ end
110
+
111
+ it "allows you to access Koala::Facebook::API::GraphCollection through the Koala::Facebook module" do
112
+ Koala::Facebook::GraphCollection.should == Koala::Facebook::API::GraphCollection
113
+ end
114
+ end
115
+ end
@@ -1,18 +1,18 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Koala::MultipartRequest do
3
+ describe Koala::HTTPService::MultipartRequest do
4
4
  it "is a subclass of Faraday::Request::Multipart" do
5
- Koala::MultipartRequest.superclass.should == Faraday::Request::Multipart
5
+ Koala::HTTPService::MultipartRequest.superclass.should == Faraday::Request::Multipart
6
6
  end
7
7
 
8
8
  it "defines mime_type as multipart/form-data" do
9
- Koala::MultipartRequest.mime_type.should == 'multipart/form-data'
9
+ Koala::HTTPService::MultipartRequest.mime_type.should == 'multipart/form-data'
10
10
  end
11
11
 
12
- describe ".process_request?" do
12
+ describe "#process_request?" do
13
13
  before :each do
14
14
  @env = {}
15
- @multipart = Koala::MultipartRequest.new
15
+ @multipart = Koala::HTTPService::MultipartRequest.new
16
16
  @multipart.stub(:request_type).and_return("")
17
17
  end
18
18
 
@@ -43,10 +43,10 @@ describe Koala::MultipartRequest do
43
43
  end
44
44
  end
45
45
 
46
- describe ".process_params" do
46
+ describe "#process_params" do
47
47
  before :each do
48
48
  @parent = Faraday::Request::Multipart.new
49
- @multipart = Koala::MultipartRequest.new
49
+ @multipart = Koala::HTTPService::MultipartRequest.new
50
50
  @block = lambda {|k, v| "#{k}=#{v}"}
51
51
  end
52
52
 
@@ -29,26 +29,27 @@ describe "Koala::Facebook::OAuth" do
29
29
  @time.stub!(:to_i).and_return(1273363199)
30
30
  end
31
31
 
32
- # initialization
33
- it "properly initializes" do
34
- @oauth.should
35
- end
32
+ describe ".new" do
33
+ it "properly initializes" do
34
+ @oauth.should
35
+ end
36
36
 
37
- it "properly sets attributes" do
38
- (@oauth.app_id == @app_id &&
39
- @oauth.app_secret == @secret &&
40
- @oauth.oauth_callback_url == @callback_url).should be_true
41
- end
37
+ it "properly sets attributes" do
38
+ (@oauth.app_id == @app_id &&
39
+ @oauth.app_secret == @secret &&
40
+ @oauth.oauth_callback_url == @callback_url).should be_true
41
+ end
42
42
 
43
- it "properly initializes without a callback_url" do
44
- @oauth = Koala::Facebook::OAuth.new(@app_id, @secret)
45
- end
43
+ it "properly initializes without a callback_url" do
44
+ @oauth = Koala::Facebook::OAuth.new(@app_id, @secret)
45
+ end
46
46
 
47
- it "properly sets attributes without a callback URL" do
48
- @oauth = Koala::Facebook::OAuth.new(@app_id, @secret)
49
- (@oauth.app_id == @app_id &&
50
- @oauth.app_secret == @secret &&
51
- @oauth.oauth_callback_url == nil).should be_true
47
+ it "properly sets attributes without a callback URL" do
48
+ @oauth = Koala::Facebook::OAuth.new(@app_id, @secret)
49
+ (@oauth.app_id == @app_id &&
50
+ @oauth.app_secret == @secret &&
51
+ @oauth.oauth_callback_url == nil).should be_true
52
+ end
52
53
  end
53
54
 
54
55
  describe "for cookie parsing" do
@@ -103,10 +104,26 @@ describe "Koala::Facebook::OAuth" do
103
104
  @oauth.get_user_info_from_cookies(@cookie)["access_token"].should == @token
104
105
  end
105
106
 
106
- it "returns nil if the call to FB fails" do
107
+ it "returns nil if the call to FB returns no data" do
107
108
  @oauth.stub(:get_access_token_info).and_return(nil)
108
109
  @oauth.get_user_info_from_cookies(@cookie).should be_nil
109
110
  end
111
+
112
+ it "returns nil if the call to FB returns an expired code error" do
113
+ @oauth.stub(:get_access_token_info).and_raise(Koala::Facebook::APIError.new(
114
+ "type" => "OAuthException",
115
+ "message" => "Code was invalid or expired. Session has expired at unix time 1324044000. The current unix time is 1324300957."
116
+ ))
117
+ @oauth.get_user_info_from_cookies(@cookie).should be_nil
118
+ end
119
+
120
+ it "raises the error if the call to FB returns a different error" do
121
+ @oauth.stub(:get_access_token_info).and_raise(Koala::Facebook::APIError.new(
122
+ "type" => "OtherError",
123
+ "message" => "A Facebook Error"
124
+ ))
125
+ expect { @oauth.get_user_info_from_cookies(@cookie) }.to raise_exception(Koala::Facebook::APIError)
126
+ end
110
127
  end
111
128
 
112
129
  it "doesn't parse invalid cookies" do
@@ -165,12 +182,12 @@ describe "Koala::Facebook::OAuth" do
165
182
  @oauth.stub(:get_access_token_info).and_return("access_token" => "my token")
166
183
  end
167
184
 
168
- it "uses get_user_info_from_cookies to parse the cookies" do
169
- @oauth.should_receive(:get_user_info_from_cookies).with(@cookie).and_return({})
185
+ it "does not uses get_user_info_from_cookies to parse the cookies" do
186
+ @oauth.should_not_receive(:get_user_info_from_cookies).with(@cookie).and_return({})
170
187
  @oauth.get_user_from_cookies(@cookie)
171
188
  end
172
189
 
173
- it "uses return the token string if the cookies are valid" do
190
+ it "uses return the facebook user id string if the cookies are valid" do
174
191
  result = @oauth.get_user_from_cookies(@cookie)
175
192
  result.should == "2905623" # the user who generated the original test cookie
176
193
  end
@@ -209,88 +226,157 @@ describe "Koala::Facebook::OAuth" do
209
226
  end
210
227
  end
211
228
 
212
- # OAuth URLs
213
-
214
229
  describe "for URL generation" do
215
-
216
- describe "for OAuth codes" do
217
- # url_for_oauth_code
230
+ describe "#url_for_oauth_code" do
218
231
  it "generates a properly formatted OAuth code URL with the default values" do
219
232
  url = @oauth.url_for_oauth_code
220
- url.should == "https://#{Koala::Facebook::GRAPH_SERVER}/oauth/authorize?client_id=#{@app_id}&redirect_uri=#{@callback_url}"
233
+ url.should match_url("https://#{Koala::Facebook::GRAPH_SERVER}/oauth/authorize?client_id=#{@app_id}&redirect_uri=#{CGI.escape @callback_url}")
221
234
  end
222
235
 
223
236
  it "generates a properly formatted OAuth code URL when a callback is given" do
224
237
  callback = "foo.com"
225
238
  url = @oauth.url_for_oauth_code(:callback => callback)
226
- url.should == "https://#{Koala::Facebook::GRAPH_SERVER}/oauth/authorize?client_id=#{@app_id}&redirect_uri=#{callback}"
239
+ url.should match_url("https://#{Koala::Facebook::GRAPH_SERVER}/oauth/authorize?client_id=#{@app_id}&redirect_uri=#{callback}")
227
240
  end
228
241
 
229
242
  it "generates a properly formatted OAuth code URL when permissions are requested as a string" do
230
243
  permissions = "publish_stream,read_stream"
231
244
  url = @oauth.url_for_oauth_code(:permissions => permissions)
232
- url.should == "https://#{Koala::Facebook::GRAPH_SERVER}/oauth/authorize?client_id=#{@app_id}&redirect_uri=#{@callback_url}&scope=#{permissions}"
245
+ url.should match_url("https://#{Koala::Facebook::GRAPH_SERVER}/oauth/authorize?client_id=#{@app_id}&scope=#{CGI.escape permissions}&redirect_uri=#{CGI.escape @callback_url}")
233
246
  end
234
247
 
235
248
  it "generates a properly formatted OAuth code URL when permissions are requested as a string" do
236
249
  permissions = ["publish_stream", "read_stream"]
237
250
  url = @oauth.url_for_oauth_code(:permissions => permissions)
238
- url.should == "https://#{Koala::Facebook::GRAPH_SERVER}/oauth/authorize?client_id=#{@app_id}&redirect_uri=#{@callback_url}&scope=#{permissions.join(",")}"
251
+ url.should match_url("https://#{Koala::Facebook::GRAPH_SERVER}/oauth/authorize?client_id=#{@app_id}&scope=#{CGI.escape permissions.join(",")}&redirect_uri=#{CGI.escape @callback_url}")
239
252
  end
240
253
 
241
254
  it "generates a properly formatted OAuth code URL when both permissions and callback are provided" do
242
255
  permissions = "publish_stream,read_stream"
243
256
  callback = "foo.com"
244
257
  url = @oauth.url_for_oauth_code(:callback => callback, :permissions => permissions)
245
- url.should == "https://#{Koala::Facebook::GRAPH_SERVER}/oauth/authorize?client_id=#{@app_id}&redirect_uri=#{callback}&scope=#{permissions}"
258
+ url.should match_url("https://#{Koala::Facebook::GRAPH_SERVER}/oauth/authorize?client_id=#{@app_id}&scope=#{CGI.escape permissions}&redirect_uri=#{CGI.escape callback}")
246
259
  end
247
260
 
248
261
  it "generates a properly formatted OAuth code URL when a display is given as a string" do
249
262
  url = @oauth.url_for_oauth_code(:display => "page")
250
- url.should == "https://#{Koala::Facebook::GRAPH_SERVER}/oauth/authorize?client_id=#{@app_id}&redirect_uri=#{@callback_url}&display=page"
263
+ url.should match_url("https://#{Koala::Facebook::GRAPH_SERVER}/oauth/authorize?client_id=#{@app_id}&display=page&redirect_uri=#{CGI.escape @callback_url}")
251
264
  end
252
265
 
253
266
  it "raises an exception if no callback is given in initialization or the call" do
254
267
  oauth2 = Koala::Facebook::OAuth.new(@app_id, @secret)
255
268
  lambda { oauth2.url_for_oauth_code }.should raise_error(ArgumentError)
256
269
  end
270
+
271
+ it "includes any additional options as URL parameters, appropriately escaped" do
272
+ params = {
273
+ :url => "http://foo.bar?c=2",
274
+ :email => "cdc@b.com"
275
+ }
276
+ url = @oauth.url_for_oauth_code(params)
277
+ params.each_pair do |key, value|
278
+ url.should =~ /[\&\?]#{key}=#{CGI.escape value}/
279
+ end
280
+ end
257
281
  end
258
282
 
259
- describe "for access token URLs" do
283
+ describe "#url_for_access_token" do
260
284
  before :each do
261
285
  # since we're just composing a URL here, we don't need to have a real code
262
286
  @code ||= "test_code"
263
287
  end
264
-
265
- # url_for_access_token
288
+
266
289
  it "generates a properly formatted OAuth token URL when provided a code" do
267
290
  url = @oauth.url_for_access_token(@code)
268
- url.should == "https://#{Koala::Facebook::GRAPH_SERVER}/oauth/access_token?client_id=#{@app_id}&redirect_uri=#{@callback_url}&client_secret=#{@secret}&code=#{@code}"
291
+ url.should match_url("https://#{Koala::Facebook::GRAPH_SERVER}/oauth/access_token?client_id=#{@app_id}&code=#{@code}&client_secret=#{@secret}&redirect_uri=#{CGI.escape @callback_url}").should be_true
269
292
  end
270
293
 
271
294
  it "generates a properly formatted OAuth token URL when provided a callback" do
272
295
  callback = "foo.com"
273
296
  url = @oauth.url_for_access_token(@code, :callback => callback)
274
- url.should == "https://#{Koala::Facebook::GRAPH_SERVER}/oauth/access_token?client_id=#{@app_id}&redirect_uri=#{callback}&client_secret=#{@secret}&code=#{@code}"
297
+ url.should match_url("https://#{Koala::Facebook::GRAPH_SERVER}/oauth/access_token?client_id=#{@app_id}&code=#{@code}&client_secret=#{@secret}&redirect_uri=#{CGI.escape callback}").should be_true
298
+ end
299
+
300
+ it "includes any additional options as URL parameters, appropriately escaped" do
301
+ params = {
302
+ :url => "http://foo.bar?c=2",
303
+ :email => "cdc@b.com"
304
+ }
305
+ url = @oauth.url_for_access_token(@code, params)
306
+ params.each_pair do |key, value|
307
+ url.should =~ /[\&\?]#{key}=#{CGI.escape value}/
308
+ end
309
+ end
310
+ end
311
+
312
+ describe "#url_for_dialog" do
313
+ it "builds the base properly" do
314
+ dialog_type = "my_dialog_type"
315
+ @oauth.url_for_dialog(dialog_type).should =~ /^http:\/\/#{Koala::Facebook::DIALOG_HOST}\/dialog\/#{dialog_type}/
316
+ end
317
+
318
+ it "adds the app_id/client_id to the url" do
319
+ automatic_params = {:app_id => @app_id, :client_id => @client_id}
320
+ url = @oauth.url_for_dialog("foo", automatic_params)
321
+ automatic_params.each_pair do |key, value|
322
+ # we're slightly simplifying how encode_params works, but for strings/ints, it's okay
323
+ url.should =~ /[\&\?]#{key}=#{CGI.escape value.to_s}/
324
+ end
325
+ end
326
+
327
+ it "includes any additional options as URL parameters, appropriately escaped" do
328
+ params = {
329
+ :url => "http://foo.bar?c=2",
330
+ :email => "cdc@b.com"
331
+ }
332
+ url = @oauth.url_for_dialog("friends", params)
333
+ params.each_pair do |key, value|
334
+ # we're slightly simplifying how encode_params works, but strings/ints, it's okay
335
+ url.should =~ /[\&\?]#{key}=#{CGI.escape value.to_s}/
336
+ end
337
+ end
338
+
339
+ describe "real examples from FB documentation" do
340
+ # see http://developers.facebook.com/docs/reference/dialogs/
341
+ # slightly brittle (e.g. if parameter order changes), but still useful
342
+ it "can generate a send dialog" do
343
+ url = @oauth.url_for_dialog("send", :name => "People Argue Just to Win", :link => "http://www.nytimes.com/2011/06/15/arts/people-argue-just-to-win-scholars-assert.html")
344
+ url.should match_url("http://www.facebook.com/dialog/send?app_id=#{@app_id}&client_id=#{@app_id}&link=http%3A%2F%2Fwww.nytimes.com%2F2011%2F06%2F15%2Farts%2Fpeople-argue-just-to-win-scholars-assert.html&name=People+Argue+Just+to+Win&redirect_uri=#{CGI.escape @callback_url}")
345
+ end
346
+
347
+ it "can generate a feed dialog" do
348
+ url = @oauth.url_for_dialog("feed", :name => "People Argue Just to Win", :link => "http://www.nytimes.com/2011/06/15/arts/people-argue-just-to-win-scholars-assert.html")
349
+ url.should match_url("http://www.facebook.com/dialog/feed?app_id=#{@app_id}&client_id=#{@app_id}&link=http%3A%2F%2Fwww.nytimes.com%2F2011%2F06%2F15%2Farts%2Fpeople-argue-just-to-win-scholars-assert.html&name=People+Argue+Just+to+Win&redirect_uri=#{CGI.escape @callback_url}")
350
+ end
351
+
352
+ it "can generate a oauth dialog" do
353
+ url = @oauth.url_for_dialog("oauth", :scope => "email", :response_type => "token")
354
+ url.should match_url("http://www.facebook.com/dialog/oauth?app_id=#{@app_id}&client_id=#{@app_id}&redirect_uri=#{CGI.escape @callback_url}&response_type=token&scope=email")
355
+ end
356
+
357
+ it "can generate a pay dialog" do
358
+ url = @oauth.url_for_dialog("pay", :order_id => "foo", :credits_purchase => false)
359
+ url.should match_url("http://www.facebook.com/dialog/pay?app_id=#{@app_id}&client_id=#{@app_id}&order_id=foo&credits_purchase=false&redirect_uri=#{CGI.escape @callback_url}")
360
+ end
275
361
  end
276
362
  end
277
363
  end
278
364
 
279
365
  describe "for fetching access tokens" do
280
- describe ".get_access_token_info" do
366
+ describe "#get_access_token_info" do
281
367
  it "uses options[:redirect_uri] if provided" do
282
368
  uri = "foo"
283
- Koala.should_receive(:make_request).with(anything, hash_including(:redirect_uri => uri), anything, anything).and_return(Koala::Response.new(200, "", {}))
369
+ Koala.should_receive(:make_request).with(anything, hash_including(:redirect_uri => uri), anything, anything).and_return(Koala::HTTPService::Response.new(200, "", {}))
284
370
  @oauth.get_access_token_info(@code, :redirect_uri => uri)
285
371
  end
286
372
 
287
373
  it "uses the redirect_uri used to create the @oauth if no :redirect_uri option is provided" do
288
- Koala.should_receive(:make_request).with(anything, hash_including(:redirect_uri => @callback_url), anything, anything).and_return(Koala::Response.new(200, "", {}))
374
+ Koala.should_receive(:make_request).with(anything, hash_including(:redirect_uri => @callback_url), anything, anything).and_return(Koala::HTTPService::Response.new(200, "", {}))
289
375
  @oauth.get_access_token_info(@code)
290
376
  end
291
377
 
292
378
  it "makes a GET request" do
293
- Koala.should_receive(:make_request).with(anything, anything, "get", anything).and_return(Koala::Response.new(200, "", {}))
379
+ Koala.should_receive(:make_request).with(anything, anything, "get", anything).and_return(Koala::HTTPService::Response.new(200, "", {}))
294
380
  @oauth.get_access_token_info(@code)
295
381
  end
296
382
 
@@ -311,11 +397,11 @@ describe "Koala::Facebook::OAuth" do
311
397
  end
312
398
  end
313
399
 
314
- describe ".get_access_token" do
400
+ describe "#get_access_token" do
315
401
  # TODO refactor these to be proper tests with stubs and tests against real data
316
402
  it "passes on any options provided to make_request" do
317
403
  options = {:a => 2}
318
- Koala.should_receive(:make_request).with(anything, anything, anything, hash_including(options)).and_return(Koala::Response.new(200, "", {}))
404
+ Koala.should_receive(:make_request).with(anything, anything, anything, hash_including(options)).and_return(Koala::HTTPService::Response.new(200, "", {}))
319
405
  @oauth.get_access_token(@code, options)
320
406
  end
321
407
 
@@ -354,7 +440,7 @@ describe "Koala::Facebook::OAuth" do
354
440
 
355
441
  it "passes on any options provided to make_request" do
356
442
  options = {:a => 2}
357
- Koala.should_receive(:make_request).with(anything, anything, anything, hash_including(options)).and_return(Koala::Response.new(200, "", {}))
443
+ Koala.should_receive(:make_request).with(anything, anything, anything, hash_including(options)).and_return(Koala::HTTPService::Response.new(200, "", {}))
358
444
  @oauth.get_app_access_token_info(options)
359
445
  end
360
446
  end
@@ -373,7 +459,7 @@ describe "Koala::Facebook::OAuth" do
373
459
 
374
460
  it "passes on any options provided to make_request" do
375
461
  options = {:a => 2}
376
- Koala.should_receive(:make_request).with(anything, anything, anything, hash_including(options)).and_return(Koala::Response.new(200, "", {}))
462
+ Koala.should_receive(:make_request).with(anything, anything, anything, hash_including(options)).and_return(Koala::HTTPService::Response.new(200, "", {}))
377
463
  @oauth.get_app_access_token(options)
378
464
  end
379
465
  end
@@ -454,7 +540,7 @@ describe "Koala::Facebook::OAuth" do
454
540
 
455
541
  it "passes on any options provided to make_request" do
456
542
  options = {:a => 2}
457
- Koala.should_receive(:make_request).with(anything, anything, anything, hash_including(options)).and_return(Koala::Response.new(200, "[{}]", {}))
543
+ Koala.should_receive(:make_request).with(anything, anything, anything, hash_including(options)).and_return(Koala::HTTPService::Response.new(200, "[{}]", {}))
458
544
  @oauth.get_token_info_from_session_keys([], options)
459
545
  end
460
546
  end
@@ -486,7 +572,7 @@ describe "Koala::Facebook::OAuth" do
486
572
 
487
573
  it "passes on any options provided to make_request" do
488
574
  options = {:a => 2}
489
- Koala.should_receive(:make_request).with(anything, anything, anything, hash_including(options)).and_return(Koala::Response.new(200, "[{}]", {}))
575
+ Koala.should_receive(:make_request).with(anything, anything, anything, hash_including(options)).and_return(Koala::HTTPService::Response.new(200, "[{}]", {}))
490
576
  @oauth.get_tokens_from_session_keys([], options)
491
577
  end
492
578
  end
@@ -516,7 +602,7 @@ describe "Koala::Facebook::OAuth" do
516
602
 
517
603
  it "passes on any options provided to make_request" do
518
604
  options = {:a => 2}
519
- Koala.should_receive(:make_request).with(anything, anything, anything, hash_including(options)).and_return(Koala::Response.new(200, "[{}]", {}))
605
+ Koala.should_receive(:make_request).with(anything, anything, anything, hash_including(options)).and_return(Koala::HTTPService::Response.new(200, "[{}]", {}))
520
606
  @oauth.get_token_from_session_key("", options)
521
607
  end
522
608
  end