vcr 2.2.3 → 2.2.4

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,6 +1,15 @@
1
- ## In git
1
+ ## 2.2.4 (July 19, 2012)
2
2
 
3
- [Full Changelog](http://github.com/myronmarston/vcr/compare/v2.2.2...master)
3
+ [Full Changelog](http://github.com/myronmarston/vcr/compare/v2.2.3...v2.2.4)
4
+
5
+ Bug Fixes:
6
+
7
+ * Fix excon so real requests are made with a connection constructed with
8
+ same args as the original connection.
9
+
10
+ ## 2.2.3 (July 9, 2012)
11
+
12
+ [Full Changelog](http://github.com/myronmarston/vcr/compare/v2.2.2...v2.2.3)
4
13
 
5
14
  Bug Fixes:
6
15
 
data/Gemfile CHANGED
@@ -11,7 +11,7 @@ gem 'yard'
11
11
 
12
12
  # Additional gems that are useful, but not required for development.
13
13
  group :extras do
14
- gem 'relish', '~> 0.5.0'
14
+ gem 'relish', '~> 0.6'
15
15
  gem 'fuubar'
16
16
  gem 'fuubar-cucumber'
17
17
 
@@ -2,7 +2,7 @@ require 'vcr/util/version_checker'
2
2
  require 'vcr/request_handler'
3
3
  require 'excon'
4
4
 
5
- VCR::VersionChecker.new('Excon', Excon::VERSION, '0.9.6', '0.14').check_version!
5
+ VCR::VersionChecker.new('Excon', Excon::VERSION, '0.9.6', '0.15').check_version!
6
6
 
7
7
  module VCR
8
8
  class LibraryHooks
@@ -58,9 +58,15 @@ module VCR
58
58
  end
59
59
  end
60
60
 
61
+ def new_connection
62
+ # Ensure the connection is constructed with the exact same args
63
+ # that the orginal connection was constructed with.
64
+ ::Excon::Connection.new(*params.fetch(:__construction_args))
65
+ end
66
+
61
67
  def perform_real_request
62
68
  begin
63
- response = ::Excon.new(uri).request(real_request_params)
69
+ response = new_connection.request(real_request_params)
64
70
  rescue ::Excon::Errors::Error => excon_error
65
71
  response = response_from_excon_error(excon_error)
66
72
  end
@@ -151,7 +157,24 @@ module VCR
151
157
  end
152
158
  end
153
159
 
154
- Excon.defaults[:mock] = true
160
+ ::Excon.defaults[:mock] = true
161
+
162
+ # We want to get at the Excon::Connection class but WebMock does
163
+ # some constant-replacing stuff to it, so we need to take that into
164
+ # account.
165
+ excon_connection = if defined?(::WebMock::HttpLibAdapters::ExconConnection)
166
+ ::WebMock::HttpLibAdapters::ExconConnection.superclass
167
+ else
168
+ ::Excon::Connection
169
+ end
170
+
171
+ excon_connection.class_eval do
172
+ def self.new(*args)
173
+ super.tap do |instance|
174
+ instance.connection[:__construction_args] = args
175
+ end
176
+ end
177
+ end
155
178
 
156
179
  VCR.configuration.after_library_hooks_loaded do
157
180
  # ensure WebMock's Excon adapter does not conflict with us here
data/lib/vcr/version.rb CHANGED
@@ -10,7 +10,7 @@ module VCR
10
10
  # * `parts` [Array<Integer>] List of the version parts.
11
11
  def version
12
12
  @version ||= begin
13
- string = '2.2.3'
13
+ string = '2.2.4'
14
14
 
15
15
  def string.parts
16
16
  split('.').map { |p| p.to_i }
@@ -25,6 +25,44 @@ describe "Excon hook", :with_monkey_patches => :excon do
25
25
  end
26
26
  end
27
27
 
28
+ context 'when the request overrides the connection params' do
29
+ let!(:excon) { ::Excon.new("http://localhost:#{VCR::SinatraApp.port}/") }
30
+
31
+ def deep_dup(hash)
32
+ Marshal.load(Marshal.dump hash)
33
+ end
34
+
35
+ def intercept_request(&interception)
36
+ orig_new = ::Excon::Connection.method(:new)
37
+
38
+ ::Excon::Connection.stub(:new) do |*args1|
39
+ orig_new.call(*args1).tap do |inst|
40
+
41
+ meth = inst.method(:request)
42
+ inst.stub(:request) do |*args2|
43
+ interception.call(inst, *args2)
44
+ meth.call(*args2)
45
+ end
46
+ end
47
+ end
48
+ end
49
+
50
+ it 'runs the real request with the same connection params' do
51
+ connection_params_1 = deep_dup(excon.connection)
52
+ connection_params_2 = nil
53
+
54
+ intercept_request do |instance, *args|
55
+ connection_params_2 = deep_dup(instance.connection)
56
+ end
57
+
58
+ VCR.use_cassette("excon") do
59
+ excon.request(:method => :get, :path => '/foo')
60
+ end
61
+
62
+ connection_params_2.should eq(connection_params_1)
63
+ end
64
+ end
65
+
28
66
  context "when Excon's streaming API is used" do
29
67
  it 'properly records and plays back the response' do
30
68
  VCR.stub(:real_http_connections_allowed? => true)
@@ -63,8 +101,7 @@ describe "Excon hook", :with_monkey_patches => :excon do
63
101
  it 'performs the right number of retries' do
64
102
  connection = Excon.new("http://localhost:#{VCR::SinatraApp.port}/not_found")
65
103
 
66
- # Excon define's .stub so we can't use RSpec's here...
67
- Excon.should_receive(:new).at_least(:once).and_return(connection)
104
+ Excon::Connection.stub(:new => connection)
68
105
 
69
106
  connection.extend Module.new {
70
107
  def request_kernel_call_counts
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vcr
3
3
  version: !ruby/object:Gem::Version
4
- hash: 1
4
+ hash: 15
5
5
  prerelease:
6
6
  segments:
7
7
  - 2
8
8
  - 2
9
- - 3
10
- version: 2.2.3
9
+ - 4
10
+ version: 2.2.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Myron Marston
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-07-10 00:00:00 Z
18
+ date: 2012-07-20 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  version_requirements: &id001 !ruby/object:Gem::Requirement