Permalink
Browse files

Fix specs

  • Loading branch information...
1 parent dabbe72 commit 8d6420f78bb512b709190bbfce7f04a38ab1d91b @arsduo committed Jan 19, 2013
@@ -550,7 +550,7 @@
describe 'with post-processing callback' do
let(:me_result) { stub("me result") }
- let(:friends_result) { stub("friends result") }
+ let(:friends_result) { [stub("friends result")] }
let(:me_callback) { lambda {|arg| {"result" => me_result, "args" => arg} } }
let(:friends_callback) { lambda {|arg| {"result" => friends_result, "args" => arg} } }
@@ -561,7 +561,7 @@
batch_api.get_connections('me', 'friends', &friends_callback)
end
me["args"].should include("id" => KoalaTest.user1)
- friends["args"].should include("id" => KoalaTest.user2)
+ friends["args"].first.should include("id" => KoalaTest.user2)
end
it 'passes GraphCollections, not raw data' do
@@ -308,7 +308,7 @@ graph_api:
/debug_token:
input_token=<%= APP_ACCESS_TOKEN %>:
get:
- with_token: '{ "data": { "app_id": 138483919580948, "application": "Social Cafe", "expires_at": 1352419328, "is_valid": true, "issued_at": 1347235328, "metadata": { "sso": "iphone-safari" }, "scopes": [ "email", "publish_actions" ], "user_id": 1207059 } }'
+ with_token: '{ "data": { "app_id": <%= APP_ID %>, "application": "Social Cafe", "expires_at": 1352419328, "is_valid": true, "issued_at": 1347235328, "metadata": { "sso": "iphone-safari" }, "scopes": [ "email", "publish_actions" ], "user_id": 1207059 } }'
# -- OAuth responses --
/oauth/access_token:
View
@@ -21,9 +21,6 @@
require 'koala'
# Support files
-# we have to first ensure consistent to_json behavior across versions
-# otherwise mock_http_service may parse the YAML improperly
-require 'support/ordered_hash'
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
# set up our testing environment
@@ -414,8 +414,8 @@
result = @api.debug_token(KoalaTest.app_access_token)
result.should be_kind_of(Hash)
result["data"].should be_kind_of(Hash)
- result["data"]["app_id"].should == 138483919580948
- result["data"]["application"].should == "Social Cafe"
+ result["data"]["app_id"].to_s.should == KoalaTest.app_id.to_s
+ result["data"]["application"].should_not be_nil
end
describe "#set_app_restrictions" do
@@ -1,44 +0,0 @@
-require 'multi_json'
-
-# when testing across Ruby versions, we found that JSON string creation inconsistently ordered keys
-# which is a problem because our mock testing service ultimately matches strings to see if requests are mocked
-# this fix solves that problem by ensuring all hashes are created with a consistent key order every time
-module MultiJson
- self.use :ok_json
-
- class << self
- def dump_with_ordering(object)
- # if it's a hash, recreate it with k/v pairs inserted in sorted-by-key order
- # (for some reason, REE fails if we don't assign the ternary result as a local variable
- # separately from calling encode_original)
- dump_original(sort_object(object))
- end
-
- alias_method :dump_original, :dump
- alias_method :dump, :dump_with_ordering
-
- def load_with_ordering(string)
- sort_object(load_original(string))
- end
-
- alias_method :load_original, :load
- alias_method :load, :load_with_ordering
-
- private
-
- def sort_object(object)
- if object.is_a?(Hash)
- sort_hash(object)
- elsif object.is_a?(Array)
- object.collect {|item| item.is_a?(Hash) ? sort_hash(item) : item}
- else
- object
- end
- end
-
- def sort_hash(unsorted_hash)
- sorted_hash = KoalaTest::OrderedHash.new(sorted_hash)
- unsorted_hash.keys.sort {|a, b| a.to_s <=> b.to_s}.inject(sorted_hash) {|hash, k| hash[k] = unsorted_hash[k]; hash}
- end
- end
-end

0 comments on commit 8d6420f

Please sign in to comment.