Permalink
Browse files

Ensured ::Excon.defaults[:mock] is set back to previous value, after …

…WebMock is disabled.
  • Loading branch information...
1 parent 3639da1 commit fe9cd066394a7c5a816ad1f47a8865918cfaaae5 @bblimke committed Mar 4, 2013
Showing with 8 additions and 4 deletions.
  1. +8 −4 lib/webmock/http_lib_adapters/excon_adapter.rb
View
12 lib/webmock/http_lib_adapters/excon_adapter.rb
@@ -28,14 +28,18 @@ def self.disable!
end
def self.add_excon_stub
- ::Excon.defaults[:mock] = true
- @stub ||= ::Excon.stub({}) do |params|
- self.handle_request(params)
+ if not @stub
+ @original_excon_mock_default = ::Excon.defaults[:mock]
+ ::Excon.defaults[:mock] = true
+ @stub = ::Excon.stub({}) do |params|
+ self.handle_request(params)
+ end
end
end
def self.remove_excon_stub
- ::Excon.defaults[:mock] = false
+ ::Excon.defaults[:mock] = @original_excon_mock_default
+ @original_excon_mock_default = nil
Excon.stubs.delete(@stub)
@stub = nil
end

0 comments on commit fe9cd06

Please sign in to comment.