koala 1.5.0 → 1.6.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
@@ -14,9 +14,12 @@ describe "Koala::Facebook::TestUsers" do
14
14
  raise Exception, "Must supply OAuth app id, secret, app_access_token, and callback to run live subscription tests!"
15
15
  end
16
16
  end
17
-
17
+
18
18
  after :each do
19
19
  # clean up any test users
20
+ # Facebook only allows us 500 test users per app, so we have to clean up
21
+ # This would be a good place to clean up and accumulate all of them for
22
+ # later deletion.
20
23
  ((@network || []) + [@user1, @user2]).each do |u|
21
24
  puts "Unable to delete test user #{u.inspect}" if u && !(@test_users.delete(u) rescue false)
22
25
  end
@@ -128,7 +131,7 @@ describe "Koala::Facebook::TestUsers" do
128
131
  @test_users.create(true, nil, {}, options)
129
132
  end
130
133
  end
131
-
134
+
132
135
  describe "#list" do
133
136
  before :each do
134
137
  @user1 = @test_users.create(true, "read_stream")
@@ -142,9 +145,9 @@ describe "Koala::Facebook::TestUsers" do
142
145
  (first_user["id"] && first_user["access_token"] && first_user["login_url"]).should
143
146
  (second_user["id"] && second_user["access_token"] && second_user["login_url"]).should
144
147
  end
145
-
148
+
146
149
  it "accepts http options" do
147
- options = {:some_http_option => true}
150
+ options = {:some_http_option => true}
148
151
  @test_users.api.should_receive(:graph_call).with(anything, anything, anything, options)
149
152
  @test_users.list(options)
150
153
  end
@@ -169,13 +172,13 @@ describe "Koala::Facebook::TestUsers" do
169
172
  it "does not delete users when provided a false ID" do
170
173
  lambda { @test_users.delete("#{@user1['id']}1") }.should raise_exception(Koala::Facebook::APIError)
171
174
  end
172
-
175
+
173
176
  it "lets you specify http options that get passed through to the graph call" do
174
177
  options = {:some_http_option => true}
175
178
  # technically this goes through delete_object, but this makes it less brittle
176
179
  @test_users.graph_api.should_receive(:graph_call).with(anything, anything, anything, options)
177
180
  @test_users.delete("user", options)
178
- end
181
+ end
179
182
  end
180
183
 
181
184
  describe "#delete_all" do
@@ -187,20 +190,20 @@ describe "Koala::Facebook::TestUsers" do
187
190
  array.each {|item| batch_api.should_receive(:delete_object).with(item["id"]) }
188
191
  @test_users.delete_all
189
192
  end
190
-
193
+
191
194
  it "accepts http options that get passed to both list and the batch call" do
192
195
  options = {:some_http_option => true}
193
196
  @test_users.should_receive(:list).with(options).and_return([{"id" => rand}], [])
194
197
  @test_users.api.should_receive(:batch).with(options)
195
198
  @test_users.delete_all(options)
196
- end
197
-
199
+ end
200
+
198
201
  it "breaks if Facebook sends back the same list twice" do
199
202
  list = [{"id" => rand}]
200
203
  @test_users.should_receive(:list).any_number_of_times.and_return(list)
201
204
  @test_users.api.should_receive(:batch).once
202
205
  @test_users.delete_all
203
- end
206
+ end
204
207
  end
205
208
 
206
209
  describe "#update" do
@@ -221,9 +224,9 @@ describe "Koala::Facebook::TestUsers" do
221
224
  @test_users2.graph_api.should_receive(:graph_call).with(@user1["id"], @updates, anything, anything)
222
225
  @test_users2.update(@user1, @updates)
223
226
  end
224
-
227
+
225
228
  it "accepts an options hash" do
226
- options = {:some_http_option => true}
229
+ options = {:some_http_option => true}
227
230
  @test_users2.graph_api.should_receive(:graph_call).with(anything, anything, anything, options)
228
231
  @test_users2.update("foo", @updates, options)
229
232
  end
@@ -235,13 +238,13 @@ describe "Koala::Facebook::TestUsers" do
235
238
  user_info["name"].should == @updates[:name]
236
239
  end
237
240
  end
238
-
241
+
239
242
  describe "#befriend" do
240
243
  before :each do
241
244
  @user1 = @test_users.create(true, "read_stream")
242
245
  @user2 = @test_users.create(true, "read_stream,user_interests")
243
246
  end
244
-
247
+
245
248
  it "makes two users into friends with string hashes" do
246
249
  result = @test_users.befriend(@user1, @user2)
247
250
  result.should be_true
@@ -260,13 +263,13 @@ describe "Koala::Facebook::TestUsers" do
260
263
  it "does not accept user IDs anymore" do
261
264
  lambda { @test_users.befriend(@user1["id"], @user2["id"]) }.should raise_exception
262
265
  end
263
-
266
+
264
267
  it "accepts http options passed to both calls" do
265
- options = {:some_http_option => true}
268
+ options = {:some_http_option => true}
266
269
  # should come twice, once for each user
267
270
  Koala.http_service.should_receive(:make_request).with(anything, anything, anything, options).twice.and_return(Koala::HTTPService::Response.new(200, "{}", {}))
268
271
  @test_users.befriend(@user1, @user2, options)
269
- end
272
+ end
270
273
  end
271
274
  end # when used without network
272
275
 
@@ -318,7 +321,7 @@ describe "Koala::Facebook::TestUsers" do
318
321
 
319
322
  it "accepts http options that are passed to both the create and befriend calls" do
320
323
  count = 25
321
- options = {:some_http_option => true}
324
+ options = {:some_http_option => true}
322
325
  @test_users.should_receive(:create).exactly(count).times.with(anything, anything, options).and_return({})
323
326
  # there are more befriends than creates, but we don't need to do the extra work to calculate out the exact #
324
327
  @test_users.should_receive(:befriend).at_least(count).times.with(anything, anything, options)
@@ -33,7 +33,9 @@ graph_api:
33
33
 
34
34
  # Error responses for when a token is required, but not given
35
35
  token_required_responses: &token_required
36
- no_token: '{"error":{"type":"OAuthAccessTokenException", "message":"An access token is required to request this resource."}}'
36
+ no_token:
37
+ code: 400
38
+ body: '{"error":{"type":"OAuthAccessTokenException", "message":"An access token is required to request this resource."}}'
37
39
 
38
40
  # Common mock item responses
39
41
  item_deleted: &item_deleted
@@ -42,11 +44,15 @@ graph_api:
42
44
 
43
45
  # OAuth error response
44
46
  oauth_error: &oauth_error
45
- no_token: '{"error": {"code"=>2500, "type": "OAuthException", "message": "Error validating verification code."}}'
47
+ no_token:
48
+ code: 400
49
+ body: '{"error": {"code"=>2500, "type": "OAuthException", "message": "Error validating verification code."}}'
46
50
 
47
51
  # Subscription error response
48
52
  verification_error: &verification_error
49
- with_token: '{"error": {"code"=>2500, "type": "OAuthException", "message": "Error validating verification code."}}'
53
+ with_token:
54
+ code: 400
55
+ body: '{"error": {"code"=>2500, "type": "OAuthException", "message": "Error validating verification code."}}'
50
56
 
51
57
  test_user_uninstalled: &test_user_uninstalled
52
58
  post:
@@ -62,61 +68,63 @@ graph_api:
62
68
 
63
69
  # -- Stubbed Responses --
64
70
  root:
65
- ids=contextoptional,koppel:
71
+ ids=facebook,koppel:
66
72
  get:
67
- with_token: '{"contextoptional":"{}","koppel":"{}"}'
68
- no_token: '{"contextoptional":"{}","koppel":"{}"}'
73
+ with_token: '{"facebook":"{}","koppel":"{}"}'
74
+ no_token: '{"facebook":"{}","koppel":"{}"}'
69
75
 
70
76
  # Ruby 1.8.7 and 1.9.2 generate JSON with different key ordering, hence we have to dynamically generate it here
71
77
  batch=<%= MultiJson.dump([{"method" => "get", "relative_url" => "me"},{"method" => "get", "relative_url" => "koppel"}]) %>:
72
78
  post:
73
- with_token: '[{"body":"{\"id\":\"123\"}"}, {"body":"{\"id\":\"456\"}"}]'
79
+ with_token: '[{"code": 200, "body":"{\"id\":\"123\"}"}, {"code": 200, "body":"{\"id\":\"456\"}"}]'
74
80
  batch=<%= MultiJson.dump([{"method" => "get", "relative_url" => "me/picture"}]) %>:
75
81
  post:
76
- with_token: '[{"headers":[{"name":"Location","value":"http://google.com"}]}]'
82
+ with_token: '[{"code": 200, "headers":[{"name":"Location","value":"http://google.com"}]}]'
77
83
  batch=<%= MultiJson.dump([{"method" => "get", "relative_url" => "me"},{"method" => "get", "relative_url" => "me/friends"}]) %>:
78
84
  post:
79
- with_token: '[{"body":"{\"id\":\"123\"}"}, {"body":"{\"data\":[],\"paging\":{}}"}]'
85
+ with_token: '[{"code": 200, "body":"{\"id\":\"koppel\"}"}, {"code": 200, "body":"{\"data\":[{\"id\":\"lukeshepard\"}],\"paging\":{}}"}]'
80
86
  batch=<%= MultiJson.dump([{"method"=>"get", "relative_url"=>"me"}, {"method"=>"get", "relative_url"=>"#{OAUTH_DATA["app_id"]}/insights?access_token=#{CGI.escape APP_ACCESS_TOKEN}"}]) %>:
81
87
  post:
82
- with_token: '[{"body":"{\"id\":\"123\"}"}, {"body":"{\"data\":[],\"paging\":{}}"}]'
88
+ with_token: '[{"code": 200, "body":"{\"id\":\"123\"}"}, {"code": 200, "body":"{\"data\":[],\"paging\":{}}"}]'
83
89
  batch=<%= MultiJson.dump([{"method"=>"get", "relative_url"=>"2/invalidconnection"}, {"method"=>"get", "relative_url"=>"koppel?access_token=#{CGI.escape APP_ACCESS_TOKEN}"}]) %>:
84
90
  post:
85
- with_token: '[{"body": "{\"error\":{\"type\":\"AnError\", \"message\":\"An error occurred!.\"}}"},{"body":"{\"id\":\"123\"}"}]'
91
+ with_token: '[{"code": 400, "body": "{\"error\":{\"type\":\"AnError\", \"message\":\"An error occurred!.\"}}"},{"code": 200, "body":"{\"id\":\"123\"}"}]'
86
92
  batch=<%= MultiJson.dump([{"method"=>"post", "relative_url"=>"FEED_ITEM_BATCH/likes"}, {"method"=>"delete", "relative_url"=> "FEED_ITEM_BATCH"}]) %>:
87
93
  post:
88
- with_token: '[{"body": "{\"id\": \"MOCK_LIKE\"}"},{"body":true}]'
94
+ with_token: '[{"code": 200, "body": "{\"id\": \"MOCK_LIKE\"}"},{"code": 200, "body":true}]'
89
95
  batch=<%= MultiJson.dump([{"method" => "post", "relative_url" => "method/fql.query", "body" => "query=select+first_name+from+user+where+uid%3D2905623"}]) %>:
90
96
  post:
91
- with_token: '[{"body":"[{\"first_name\":\"Alex\"}]"}]'
97
+ with_token: '[{"code": 200, "body":"[{\"first_name\":\"Alex\"}]"}]'
92
98
 
93
99
  # dependencies
94
100
  batch=<%= MultiJson.dump([{"method"=>"get", "relative_url"=>"me", "name" => "getme"}, {"method"=>"get", "relative_url"=>"koppel", "depends_on" => "getme"}]) %>:
95
101
  post:
96
- with_token: '[null,{"body":"{\"id\":\"123\"}"}]'
102
+ with_token: '[null,{"code": 200, "body":"{\"id\":\"123\"}"}]'
97
103
  batch=<%= MultiJson.dump([{"method"=>"get", "relative_url"=>"2/invalidconnection", "name" => "getdata"}, {"method"=>"get", "relative_url"=>"koppel", "depends_on" => "getdata"}]) %>:
98
104
  post:
99
- with_token: '[{"body": "{\"error\":{\"type\":\"AnError\", \"message\":\"An error occurred!.\"}}"},null]'
105
+ with_token: '[{"code": 400, "body": "{\"error\":{\"type\":\"AnError\", \"message\":\"An error occurred!.\"}}"},null]'
100
106
  batch=<%= MultiJson.dump([{"method" => "get", "relative_url" => "me/friends?limit=5", "name" => "get-friends"}, {"method" => "get", "relative_url" => "?ids=#{CGI.escape "{result=get-friends:$.data.*.id}"}"}]) %>:
101
107
  post:
102
- with_token: '[null,{"body":"{}"}]'
108
+ with_token: '[null,{"code": 200, "body":"{}"}]'
103
109
  batch=<%= MultiJson.dump([{"method" => "get", "relative_url" => "me/friends?limit=5", "name" => "get-friends", "omit_response_on_success" => false}, {"method" => "get", "relative_url" => "?ids=#{CGI.escape "{result=get-friends:$.data.*.id}"}"}]) %>:
104
110
  post:
105
- with_token: '[{"body":"{\"data\":[],\"paging\":{}}"},{"body":"{}"}]'
111
+ with_token: '[{"code": 200, "body":"{\"data\":[],\"paging\":{}}"},{"code": 200, "body":"{}"}]'
106
112
  batch=<%= MultiJson.dump([{"method" => "get", "relative_url" => "me/friends?limit=5"}, {"method" => "get", "relative_url" => "?ids=#{CGI.escape "{result=i-dont-exist:$.data.*.id}"}"}]) %>:
107
113
  post:
108
- with_token: '{"error":190,"error_description":"Error validating access token."}'
114
+ with_token:
115
+ code: 400
116
+ body: '{"error_code":190,"error_description":"Error validating access token."}'
109
117
 
110
118
  # attached files tests
111
119
  batch=<%= MultiJson.dump([{"method"=>"post", "relative_url"=>"me/photos", "attached_files" => "op1_file0"}]) %>&op1_file0=[FILE]:
112
120
  post:
113
- with_token: '[{"body": "{\"error\":{\"type\":\"AnError\", \"message\":\"An error occurred!.\"}}"},null]'
121
+ with_token: '[{"code": 400, body": "{\"error\":{\"type\":\"AnError\", \"message\":\"An error occurred!.\"}}"},null]'
114
122
  batch=<%= MultiJson.dump([{"method"=>"post", "relative_url"=>"me/photos", "attached_files" => "op1_file0"}]) %>&op1_file0=[FILE]:
115
123
  post:
116
- with_token: '[{"body":"{\"id\": \"MOCK_PHOTO\"}"}]'
124
+ with_token: '[{"code": 200, "body":"{\"id\": \"MOCK_PHOTO\"}"}]'
117
125
  batch=<%= MultiJson.dump([{"method"=>"post", "relative_url"=>"me/photos", "attached_files" => "op1_file0"}, {"method"=>"post", "relative_url"=>"koppel/photos", "attached_files" => "op2_file0"}]) %>&op1_file0=[FILE]&op2_file0=[FILE]:
118
126
  post:
119
- with_token: '[{"body":"{\"id\": \"MOCK_PHOTO\"}"}, {"body":"{\"id\": \"MOCK_PHOTO\"}"}]'
127
+ with_token: '[{"code": 200, "body":"{\"id\": \"MOCK_PHOTO\"}"}, {"code": 200, "body":"{\"id\": \"MOCK_PHOTO\"}"}]'
120
128
 
121
129
 
122
130
 
@@ -196,13 +204,13 @@ graph_api:
196
204
  with_token: '{"id": 1, "name": 1, "updated_time": 1}'
197
205
  no_token: '{"id": 1, "name": 1}'
198
206
 
199
- /contextoptional:
207
+ /facebook:
200
208
  no_args:
201
209
  get:
202
210
  with_token: '{"id": 1, "name": 1}'
203
211
  no_token: '{"id": 1, "name": 1}'
204
212
 
205
- /contextoptional/photos:
213
+ /facebook/photos:
206
214
  no_args:
207
215
  get:
208
216
  with_token: '{"data": [{}], "paging": {"previous": "https:\/\/graph.facebook.com\/7204941866\/photos?limit=25&until=2008-09-15T18%3A30%3A25%2B0000", "next": "https:\/\/graph.facebook.com\/7204941866\/photos?limit=25&until=2008-09-15T18%3A30%3A25%2B0000"}}'
@@ -247,12 +255,12 @@ graph_api:
247
255
  no_token: '{"http://developers.facebook.com/blog/post/490": [], "http://developers.facebook.com/blog/post/472": []}'
248
256
  ids=:
249
257
  get:
250
- body: '{"error": {"type": "OAuthException","message": "Cannot specify an empty identifier"}}'
251
258
  code: 400
259
+ body: '{"error": {"type": "OAuthException","message": "Cannot specify an empty identifier"}}'
252
260
  no_args:
253
261
  get:
254
- body: '{"error": {"type": "Exception","message": "No node specified"}}'
255
262
  code: 500
263
+ body: '{"error": {"type": "Exception","message": "No node specified"}}'
256
264
 
257
265
  /search:
258
266
  q=facebook:
@@ -348,17 +356,23 @@ graph_api:
348
356
  code: 200
349
357
  callback_url=<%= SUBSCRIPTION_DATA["subscription_path"] %>foo&fields=name&object=user&verify_token=<%= SUBSCRIPTION_DATA["verify_token"] %>:
350
358
  post:
351
- with_token: '{"error":{"type":"Exception","message":"(#2200) subscription validation failed"}}'
359
+ with_token:
360
+ code: 400
361
+ body: '{"error":{"type":"Exception","message":"(#2200) subscription validation failed"}}'
352
362
  callback_url=foo&fields=name&object=user&verify_token=<%= SUBSCRIPTION_DATA["verify_token"] %>:
353
363
  post:
354
- with_token: '{"error":{"type":"Exception","message":"(#100) callback_url URL is not properly formatted"}}'
364
+ with_token:
365
+ code: 400
366
+ body: '{"error":{"type":"Exception","message":"(#100) callback_url URL is not properly formatted"}}'
355
367
  object=user:
356
368
  delete:
357
369
  with_token:
358
370
  code: 200
359
371
  object=kittens:
360
372
  delete:
361
- with_token: '{"error":{"type":"Exception","message":"(#100) Invalid parameter"}}'
373
+ with_token:
374
+ code: 400
375
+ body: '{"error":{"type":"Exception","message":"(#100) Invalid parameter"}}'
362
376
  no_args:
363
377
  delete:
364
378
  with_token:
@@ -456,7 +470,9 @@ graph_api:
456
470
  /9999999991:
457
471
  no_args:
458
472
  delete:
459
- with_token: '{"error": {"type": "OAuthException", "message": "Error validating verification code."}}'
473
+ with_token:
474
+ code: 400
475
+ body: '{"error": {"type": "OAuthException", "message": "Error validating verification code."}}'
460
476
 
461
477
  /888888888:
462
478
  no_args:
data/spec/spec_helper.rb CHANGED
@@ -5,16 +5,16 @@ rescue LoadError
5
5
  end
6
6
 
7
7
  # In Ruby 1.9.2 versions before patchlevel 290, the default Psych
8
- # parser has an issue with YAML merge keys, which
8
+ # parser has an issue with YAML merge keys, which
9
9
  # fixtures/mock_facebook_responses.yml relies heavily on.
10
- #
10
+ #
11
11
  # Anyone using an earlier version will see missing mock response
12
12
  # errors when running the test suite similar to this:
13
- #
13
+ #
14
14
  # RuntimeError:
15
15
  # Missing a mock response for graph_api: /me/videos: source=[FILE]: post: with_token
16
16
  # API PATH: /me/videos?source=[FILE]&format=json&access_token=*
17
- #
17
+ #
18
18
  # For now, it seems the best fix is to just downgrade to the old syck YAML parser
19
19
  # for these troubled versions.
20
20
  #
@@ -29,8 +29,8 @@ require 'koala'
29
29
 
30
30
  # ensure consistent to_json behavior
31
31
  # this must be required first so mock_http_service loads the YAML as expected
32
- require 'support/ordered_hash'
33
- require 'support/json_testing_fix'
32
+ require 'support/ordered_hash'
33
+ require 'support/json_testing_fix'
34
34
 
35
35
  # set up our testing environment
36
36
  require 'support/mock_http_service'
@@ -22,7 +22,7 @@ shared_examples_for "Koala GraphAPI" do
22
22
  end
23
23
 
24
24
  it "throws an APIError if the result hash has an error key" do
25
- Koala.stub(:make_request).and_return(Koala::HTTPService::Response.new(500, {"error" => "An error occurred!"}, {}))
25
+ Koala.stub(:make_request).and_return(Koala::HTTPService::Response.new(500, '{"error": "An error occurred!"}', {}))
26
26
  lambda { @api.graph_call(KoalaTest.user1, {}) }.should raise_exception(Koala::Facebook::APIError)
27
27
  end
28
28
 
@@ -81,7 +81,7 @@ shared_examples_for "Koala GraphAPI" do
81
81
  end
82
82
 
83
83
  it "gets multiple objects if they're a string" do
84
- results = @api.get_objects("contextoptional,#{KoalaTest.user1}")
84
+ results = @api.get_objects("facebook,#{KoalaTest.user1}")
85
85
  results.should have(2).items
86
86
  end
87
87
 
@@ -584,17 +584,17 @@ shared_examples_for "Koala GraphAPI without an access token" do
584
584
  end
585
585
 
586
586
  it "can't get data about 'me'" do
587
- lambda { @api.get_object("me") }.should raise_error(Koala::Facebook::APIError)
587
+ lambda { @api.get_object("me") }.should raise_error(Koala::Facebook::ClientError)
588
588
  end
589
589
 
590
590
  it "can't access connections from users" do
591
- lambda { @api.get_connections(KoalaTest.user2, "friends") }.should raise_error(Koala::Facebook::APIError)
591
+ lambda { @api.get_connections(KoalaTest.user2, "friends") }.should raise_error(Koala::Facebook::ClientError)
592
592
  end
593
593
 
594
594
  it "can't put an object" do
595
- lambda { @result = @api.put_connections(KoalaTest.user2, "feed", :message => "Hello, world") }.should raise_error(Koala::Facebook::APIError)
595
+ lambda { @result = @api.put_connections(KoalaTest.user2, "feed", :message => "Hello, world") }.should raise_error(Koala::Facebook::AuthenticationError)
596
596
  # legacy put_object syntax
597
- lambda { @result = @api.put_object(KoalaTest.user2, "feed", :message => "Hello, world") }.should raise_error(Koala::Facebook::APIError)
597
+ lambda { @result = @api.put_object(KoalaTest.user2, "feed", :message => "Hello, world") }.should raise_error(Koala::Facebook::AuthenticationError)
598
598
  end
599
599
 
600
600
  # these are not strictly necessary as the other put methods resolve to put_connections,
@@ -602,27 +602,27 @@ shared_examples_for "Koala GraphAPI without an access token" do
602
602
  it "can't post to a feed" do
603
603
  (lambda do
604
604
  attachment = {:name => "OAuth Playground", :link => "http://oauth.twoalex.com/"}
605
- @result = @api.put_wall_post("Hello, world", attachment, "contextoptional")
606
- end).should raise_error(Koala::Facebook::APIError)
605
+ @result = @api.put_wall_post("Hello, world", attachment, "facebook")
606
+ end).should raise_error(Koala::Facebook::AuthenticationError)
607
607
  end
608
608
 
609
609
  it "can't comment on an object" do
610
- # random public post on the ContextOptional wall
611
- lambda { @result = @api.put_comment("7204941866_119776748033392", "The hackathon was great!") }.should raise_error(Koala::Facebook::APIError)
610
+ # random public post on the facebook wall
611
+ lambda { @result = @api.put_comment("7204941866_119776748033392", "The hackathon was great!") }.should raise_error(Koala::Facebook::AuthenticationError)
612
612
  end
613
613
 
614
614
  it "can't like an object" do
615
- lambda { @api.put_like("7204941866_119776748033392") }.should raise_error(Koala::Facebook::APIError)
615
+ lambda { @api.put_like("7204941866_119776748033392") }.should raise_error(Koala::Facebook::AuthenticationError)
616
616
  end
617
617
 
618
618
  # DELETE
619
619
  it "can't delete posts" do
620
620
  # test post on the Ruby SDK Test application
621
- lambda { @result = @api.delete_object("115349521819193_113815981982767") }.should raise_error(Koala::Facebook::APIError)
621
+ lambda { @result = @api.delete_object("115349521819193_113815981982767") }.should raise_error(Koala::Facebook::AuthenticationError)
622
622
  end
623
623
 
624
624
  it "can't delete a like" do
625
- lambda { @api.delete_like("7204941866_119776748033392") }.should raise_error(Koala::Facebook::APIError)
625
+ lambda { @api.delete_like("7204941866_119776748033392") }.should raise_error(Koala::Facebook::AuthenticationError)
626
626
  end
627
627
 
628
628
  # FQL_QUERY
@@ -6,19 +6,19 @@ module KoalaTest
6
6
  attr_accessor :oauth_test_data, :subscription_test_data, :search_time
7
7
  attr_accessor :test_user_api
8
8
  end
9
-
9
+
10
10
  # Test setup
11
-
11
+
12
12
  def self.setup_test_environment!
13
13
  setup_rspec
14
-
14
+
15
15
  unless ENV['LIVE']
16
16
  # By default the Koala specs are run using stubs for HTTP requests,
17
17
  # so they won't fail due to Facebook-imposed rate limits or server timeouts.
18
18
  #
19
19
  # However as a result they are more brittle since
20
20
  # we are not testing the latest responses from the Facebook servers.
21
- # To be certain all specs pass with the current Facebook services,
21
+ # To be certain all specs pass with the current Facebook services,
22
22
  # run LIVE=true bundle exec rake spec.
23
23
  Koala.http_service = Koala::MockHTTPService
24
24
  KoalaTest.setup_test_data(Koala::MockHTTPService::TEST_DATA)
@@ -36,7 +36,7 @@ module KoalaTest
36
36
  rescue LoadError
37
37
  puts "Unable to load adapter #{adapter}, using Net::HTTP."
38
38
  end
39
-
39
+
40
40
  Koala.http_service.http_options[:beta] = true if ENV["beta"] || ENV["BETA"]
41
41
 
42
42
  # use a test user unless the developer wants to test against a real profile
@@ -47,7 +47,7 @@ module KoalaTest
47
47
  end
48
48
  end
49
49
  end
50
-
50
+
51
51
  def self.setup_rspec
52
52
  # set up a global before block to set the token for tests
53
53
  # set the token up for
@@ -85,7 +85,7 @@ module KoalaTest
85
85
  self.secret = data["oauth_test_data"]["secret"]
86
86
  self.code = data["oauth_test_data"]["code"]
87
87
  self.session_key = data["oauth_test_data"]["session_key"]
88
-
88
+
89
89
  # fix the search time so it can be used in the mock responses
90
90
  self.search_time = data["search_time"] || (Time.now - 3600).to_s
91
91
  end
@@ -93,7 +93,7 @@ module KoalaTest
93
93
  def self.testing_permissions
94
94
  "read_stream, publish_stream, user_photos, user_videos, read_insights"
95
95
  end
96
-
96
+
97
97
  def self.setup_test_users
98
98
  print "Setting up test users..."
99
99
  @test_user_api = Koala::Facebook::TestUsers.new(:app_id => self.app_id, :secret => self.secret)
@@ -103,7 +103,7 @@ module KoalaTest
103
103
  # before each test module, create two test users with specific names and befriend them
104
104
  KoalaTest.create_test_users
105
105
  end
106
-
106
+
107
107
  config.after :suite do
108
108
  # after each test module, delete the test users to avoid cluttering up the application
109
109
  KoalaTest.destroy_test_users
@@ -122,9 +122,9 @@ module KoalaTest
122
122
  rescue Exception => e
123
123
  Kernel.warn("Problem creating test users! #{e.message}")
124
124
  raise
125
- end
125
+ end
126
126
  end
127
-
127
+
128
128
  def self.destroy_test_users
129
129
  [@live_testing_user, @live_testing_friend].each do |u|
130
130
  puts "Unable to delete test user #{u.inspect}" if u && !(@test_user_api.delete(u) rescue false)
@@ -144,7 +144,7 @@ module KoalaTest
144
144
  end
145
145
  puts "done!"
146
146
  end
147
-
147
+
148
148
  # Info about the testing environment
149
149
  def self.real_user?
150
150
  !(mock_interface? || @test_user_api)
@@ -189,7 +189,7 @@ module KoalaTest
189
189
  end
190
190
 
191
191
  def self.page
192
- "contextoptional"
192
+ "facebook"
193
193
  end
194
194
 
195
195
  def self.app_properties