vcr 2.6.0 → 2.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MWJkMzRlZWY1OTM1ZDQ3NGJiODIyZTJjMjE3YjljNGMwMDIzODdlOA==
4
+ MWRhMTJmODMwZTRlMWQ4YzFiMGRlZmY4ZTE5NmM4OWQyZDNlYzM0ZQ==
5
5
  data.tar.gz: !binary |-
6
- ZDE3NDU2NTFjYTJkNjY0ZDg4MGI3ZmQzZWE1OGIzN2QxOWI3NDc2ZQ==
6
+ MjU3OGExMjk0NWI2MjVhYTM2NGEzNTRhOGJlMWJlMzFiNzBkMjRkYg==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- YjIyYjhmNDNjN2ZlMjBhZTY3YWM5YWFkNjZkZWFhN2NmYWQyZTM1Y2M0NDNk
10
- MGY3NTFlMjkzYzEyZDY5ODcwOTNjNzgzMDFlYzE3YjA4OWVjYzc5YTliODk2
11
- ZmVkMTdhZmQ3YTcwNDYyOGU4YzJjNWNkZWQ0MTc0MzRlNzk2OGE=
9
+ ZTI5ZDI3NDdmNmI4ZTY1NTFmNTBkN2Q1NGViYTc5MTkzNzhmNDY3MDJkMmQ1
10
+ ZTVjNTk0YzVkOTM0MjVkN2U0ZTVmNTIzZGViYTFiYzVlYmM0MjM2NWFiNThl
11
+ MGI1YTg3ZDc3MTcwMjJiMmY1MzA1YWMzNzBhMWJmMThhZGE5YmU=
12
12
  data.tar.gz: !binary |-
13
- OTJmNjYyMDczMWJkOWFkODRjNmEwOTRjNmMyNzNiZDZmZDIyODBmYmNmZTdi
14
- Y2JjMTkzMDMwZDg2NWVjNjkyMzIyZGVjMmI2MmNmMDlhMWJjN2I2YTAzYzEz
15
- MjM1OTc0OWYyMmY3ODExZDQ0MDFiNWE4ZWQwM2RkZWM0MjM0OGY=
13
+ MTIwY2QzNmRkOTczOGNmYmQxNzg2N2E0NjI4YjgyMTRiYzMzMTFmODA3ZGZm
14
+ ZDdlNGFmNjg5NmY4YWQ4YzM0ZjA4YzIwZGIwYjdlZjViZmFkMDM1NTZmOTJi
15
+ ZWFiNDhmMzllZjI5OTgwOTM0OWI2ZjgxNmM3ZmYxMzFlMGQwZmM=
data/CHANGELOG.md CHANGED
@@ -1,3 +1,30 @@
1
+ ## 2.7.0 (October 31, 2013)
2
+
3
+ [Full Changelog](http://github.com/vcr/vcr/compare/v2.6.0...v2.7.0)
4
+
5
+ Enhancements:
6
+
7
+ * Explicitly support the latest WebMock releases (1.14 and 1.15).
8
+ (Eduardo Maia, Johannes Würbach)
9
+ * Explicitly support the latest Excon releases (0.27 and 0.28).
10
+ (Myron Marston)
11
+ * Add support for Excon unix sockets by leveraging its
12
+ new `::Excon::Utils.request_uri` method. (Todd Lunter)
13
+ * Reword the "it may not work with this version" warning
14
+ message so the intent is more clear (Myron Marston).
15
+ * Support post/put bodies being specified as a hash when
16
+ using Typhoeus by leveraging it's new `encoded_body` API.
17
+ (Myron Marston, Hans Hasselberg)
18
+
19
+ Bug Fixes:
20
+
21
+ * Fix detection of encoding errors for MultiJson 1.8.1+.
22
+ (Myron Marston).
23
+ * Fix file name sanitization to better handle paths that have
24
+ a dot in them (Rob Hanlon, Myron Marston).
25
+ * Fix Faraday middleware so that it works properly when another
26
+ adapter is exclusively enabled (Myron Marston).
27
+
1
28
  ## 2.6.0 (September 25, 2013)
2
29
 
3
30
  [Full Changelog](http://github.com/vcr/vcr/compare/v2.5.0...v2.6.0)
data/Gemfile CHANGED
@@ -31,7 +31,7 @@ gem 'aruba', '>= 0.5'
31
31
  gem 'rspec', '>= 2.11'
32
32
 
33
33
  gem 'fakeweb', '>= 1.3.0'
34
- gem 'webmock', '>= 1.13'
34
+ gem 'webmock', '>= 1.14'
35
35
 
36
36
  gem 'faraday', '>= 0.8'
37
37
  gem 'httpclient', '>= 2.2'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- vcr (2.6.0)
4
+ vcr (2.7.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -29,15 +29,15 @@ GEM
29
29
  gherkin (~> 2.12.1)
30
30
  multi_json (>= 1.7.5, < 2.0)
31
31
  multi_test (>= 0.0.2)
32
- curb (0.8.4)
33
- debugger (1.6.1)
32
+ curb (0.8.5)
33
+ debugger (1.6.2)
34
34
  columnize (>= 0.3.1)
35
35
  debugger-linecache (~> 1.2.0)
36
36
  debugger-ruby_core_source (~> 1.2.3)
37
37
  debugger-linecache (1.2.0)
38
38
  debugger-ruby_core_source (1.2.3)
39
39
  diff-lcs (1.2.4)
40
- em-http-request (1.1.0)
40
+ em-http-request (1.1.1)
41
41
  addressable (>= 2.3.4)
42
42
  cookiejar
43
43
  em-socksify (>= 0.3)
@@ -49,11 +49,11 @@ GEM
49
49
  ffi (>= 1.3.0)
50
50
  mime-types (~> 1.18)
51
51
  eventmachine (1.0.3)
52
- excon (0.26.0)
52
+ excon (0.28.0)
53
53
  fakeweb (1.3.0)
54
54
  faraday (0.8.8)
55
55
  multipart-post (~> 1.2.0)
56
- ffi (1.9.0)
56
+ ffi (1.9.3)
57
57
  fuubar (1.2.1)
58
58
  rspec (~> 2.0)
59
59
  rspec-instafail (~> 0.2.0)
@@ -61,17 +61,17 @@ GEM
61
61
  fuubar-cucumber (0.0.20)
62
62
  cucumber (~> 1.3.0)
63
63
  ruby-progressbar (~> 1.0.0)
64
- gherkin (2.12.1)
64
+ gherkin (2.12.2)
65
65
  multi_json (~> 1.3)
66
66
  github-markup (0.7.5)
67
67
  http_parser.rb (0.6.0.beta.2)
68
68
  httpclient (2.3.4.1)
69
- json (1.8.0)
69
+ json (1.8.1)
70
70
  linecache (0.46)
71
71
  rbx-require-relative (> 0.0.4)
72
72
  method_source (0.8.2)
73
73
  mime-types (1.25)
74
- multi_json (1.8.0)
74
+ multi_json (1.8.2)
75
75
  multi_test (0.0.2)
76
76
  multipart-post (1.2.0)
77
77
  patron (0.4.18)
@@ -85,7 +85,7 @@ GEM
85
85
  rake (10.1.0)
86
86
  rbx-require-relative (0.0.9)
87
87
  redcarpet (1.17.2)
88
- redis (3.0.4)
88
+ redis (3.0.5)
89
89
  relish (0.7)
90
90
  archive-tar-minitar (>= 0.5.2)
91
91
  json (>= 1.4.6)
@@ -96,11 +96,11 @@ GEM
96
96
  rspec-core (~> 2.14.0)
97
97
  rspec-expectations (~> 2.14.0)
98
98
  rspec-mocks (~> 2.14.0)
99
- rspec-core (2.14.5)
100
- rspec-expectations (2.14.2)
99
+ rspec-core (2.14.6)
100
+ rspec-expectations (2.14.3)
101
101
  diff-lcs (>= 1.1.3, < 2.0)
102
102
  rspec-instafail (0.2.4)
103
- rspec-mocks (2.14.3)
103
+ rspec-mocks (2.14.4)
104
104
  ruby-debug (0.10.4)
105
105
  columnize (>= 0.1)
106
106
  ruby-debug-base (~> 0.10.4.0)
@@ -119,9 +119,9 @@ GEM
119
119
  slop (3.4.6)
120
120
  tilt (1.4.1)
121
121
  timecop (0.6.1)
122
- typhoeus (0.6.5)
122
+ typhoeus (0.6.6)
123
123
  ethon (~> 0.6.1)
124
- webmock (1.13.0)
124
+ webmock (1.15.0)
125
125
  addressable (>= 2.2.7)
126
126
  crack (>= 0.3.2)
127
127
  yajl-ruby (1.1.0)
@@ -161,6 +161,6 @@ DEPENDENCIES
161
161
  timecop (= 0.6.1)
162
162
  typhoeus (>= 0.6)
163
163
  vcr!
164
- webmock (>= 1.13)
164
+ webmock (>= 1.14)
165
165
  yajl-ruby (>= 1.1.0)
166
166
  yard
data/README.md CHANGED
@@ -148,6 +148,7 @@ Thanks also to the following people who have contributed patches or helpful sugg
148
148
  * [Carlos Kirkconnell](https://github.com/kirkconnell)
149
149
  * [Chad Jolly](https://github.com/cjolly)
150
150
  * [Chris Le](https://github.com/chrisle)
151
+ * [Eduardo Maia](https://github.com/emaiax)
151
152
  * [Eric Allam](http://github.com/rubymaverick)
152
153
  * [Ezekiel Templin](https://github.com/ezkl)
153
154
  * [Flaviu Simihaian](https://github.com/closedbracket)
@@ -184,6 +185,7 @@ Thanks also to the following people who have contributed patches or helpful sugg
184
185
  * [Shay Frendt](https://github.com/shayfrendt)
185
186
  * [Steve Faulkner](https://github.com/southpolesteve)
186
187
  * [Stephen Anderson](https://github.com/bendycode)
188
+ * [Todd Lunter](https://github.com/tlunter)
187
189
  * [Tyler Hunt](https://github.com/tylerhunt)
188
190
  * [Uģis Ozols](https://github.com/ugisozols)
189
191
  * [vzvu3k6k](https://github.com/vzvu3k6k)
@@ -193,6 +195,7 @@ Thanks also to the following people who have contributed patches or helpful sugg
193
195
 
194
196
  * [Betamax](https://github.com/robfletcher/betamax) (Groovy/JVM)
195
197
  * [Betamax](https://github.com/sigmavirus24/betamax) (Python)
198
+ * [ExVCR](https://github.com/parroty/exvcr) (Elixir)
196
199
  * [HAVCR](https://github.com/cordawyn/havcr) (Haskell)
197
200
  * [Mimic](https://github.com/acoulton/mimic) (PHP/Kohana)
198
201
  * [Nock-VCR](https://github.com/carbonfive/nock-vcr) (JavaScript/Node)
@@ -51,7 +51,11 @@ module VCR
51
51
 
52
52
  def sanitized_file_name_from(file_name)
53
53
  parts = file_name.to_s.split('.')
54
- file_extension = '.' + parts.pop if parts.size > 1
54
+
55
+ if parts.size > 1 && !parts.last.include?(File::SEPARATOR)
56
+ file_extension = '.' + parts.pop
57
+ end
58
+
55
59
  parts.join('.').gsub(/[^\w\-\/]+/, '_') + file_extension.to_s
56
60
  end
57
61
  end
@@ -23,7 +23,7 @@ else
23
23
  @vcr_request ||= VCR::Request.new \
24
24
  request.options.fetch(:method, :get),
25
25
  request.url,
26
- request.options.fetch(:body, ""),
26
+ request_body,
27
27
  request.options.fetch(:headers, {})
28
28
  end
29
29
 
@@ -61,6 +61,16 @@ else
61
61
  end if stubbed_response.headers
62
62
  end
63
63
  end
64
+
65
+ if ::Typhoeus::Request.method_defined?(:encoded_body)
66
+ def request_body
67
+ request.encoded_body
68
+ end
69
+ else
70
+ def request_body
71
+ request.options.fetch(:body, "")
72
+ end
73
+ end
64
74
  end
65
75
 
66
76
  # @private
@@ -2,7 +2,7 @@ require 'vcr/util/version_checker'
2
2
  require 'vcr/request_handler'
3
3
  require 'webmock'
4
4
 
5
- VCR::VersionChecker.new('WebMock', WebMock.version, '1.8.0', '1.13').check_version!
5
+ VCR::VersionChecker.new('WebMock', WebMock.version, '1.8.0', '1.15').check_version!
6
6
 
7
7
  module VCR
8
8
  class LibraryHooks
@@ -2,7 +2,7 @@ require 'excon'
2
2
  require 'vcr/request_handler'
3
3
  require 'vcr/util/version_checker'
4
4
 
5
- VCR::VersionChecker.new('Excon', Excon::VERSION, '0.22.0', '0.26').check_version!
5
+ VCR::VersionChecker.new('Excon', Excon::VERSION, '0.22.0', '0.28').check_version!
6
6
 
7
7
  module VCR
8
8
  # Contains middlewares for use with different libraries.
@@ -164,30 +164,16 @@ module VCR
164
164
  normalized
165
165
  end
166
166
 
167
- def uri
168
- @uri ||= "#{request_params[:scheme]}://#{request_params[:host]}:#{request_params[:port]}#{request_params[:path]}#{query}"
169
- end
170
-
171
- # based on:
172
- # https://github.com/geemus/excon/blob/v0.7.8/lib/excon/connection.rb#L117-132
173
- def query
174
- @query ||= case request_params[:query]
175
- when String
176
- "?#{request_params[:query]}"
177
- when Hash
178
- qry = '?'
179
- for key, values in request_params[:query]
180
- if values.nil?
181
- qry << key.to_s << '&'
182
- else
183
- for value in [*values]
184
- qry << key.to_s << '=' << CGI.escape(value.to_s) << '&'
185
- end
186
- end
187
- end
188
- qry.chop! # remove trailing '&'
189
- else
190
- ''
167
+ if defined?(::Excon::Utils) && ::Excon::Utils.respond_to?(:request_uri)
168
+ def uri
169
+ @uri ||= "#{::Excon::Utils.request_uri(request_params)}"
170
+ end
171
+ else
172
+ require 'vcr/middleware/excon/legacy_methods'
173
+ include LegacyMethods
174
+
175
+ def uri
176
+ @uri ||= "#{request_params[:scheme]}://#{request_params[:host]}:#{request_params[:port]}#{request_params[:path]}#{query}"
191
177
  end
192
178
  end
193
179
  end
@@ -0,0 +1,33 @@
1
+ module VCR
2
+ module Middleware
3
+ class Excon
4
+ # Contains legacy methods only needed when integrating with older versions
5
+ # of Excon.
6
+ # @api private
7
+ module LegacyMethods
8
+ # based on:
9
+ # https://github.com/geemus/excon/blob/v0.7.8/lib/excon/connection.rb#L117-132
10
+ def query
11
+ @query ||= case request_params[:query]
12
+ when String
13
+ "?#{request_params[:query]}"
14
+ when Hash
15
+ qry = '?'
16
+ for key, values in request_params[:query]
17
+ if values.nil?
18
+ qry << key.to_s << '&'
19
+ else
20
+ for value in [*values]
21
+ qry << key.to_s << '=' << CGI.escape(value.to_s) << '&'
22
+ end
23
+ end
24
+ end
25
+ qry.chop! # remove trailing '&'
26
+ else
27
+ ''
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -27,7 +27,7 @@ module VCR
27
27
  #
28
28
  # @param [Hash] env the Faraday request env hash
29
29
  def call(env)
30
- return if VCR.library_hooks.disabled?(:faraday)
30
+ return @app.call(env) if VCR.library_hooks.disabled?(:faraday)
31
31
  RequestHandler.new(@app, env).handle
32
32
  end
33
33
 
@@ -35,8 +35,9 @@ module VCR
35
35
 
36
36
  def warn_about_too_high
37
37
  Kernel.warn "You are using #{@library_name} #{@library_version}. " +
38
- "VCR is known to work with #{@library_name} #{version_requirement}. " +
39
- "It may not work with this version."
38
+ "VCR #{VCR.version} has been tested against #{@library_name} #{version_requirement}, " +
39
+ "and you are using a newer version. If you experience VCR issues, " +
40
+ "consider downgrading #{@library_name} as it may fix it."
40
41
  end
41
42
 
42
43
  def compare_version
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.6.0'
13
+ string = '2.7.0'
14
14
 
15
15
  def string.parts
16
16
  split('.').map { |p| p.to_i }
@@ -28,6 +28,10 @@ module VCR
28
28
  "FOO!"
29
29
  end
30
30
 
31
+ post '/return-request-body' do
32
+ request.body
33
+ end
34
+
31
35
  get '/set-cookie-headers/1' do
32
36
  headers 'Set-Cookie' => 'foo'
33
37
  'header set'
@@ -56,6 +56,11 @@ module VCR
56
56
  expected = File.join(FileSystem.storage_location, "a_1/b")
57
57
  expect(FileSystem.absolute_path_to_file("a 1/b")).to eq(expected)
58
58
  end
59
+
60
+ it 'handles files with no extensions (even when there is a dot in the path)' do
61
+ expected = File.join(FileSystem.storage_location, "/foo_bar/baz_qux")
62
+ expect(FileSystem.absolute_path_to_file("/foo.bar/baz qux")).to eq(expected)
63
+ end
59
64
  end
60
65
  end
61
66
  end
@@ -71,10 +71,8 @@ module VCR
71
71
 
72
72
  if RUBY_INTERPRETER == :jruby
73
73
  # don't test yajl on jruby
74
- elsif RUBY_VERSION.to_f < 1.9
75
- engines[:yajl] = MultiJson::LoadError
76
74
  else
77
- engines[:yajl] = ArgumentError
75
+ engines[:yajl] = MultiJson::LoadError
78
76
  end
79
77
 
80
78
  if RUBY_VERSION =~ /1.9/
@@ -84,13 +84,30 @@ describe "Typhoeus hook", :with_monkey_patches => :typhoeus do
84
84
  end
85
85
 
86
86
  it 'records and replays headers correctly' do
87
- pending "waiting on typhoeus/typhoeus#324" do
88
- recorded = get_response
89
- played_back = get_response
87
+ recorded = get_response
88
+ played_back = get_response
90
89
 
91
- expect(played_back.headers).to eq(recorded.headers)
90
+ expect(played_back.headers).to eq(recorded.headers)
91
+ end
92
+ end
93
+
94
+ context 'when a request is made with a hash for the POST body' do
95
+ def make_request
96
+ VCR.use_cassette("hash_body") do
97
+ Typhoeus::Request.post(
98
+ "http://localhost:#{VCR::SinatraApp.port}/return-request-body",
99
+ :body => { :foo => "17" }
100
+ )
92
101
  end
93
102
  end
103
+
104
+ it 'records and replays correctly' do
105
+ recorded = make_request
106
+ played_back = make_request
107
+
108
+ expect(recorded.body).to eq("foo=17")
109
+ expect(played_back.body).to eq(recorded.body)
110
+ end
94
111
  end
95
112
 
96
113
  context '#effective_url' do
@@ -128,6 +128,16 @@ describe VCR::Middleware::Faraday do
128
128
  end
129
129
  end
130
130
 
131
+ context "when another adapter is exclusive" do
132
+ it 'still makes requests properly' do
133
+ response = VCR.library_hooks.exclusively_enabled(:typhoeus) do
134
+ Faraday.get("http://localhost:#{VCR::SinatraApp.port}/")
135
+ end
136
+
137
+ expect(response.body).to eq("GET to root")
138
+ end
139
+ end
140
+
131
141
  context 'for a recorded request' do
132
142
  let!(:inserted_cassette) { VCR.insert_cassette('new_cassette') }
133
143
  before(:each) { expect(VCR).to receive(:record_http_interaction) }
@@ -19,13 +19,13 @@ module VCR
19
19
 
20
20
  it 'prints a warning if the major version is too high' do
21
21
  checker = VersionChecker.new('foo', '2.0.0', '1.0.0', '1.1')
22
- expect(Kernel).to receive(:warn).with(/may not work with this version/)
22
+ expect(Kernel).to receive(:warn).with(/you are using a newer version/)
23
23
  checker.check_version!
24
24
  end
25
25
 
26
26
  it 'prints a warning if the minor version is too high' do
27
27
  checker = VersionChecker.new('foo', '1.2.0', '1.0.0', '1.1')
28
- expect(Kernel).to receive(:warn).with(/may not work with this version/)
28
+ expect(Kernel).to receive(:warn).with(/you are using a newer version/)
29
29
  checker.check_version!
30
30
  end
31
31
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vcr
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.0
4
+ version: 2.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Myron Marston
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-26 00:00:00.000000000 Z
11
+ date: 2013-10-31 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: VCR provides a simple API to record and replay your test suite's HTTP
14
14
  interactions. It works with a variety of HTTP client libraries, HTTP stubbing libraries
@@ -120,6 +120,7 @@ files:
120
120
  - lib/vcr/library_hooks/typhoeus_0.4.rb
121
121
  - lib/vcr/library_hooks/webmock.rb
122
122
  - lib/vcr/middleware/excon.rb
123
+ - lib/vcr/middleware/excon/legacy_methods.rb
123
124
  - lib/vcr/middleware/faraday.rb
124
125
  - lib/vcr/middleware/rack.rb
125
126
  - lib/vcr/request_handler.rb