Skip to content
This repository
Browse code

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

…WebMock is disabled.
  • Loading branch information...
commit fe9cd066394a7c5a816ad1f47a8865918cfaaae5 1 parent 3639da1
Bartosz Blimke authored
12  lib/webmock/http_lib_adapters/excon_adapter.rb
@@ -28,14 +28,18 @@ def self.disable!
28 28
         end
29 29
 
30 30
         def self.add_excon_stub
31  
-          ::Excon.defaults[:mock] = true
32  
-          @stub ||= ::Excon.stub({}) do |params|
33  
-            self.handle_request(params)
  31
+          if not @stub
  32
+            @original_excon_mock_default = ::Excon.defaults[:mock]
  33
+            ::Excon.defaults[:mock] = true
  34
+            @stub = ::Excon.stub({}) do |params|
  35
+              self.handle_request(params)
  36
+            end
34 37
           end
35 38
         end
36 39
 
37 40
         def self.remove_excon_stub
38  
-          ::Excon.defaults[:mock] = false
  41
+          ::Excon.defaults[:mock] = @original_excon_mock_default
  42
+          @original_excon_mock_default = nil
39 43
           Excon.stubs.delete(@stub)
40 44
           @stub = nil
41 45
         end

0 notes on commit fe9cd06

Please sign in to comment.
Something went wrong with that request. Please try again.