koala 1.6.0 → 1.7.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.
- data/.travis.yml +2 -5
- data/Gemfile +1 -2
- data/changelog.md +107 -4
- data/koala.gemspec +5 -5
- data/lib/koala.rb +13 -4
- data/lib/koala/api.rb +28 -3
- data/lib/koala/api/graph_api.rb +33 -3
- data/lib/koala/api/graph_collection.rb +20 -20
- data/lib/koala/api/rest_api.rb +1 -3
- data/lib/koala/http_service.rb +21 -16
- data/lib/koala/oauth.rb +15 -11
- data/lib/koala/version.rb +1 -1
- data/readme.md +34 -7
- data/spec/cases/api_spec.rb +21 -1
- data/spec/cases/graph_api_batch_spec.rb +38 -16
- data/spec/cases/graph_api_spec.rb +13 -20
- data/spec/cases/http_service_spec.rb +39 -9
- data/spec/cases/koala_spec.rb +34 -22
- data/spec/cases/oauth_spec.rb +16 -12
- data/spec/cases/test_users_spec.rb +5 -1
- data/spec/fixtures/mock_facebook_responses.yml +14 -6
- data/spec/spec_helper.rb +19 -35
- data/spec/support/graph_api_shared_examples.rb +34 -17
- data/spec/support/koala_test.rb +10 -1
- data/spec/support/mock_http_service.rb +77 -33
- metadata +27 -32
- data/spec/support/json_testing_fix.rb +0 -42
@@ -1,42 +0,0 @@
|
|
1
|
-
# when testing across Ruby versions, we found that JSON string creation inconsistently ordered keys
|
2
|
-
# which is a problem because our mock testing service ultimately matches strings to see if requests are mocked
|
3
|
-
# this fix solves that problem by ensuring all hashes are created with a consistent key order every time
|
4
|
-
module MultiJson
|
5
|
-
self.use :ok_json
|
6
|
-
|
7
|
-
class << self
|
8
|
-
def dump_with_ordering(object)
|
9
|
-
# if it's a hash, recreate it with k/v pairs inserted in sorted-by-key order
|
10
|
-
# (for some reason, REE fails if we don't assign the ternary result as a local variable
|
11
|
-
# separately from calling encode_original)
|
12
|
-
dump_original(sort_object(object))
|
13
|
-
end
|
14
|
-
|
15
|
-
alias_method :dump_original, :dump
|
16
|
-
alias_method :dump, :dump_with_ordering
|
17
|
-
|
18
|
-
def load_with_ordering(string)
|
19
|
-
sort_object(load_original(string))
|
20
|
-
end
|
21
|
-
|
22
|
-
alias_method :load_original, :load
|
23
|
-
alias_method :load, :load_with_ordering
|
24
|
-
|
25
|
-
private
|
26
|
-
|
27
|
-
def sort_object(object)
|
28
|
-
if object.is_a?(Hash)
|
29
|
-
sort_hash(object)
|
30
|
-
elsif object.is_a?(Array)
|
31
|
-
object.collect {|item| item.is_a?(Hash) ? sort_hash(item) : item}
|
32
|
-
else
|
33
|
-
object
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
def sort_hash(unsorted_hash)
|
38
|
-
sorted_hash = KoalaTest::OrderedHash.new(sorted_hash)
|
39
|
-
unsorted_hash.keys.sort {|a, b| a.to_s <=> b.to_s}.inject(sorted_hash) {|hash, k| hash[k] = unsorted_hash[k]; hash}
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|