koala 1.1.0 → 1.2.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/.travis.yml +2 -1
- data/CHANGELOG +36 -0
- data/Gemfile +6 -2
- data/Rakefile +0 -1
- data/koala.gemspec +7 -8
- data/lib/koala/batch_operation.rb +15 -15
- data/lib/koala/graph_api.rb +85 -73
- data/lib/koala/graph_batch_api.rb +21 -11
- data/lib/koala/graph_collection.rb +13 -8
- data/lib/koala/http_service.rb +176 -0
- data/lib/koala/oauth.rb +34 -24
- data/lib/koala/realtime_updates.rb +21 -18
- data/lib/koala/rest_api.rb +1 -1
- data/lib/koala/test_users.rb +33 -17
- data/lib/koala/uploadable_io.rb +49 -43
- data/lib/koala/utils.rb +11 -0
- data/lib/koala/version.rb +3 -0
- data/lib/koala.rb +47 -45
- data/readme.md +58 -38
- data/spec/cases/{api_base_spec.rb → api_spec.rb} +27 -2
- data/spec/cases/error_spec.rb +32 -0
- data/spec/cases/graph_and_rest_api_spec.rb +12 -21
- data/spec/cases/graph_api_batch_spec.rb +92 -119
- data/spec/cases/graph_api_spec.rb +11 -14
- data/spec/cases/graph_collection_spec.rb +116 -0
- data/spec/cases/http_service_spec.rb +446 -0
- data/spec/cases/koala_spec.rb +36 -37
- data/spec/cases/oauth_spec.rb +318 -212
- data/spec/cases/realtime_updates_spec.rb +45 -31
- data/spec/cases/rest_api_spec.rb +23 -7
- data/spec/cases/test_users_spec.rb +123 -75
- data/spec/cases/uploadable_io_spec.rb +77 -36
- data/spec/cases/utils_spec.rb +10 -0
- data/spec/fixtures/facebook_data.yml +26 -24
- data/spec/fixtures/mock_facebook_responses.yml +131 -101
- data/spec/spec_helper.rb +29 -5
- data/spec/support/graph_api_shared_examples.rb +80 -120
- data/spec/support/json_testing_fix.rb +35 -11
- data/spec/support/koala_test.rb +187 -0
- data/spec/support/mock_http_service.rb +8 -5
- data/spec/support/ordered_hash.rb +205 -0
- data/spec/support/rest_api_shared_examples.rb +37 -37
- data/spec/support/uploadable_io_shared_examples.rb +2 -8
- metadata +72 -83
- data/lib/koala/http_services/net_http_service.rb +0 -92
- data/lib/koala/http_services/typhoeus_service.rb +0 -37
- data/lib/koala/http_services.rb +0 -46
- data/spec/cases/http_services/http_service_spec.rb +0 -129
- data/spec/cases/http_services/net_http_service_spec.rb +0 -532
- data/spec/cases/http_services/typhoeus_service_spec.rb +0 -152
- data/spec/support/live_testing_data_helper.rb +0 -40
- data/spec/support/setup_mocks_or_live.rb +0 -51
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
module LiveTestingDataHelper
|
|
2
|
-
# in RSpec 2, included example groups no longer share any hooks or state with outside examples
|
|
3
|
-
# even if in the same block
|
|
4
|
-
# so we have to use a module to provide setup and teardown hooks for live testing
|
|
5
|
-
|
|
6
|
-
def self.included(base)
|
|
7
|
-
base.class_eval do
|
|
8
|
-
before :each do
|
|
9
|
-
@token = $testing_data["oauth_token"]
|
|
10
|
-
raise Exception, "Must supply access token to run FacebookWithAccessTokenTests!" unless @token
|
|
11
|
-
# track temporary objects created
|
|
12
|
-
@temporary_object_ids = []
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
after :each do
|
|
16
|
-
# clean up any temporary objects
|
|
17
|
-
@temporary_object_ids << @temporary_object_id if @temporary_object_id
|
|
18
|
-
count = @temporary_object_ids.length
|
|
19
|
-
errors = []
|
|
20
|
-
|
|
21
|
-
if count > 0
|
|
22
|
-
@temporary_object_ids.each do |id|
|
|
23
|
-
# get our API
|
|
24
|
-
api = @api || (@test_users ? @test_users.graph_api : nil)
|
|
25
|
-
raise "Unable to locate API when passed temporary object to delete!" unless api
|
|
26
|
-
|
|
27
|
-
# delete the object
|
|
28
|
-
result = (api.delete_object(id) rescue false)
|
|
29
|
-
# if we errored out or Facebook returned false, track that
|
|
30
|
-
errors << id unless result
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
unless errors.length == 0
|
|
34
|
-
puts "cleaned up #{count - errors.length} objects, but errored out on the following:\n #{errors.join(", ")}"
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
end
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
# small helper method for live testing
|
|
2
|
-
module KoalaTest
|
|
3
|
-
def self.validate_user_info(token)
|
|
4
|
-
print "Validating permissions for live testing..."
|
|
5
|
-
# make sure we have the necessary permissions
|
|
6
|
-
api = Koala::Facebook::GraphAndRestAPI.new(token)
|
|
7
|
-
perms = api.fql_query("select read_stream, publish_stream, user_photos, user_videos, read_insights from permissions where uid = me()")[0]
|
|
8
|
-
perms.each_pair do |perm, value|
|
|
9
|
-
if value == (perm == "read_insights" ? 1 : 0) # live testing depends on insights calls failing
|
|
10
|
-
puts "failed!\n" # put a new line after the print above
|
|
11
|
-
raise ArgumentError, "Your access token must have the read_stream, publish_stream, and user_photos permissions, and lack read_insights. You have: #{perms.inspect}"
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
puts "done!"
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
unless ENV['LIVE']
|
|
20
|
-
# By default the Koala specs are run using stubs for HTTP requests
|
|
21
|
-
#
|
|
22
|
-
# Valid OAuth token and code are not necessary to run these
|
|
23
|
-
# specs. Because of this, specs do not fail due to Facebook
|
|
24
|
-
# imposed rate-limits or server timeouts.
|
|
25
|
-
#
|
|
26
|
-
# However as a result they are more brittle since
|
|
27
|
-
# we are not testing the latest responses from the Facebook servers.
|
|
28
|
-
# Therefore, to be certain all specs pass with the current
|
|
29
|
-
# Facebook services, run koala_spec_without_mocks.rb.
|
|
30
|
-
Koala.http_service = Koala::MockHTTPService
|
|
31
|
-
|
|
32
|
-
$testing_data = Koala::MockHTTPService::TEST_DATA
|
|
33
|
-
else
|
|
34
|
-
# Runs Koala specs through the Facebook servers
|
|
35
|
-
#
|
|
36
|
-
# Note that you need a valid OAuth token and code for these
|
|
37
|
-
# specs to run. See facebook_data.yml for more information.
|
|
38
|
-
|
|
39
|
-
# load testing data (see note in readme.md)
|
|
40
|
-
$testing_data = YAML.load_file(File.join(File.dirname(__FILE__), '../fixtures/facebook_data.yml'))
|
|
41
|
-
|
|
42
|
-
unless $testing_data["oauth_token"]
|
|
43
|
-
puts "Access token tests will fail until you store a valid token in facebook_data.yml"
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
unless $testing_data["oauth_test_data"] && $testing_data["oauth_test_data"]["code"] && $testing_data["oauth_test_data"]["secret"]
|
|
47
|
-
puts "OAuth code tests will fail until you store valid data for the user's OAuth code and the app secret in facebook_data.yml"
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
KoalaTest.validate_user_info $testing_data["oauth_token"]
|
|
51
|
-
end
|