koala 1.5.0 → 1.6.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.
- data/.gitignore +2 -1
- data/.travis.yml +4 -1
- data/Gemfile +1 -1
- data/changelog.md +294 -0
- data/koala.gemspec +3 -2
- data/lib/koala/api/batch_operation.rb +1 -1
- data/lib/koala/api/graph_api.rb +132 -62
- data/lib/koala/api/graph_batch_api.rb +28 -38
- data/lib/koala/api/graph_collection.rb +3 -1
- data/lib/koala/api/rest_api.rb +19 -3
- data/lib/koala/api.rb +11 -31
- data/lib/koala/errors.rb +86 -0
- data/lib/koala/oauth.rb +21 -21
- data/lib/koala/realtime_updates.rb +42 -21
- data/lib/koala/version.rb +1 -1
- data/lib/koala.rb +1 -2
- data/readme.md +130 -103
- data/spec/cases/api_spec.rb +3 -3
- data/spec/cases/error_spec.rb +91 -20
- data/spec/cases/graph_api_batch_spec.rb +57 -22
- data/spec/cases/graph_api_spec.rb +68 -0
- data/spec/cases/graph_collection_spec.rb +6 -0
- data/spec/cases/oauth_spec.rb +16 -16
- data/spec/cases/realtime_updates_spec.rb +80 -82
- data/spec/cases/test_users_spec.rb +25 -20
- data/spec/fixtures/mock_facebook_responses.yml +45 -29
- data/spec/spec_helper.rb +6 -6
- data/spec/support/graph_api_shared_examples.rb +13 -13
- data/spec/support/koala_test.rb +13 -13
- data/spec/support/rest_api_shared_examples.rb +3 -3
- metadata +28 -9
- data/CHANGELOG +0 -275
|
@@ -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:
|
|
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:
|
|
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:
|
|
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=
|
|
71
|
+
ids=facebook,koppel:
|
|
66
72
|
get:
|
|
67
|
-
with_token: '{"
|
|
68
|
-
no_token: '{"
|
|
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\":\"
|
|
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:
|
|
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
|
-
/
|
|
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
|
-
/
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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"
|
|
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("
|
|
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::
|
|
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::
|
|
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::
|
|
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::
|
|
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, "
|
|
606
|
-
end).should raise_error(Koala::Facebook::
|
|
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
|
|
611
|
-
lambda { @result = @api.put_comment("7204941866_119776748033392", "The hackathon was great!") }.should raise_error(Koala::Facebook::
|
|
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::
|
|
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::
|
|
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::
|
|
625
|
+
lambda { @api.delete_like("7204941866_119776748033392") }.should raise_error(Koala::Facebook::AuthenticationError)
|
|
626
626
|
end
|
|
627
627
|
|
|
628
628
|
# FQL_QUERY
|
data/spec/support/koala_test.rb
CHANGED
|
@@ -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
|
-
"
|
|
192
|
+
"facebook"
|
|
193
193
|
end
|
|
194
194
|
|
|
195
195
|
def self.app_properties
|
|
@@ -111,8 +111,8 @@ shared_examples_for "Koala RestAPI" do
|
|
|
111
111
|
@api.rest_call('anything', {}, {}, method)
|
|
112
112
|
end
|
|
113
113
|
|
|
114
|
-
it "throws an APIError if the
|
|
115
|
-
Koala.stub(:make_request).and_return(Koala::HTTPService::Response.new(500, {"error_code"
|
|
114
|
+
it "throws an APIError if the status code >= 400" do
|
|
115
|
+
Koala.stub(:make_request).and_return(Koala::HTTPService::Response.new(500, '{"error_code": "An error occurred!"}', {}))
|
|
116
116
|
lambda { @api.rest_call(KoalaTest.user1, {}) }.should raise_exception(Koala::Facebook::APIError)
|
|
117
117
|
end
|
|
118
118
|
end
|
|
@@ -164,6 +164,6 @@ end
|
|
|
164
164
|
|
|
165
165
|
shared_examples_for "Koala RestAPI without an access token" do
|
|
166
166
|
it "can't use set_app_properties" do
|
|
167
|
-
lambda { @api.set_app_properties(:desktop => 0) }.should raise_error(Koala::Facebook::
|
|
167
|
+
lambda { @api.set_app_properties(:desktop => 0) }.should raise_error(Koala::Facebook::AuthenticationError)
|
|
168
168
|
end
|
|
169
169
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: koala
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.6.0
|
|
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: 2012-
|
|
12
|
+
date: 2012-12-06 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: multi_json
|
|
@@ -34,7 +34,23 @@ dependencies:
|
|
|
34
34
|
requirements:
|
|
35
35
|
- - ~>
|
|
36
36
|
- !ruby/object:Gem::Version
|
|
37
|
-
version: '0.
|
|
37
|
+
version: '0.8'
|
|
38
|
+
type: :runtime
|
|
39
|
+
prerelease: false
|
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
41
|
+
none: false
|
|
42
|
+
requirements:
|
|
43
|
+
- - ~>
|
|
44
|
+
- !ruby/object:Gem::Version
|
|
45
|
+
version: '0.8'
|
|
46
|
+
- !ruby/object:Gem::Dependency
|
|
47
|
+
name: addressable
|
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
|
49
|
+
none: false
|
|
50
|
+
requirements:
|
|
51
|
+
- - ~>
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: '2.2'
|
|
38
54
|
type: :runtime
|
|
39
55
|
prerelease: false
|
|
40
56
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -42,7 +58,7 @@ dependencies:
|
|
|
42
58
|
requirements:
|
|
43
59
|
- - ~>
|
|
44
60
|
- !ruby/object:Gem::Version
|
|
45
|
-
version: '
|
|
61
|
+
version: '2.2'
|
|
46
62
|
- !ruby/object:Gem::Dependency
|
|
47
63
|
name: rspec
|
|
48
64
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -85,20 +101,20 @@ executables: []
|
|
|
85
101
|
extensions: []
|
|
86
102
|
extra_rdoc_files:
|
|
87
103
|
- readme.md
|
|
88
|
-
-
|
|
104
|
+
- changelog.md
|
|
89
105
|
files:
|
|
90
106
|
- .autotest
|
|
91
107
|
- .gitignore
|
|
92
108
|
- .rspec
|
|
93
109
|
- .travis.yml
|
|
94
110
|
- .yardopts
|
|
95
|
-
- CHANGELOG
|
|
96
111
|
- Gemfile
|
|
97
112
|
- Guardfile
|
|
98
113
|
- LICENSE
|
|
99
114
|
- Manifest
|
|
100
115
|
- Rakefile
|
|
101
116
|
- autotest/discover.rb
|
|
117
|
+
- changelog.md
|
|
102
118
|
- koala.gemspec
|
|
103
119
|
- lib/koala.rb
|
|
104
120
|
- lib/koala/api.rb
|
|
@@ -108,6 +124,7 @@ files:
|
|
|
108
124
|
- lib/koala/api/graph_collection.rb
|
|
109
125
|
- lib/koala/api/legacy.rb
|
|
110
126
|
- lib/koala/api/rest_api.rb
|
|
127
|
+
- lib/koala/errors.rb
|
|
111
128
|
- lib/koala/http_service.rb
|
|
112
129
|
- lib/koala/http_service/multipart_request.rb
|
|
113
130
|
- lib/koala/http_service/response.rb
|
|
@@ -121,6 +138,7 @@ files:
|
|
|
121
138
|
- spec/cases/api_spec.rb
|
|
122
139
|
- spec/cases/error_spec.rb
|
|
123
140
|
- spec/cases/graph_api_batch_spec.rb
|
|
141
|
+
- spec/cases/graph_api_spec.rb
|
|
124
142
|
- spec/cases/graph_collection_spec.rb
|
|
125
143
|
- spec/cases/http_service_spec.rb
|
|
126
144
|
- spec/cases/koala_spec.rb
|
|
@@ -163,7 +181,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
163
181
|
version: '0'
|
|
164
182
|
segments:
|
|
165
183
|
- 0
|
|
166
|
-
hash:
|
|
184
|
+
hash: 4609092032250353184
|
|
167
185
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
168
186
|
none: false
|
|
169
187
|
requirements:
|
|
@@ -172,10 +190,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
172
190
|
version: '0'
|
|
173
191
|
segments:
|
|
174
192
|
- 0
|
|
175
|
-
hash:
|
|
193
|
+
hash: 4609092032250353184
|
|
176
194
|
requirements: []
|
|
177
195
|
rubyforge_project:
|
|
178
|
-
rubygems_version: 1.8.
|
|
196
|
+
rubygems_version: 1.8.24
|
|
179
197
|
signing_key:
|
|
180
198
|
specification_version: 3
|
|
181
199
|
summary: A lightweight, flexible library for Facebook with support for the Graph API,
|
|
@@ -184,6 +202,7 @@ test_files:
|
|
|
184
202
|
- spec/cases/api_spec.rb
|
|
185
203
|
- spec/cases/error_spec.rb
|
|
186
204
|
- spec/cases/graph_api_batch_spec.rb
|
|
205
|
+
- spec/cases/graph_api_spec.rb
|
|
187
206
|
- spec/cases/graph_collection_spec.rb
|
|
188
207
|
- spec/cases/http_service_spec.rb
|
|
189
208
|
- spec/cases/koala_spec.rb
|