Skip to content

Commit a0b906d

Browse files
committed
Add WebMock monkey-patch to work around nil uri in response
See bblimke/webmock#469
1 parent 5d1b52a commit a0b906d

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

spec/spec_helper.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,14 @@ def with_tmp_file(named: nil, content: '')
103103
EMPTY_FIREBASE_TEST_LOG_PATH = File.join(__dir__, 'test-data', 'empty.json')
104104
PASSED_FIREBASE_TEST_LOG_PATH = File.join(__dir__, 'test-data', 'firebase', 'firebase-test-lab-run-passed.log')
105105
FAILED_FIREBASE_TEST_LOG_PATH = File.join(__dir__, 'test-data', 'firebase', 'firebase-test-lab-run-failure.log')
106+
107+
# Monkey-patch WebMock to work around bug where response.uri is not set
108+
# See https://github.com/bblimke/webmock/issues/469
109+
WebMock::HttpLibAdapters::NetHttpAdapter.instance_variable_get(:@webMockNetHTTP).class_eval do
110+
old_request = instance_method :request
111+
define_method :request do |request, &block|
112+
old_request.bind(self).(request, &block).tap do |response|
113+
response.uri = request.uri
114+
end
115+
end
116+
end

0 commit comments

Comments
 (0)