Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #196 from jonleighton/fix_em_http_callbacks

Fix em-http-request callback triggering
  • Loading branch information...
commit e962df713de6624dca8a0e6f7ee3f5779a0602e3 2 parents 887bf32 + 71e7baf
Bartosz Blimke authored
Showing with 12 additions and 10 deletions.
  1. +12 −10 lib/webmock/http_lib_adapters/em_http_request/em_http_request_1_x.rb
22 lib/webmock/http_lib_adapters/em_http_request/em_http_request_1_x.rb
View
@@ -105,16 +105,6 @@ def send_request_with_webmock(head, body)
self
elsif WebMock.net_connect_allowed?(request_signature.uri)
send_request_without_webmock(head, body)
- callback {
- if WebMock::CallbackRegistry.any_callbacks?
- webmock_response = build_webmock_response
- WebMock::CallbackRegistry.invoke_callbacks(
- {:lib => :em_http_request, :real_request => true},
- request_signature,
- webmock_response)
- end
- }
- self
else
raise WebMock::NetConnectNotAllowedError.new(request_signature)
end
@@ -123,6 +113,18 @@ def send_request_with_webmock(head, body)
alias_method :send_request_without_webmock, :send_request
alias_method :send_request, :send_request_with_webmock
+ def set_deferred_status(status, *args)
+ if status == :succeeded && !stubbed_webmock_response && WebMock::CallbackRegistry.any_callbacks?
+ webmock_response = build_webmock_response
+ WebMock::CallbackRegistry.invoke_callbacks(
+ {:lib => :em_http_request, :real_request => true},
+ request_signature,
+ webmock_response)
+ end
+
+ super
+ end
+
def request_signature
@request_signature ||= build_request_signature
end
Please sign in to comment.
Something went wrong with that request. Please try again.