Skip to content

Commit 93128b3

Browse files
committed
Merge pull request vcr#333 from vcr/issue-199
Play nicely with manual excon stubs.
2 parents b088603 + 4c78582 commit 93128b3

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ Bug Fixes:
1515
* Explicitly support the latest Excon (0.25). (Myron Marston)
1616
* Fix detection of encoding errors to handle `ArgumentError` that
1717
is raised by recent version of `MultiJson` (Myron Marston).
18+
* Fix Excon adapter so that it allows VCR to play nicely with
19+
manual Excon stubs (using Excon's `Excon.stub` API). (Myron Marston)
1820

1921
## 2.5.0 (May 18, 2013)
2022

lib/vcr/middleware/excon.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@ def ensure_response_body_can_be_read_for_error_case
9696

9797
private
9898

99+
def externally_stubbed?
100+
!!::Excon.stub_for(request_params)
101+
end
102+
99103
def should_record?
100104
@should_record
101105
end

spec/vcr/library_hooks/excon_spec.rb

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@
22
require 'support/shared_example_groups/excon'
33

44
describe "Excon hook", :with_monkey_patches => :excon do
5-
# TODO: figure out a way to get disabling VCR to work with Excon
6-
# and allow dirct excon stubs to work.
7-
# def directly_stub_request(method, url, response_body)
8-
# ::Excon.stub({ :method => method, :url => url }, { :body => response_body })
9-
# end
5+
after(:each) do
6+
::Excon.stubs.clear
7+
::Excon.defaults[:mock] = false
8+
end
9+
10+
def directly_stub_request(method, url, response_body)
11+
::Excon.defaults[:mock] = true
12+
::Excon.stub({ :method => method, :url => url }, { :body => response_body })
13+
end
1014

1115
it_behaves_like 'a hook into an HTTP library', :excon, 'excon', :status_message_not_exposed
1216

0 commit comments

Comments
 (0)