Skip to content
Snippets Groups Projects
Commit 62cfbe32 authored by Thu Trang Pham's avatar Thu Trang Pham
Browse files

MockHttpResponse should return headers how net/http response does

parent 49647fa3
No related branches found
No related tags found
No related merge requests found
...@@ -58,7 +58,7 @@ module Geocoder::Lookup ...@@ -58,7 +58,7 @@ module Geocoder::Lookup
def check_response_for_errors!(response) def check_response_for_errors!(response)
super super
if response.headers['X-MS-BM-WS-INFO'] == 1 if response['x-ms-bm-ws-info'].to_i == 1
# Occasionally, the servers processing service requests can be overloaded, # Occasionally, the servers processing service requests can be overloaded,
# and you may receive some responses that contain no results for queries that # and you may receive some responses that contain no results for queries that
# you would normally receive a result. To identify this situation, # you would normally receive a result. To identify this situation,
......
...@@ -124,7 +124,7 @@ module Geocoder ...@@ -124,7 +124,7 @@ module Geocoder
if file == "bing_service_unavailable" if file == "bing_service_unavailable"
filepath = File.join("test", "fixtures", file) filepath = File.join("test", "fixtures", file)
s = File.read(filepath).strip.gsub(/\n\s*/, "") s = File.read(filepath).strip.gsub(/\n\s*/, "")
MockHttpResponse.new(body: s, code: "200", headers: {'X-MS-BM-WS-INFO' => 1}) MockHttpResponse.new(body: s, code: "200", headers: {'x-ms-bm-ws-info' => "1"})
else else
super super
end end
...@@ -424,7 +424,7 @@ class GeocoderTestCase < Test::Unit::TestCase ...@@ -424,7 +424,7 @@ class GeocoderTestCase < Test::Unit::TestCase
end end
class MockHttpResponse class MockHttpResponse
attr_reader :code, :body, :headers attr_reader :code, :body
def initialize(options = {}) def initialize(options = {})
@code = options[:code].to_s @code = options[:code].to_s
@body = options[:body] @body = options[:body]
...@@ -432,6 +432,6 @@ class MockHttpResponse ...@@ -432,6 +432,6 @@ class MockHttpResponse
end end
def [](key) def [](key)
send key if respond_to?(key) @headers[key]
end end
end end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment