vcr 3.0.2 → 3.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/features/CHANGELOG.md +710 -0
- data/features/CONTRIBUTING.md +26 -0
- data/features/LICENSE.md +20 -0
- data/features/README.md +339 -0
- data/features/Upgrade.md +289 -0
- data/lib/vcr/version.rb +1 -1
- metadata +3 -4
- data/features/CHANGELOG.md +0 -1
- data/features/CONTRIBUTING.md +0 -1
- data/features/LICENSE.md +0 -1
- data/features/README.md +0 -1
- data/features/Upgrade.md +0 -1
@@ -0,0 +1,26 @@
|
|
1
|
+
## Contributing
|
2
|
+
|
3
|
+
Install [bundler](http://gembundler.com/) and use it to install all the development dependencies:
|
4
|
+
|
5
|
+
```console
|
6
|
+
gem install bundler
|
7
|
+
bundle install
|
8
|
+
```
|
9
|
+
|
10
|
+
You should be able to run the tests now:
|
11
|
+
|
12
|
+
```console
|
13
|
+
bundle exec rake
|
14
|
+
```
|
15
|
+
|
16
|
+
VCR uses [RSpec](http://github.com/rspec/rspec) for unit tests. The specs are written in a very "focused" style, where each spec is concerned only with exercising the object under test, using mocks as necessary. You can run the specs using `rake spec`.
|
17
|
+
|
18
|
+
[Cucumber](http://cukes.info/) is used for end-to-end full stack integration tests that also function as VCR's documentation.
|
19
|
+
|
20
|
+
## Problems running bundle install?
|
21
|
+
|
22
|
+
If you get an error while running `bundle install`, it may be one of the "extras" gems which are not required for development. Try installing it without these gems.
|
23
|
+
|
24
|
+
```console
|
25
|
+
bundle install --without extras
|
26
|
+
```
|
data/features/LICENSE.md
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2010-2015 Myron Marston
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/features/README.md
ADDED
@@ -0,0 +1,339 @@
|
|
1
|
+
vcr
|
2
|
+
===
|
3
|
+
|
4
|
+
[![Quality](https://img.shields.io/codeclimate/github/vcr/vcr.svg?style=flat-square)](https://codeclimate.com/github/vcr/vcr)
|
5
|
+
[![Coverage](https://img.shields.io/codeclimate/coverage/github/vcr/vcr.svg?style=flat-square)](https://codeclimate.com/github/vcr/vcr)
|
6
|
+
[![Build](https://img.shields.io/travis-ci/vcr/vcr.svg?style=flat-square)](https://travis-ci.org/vcr/vcr)
|
7
|
+
[![Dependencies](https://img.shields.io/gemnasium/vcr/vcr.svg?style=flat-square)](https://gemnasium.com/vcr/vcr)
|
8
|
+
[![Downloads](https://img.shields.io/gem/dtv/vcr.svg?style=flat-square)](https://rubygems.org/gems/vcr)
|
9
|
+
[![Tags](https://img.shields.io/github/tag/vcr/vcr.svg?style=flat-square)](https://github.com/vcr/vcr/tags)
|
10
|
+
[![Releases](https://img.shields.io/github/release/vcr/vcr.svg?style=flat-square)](http://github.com/vcr/vcr/releases)
|
11
|
+
[![Issues](https://img.shields.io/github/issues/vcr/vcr.svg?style=flat-square)](https://github.com/vcr/vcr/issues)
|
12
|
+
[![License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](http://opensource.org/licenses/MIT)
|
13
|
+
[![Version](https://img.shields.io/gem/v/vcr.svg?style=flat-square)](https://rubygems.org/gems/vcr)
|
14
|
+
[![OpenCollective](https://opencollective.com/vcr/backers/badge.svg)](https://opencollective.com/vcr#backer)
|
15
|
+
[![OpenCollective](https://opencollective.com/vcr/sponsors/badge.svg)](https://opencollective.com/vcr#sponsor)
|
16
|
+
|
17
|
+
|
18
|
+
Record your test suite's HTTP interactions and replay them during future test runs for fast, deterministic, accurate tests.
|
19
|
+
|
20
|
+
**Help Wanted**
|
21
|
+
|
22
|
+
We looking for new maintainers. If you'd like to help maintain a well-used gem please join the [vcr-maintainers google group](https://groups.google.com/forum/#!forum/vcr-maintainers).
|
23
|
+
|
24
|
+
|
25
|
+
Usage
|
26
|
+
=====
|
27
|
+
|
28
|
+
``` ruby
|
29
|
+
require 'rubygems'
|
30
|
+
require 'test/unit'
|
31
|
+
require 'vcr'
|
32
|
+
|
33
|
+
VCR.configure do |config|
|
34
|
+
config.cassette_library_dir = "fixtures/vcr_cassettes"
|
35
|
+
config.hook_into :webmock # or :fakeweb
|
36
|
+
end
|
37
|
+
|
38
|
+
class VCRTest < Test::Unit::TestCase
|
39
|
+
def test_example_dot_com
|
40
|
+
VCR.use_cassette("synopsis") do
|
41
|
+
response = Net::HTTP.get_response(URI('http://www.iana.org/domains/reserved'))
|
42
|
+
assert_match /Example domains/, response.body
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
```
|
47
|
+
|
48
|
+
Run this test once, and VCR will record the HTTP request to `fixtures/vcr_cassettes/synopsis.yml`. Run it again, and VCR will replay the response from iana.org when the HTTP request is made. This test is now fast (no real HTTP requests are made anymore), deterministic (the test will continue to pass, even if you are offline, or iana.org goes down for maintenance) and accurate (the response will contain the same headers and body you get from a real request). You can use a different cassette library directory (e.g., "test/vcr_cassettes"), but do *not* use 'test/fixtures' as the directory if you're using Rails and minitest (Rails will instead transitively load any files in that directory as models).
|
49
|
+
|
50
|
+
**Features**
|
51
|
+
|
52
|
+
* Automatically records and replays your HTTP interactions with minimal setup/configuration code.
|
53
|
+
* Supports and works with the HTTP stubbing facilities of multiple libraries. Currently, the following are supported:
|
54
|
+
* [WebMock](https://github.com/bblimke/webmock)
|
55
|
+
* [Typhoeus](https://github.com/typhoeus/typhoeus)
|
56
|
+
* [Faraday](https://github.com/lostisland/faraday)
|
57
|
+
* [Excon](https://github.com/excon/excon)
|
58
|
+
* [FakeWeb](https://github.com/chrisk/fakeweb) (deprecated)
|
59
|
+
* Supports multiple HTTP libraries:
|
60
|
+
* [Patron](https://github.com/toland/patron) (when using WebMock)
|
61
|
+
* [Curb](https://github.com/taf2/curb) (when using WebMock -- only supports Curl::Easy at the moment)
|
62
|
+
* [HTTPClient](https://github.com/nahi/httpclient) (when using WebMock)
|
63
|
+
* [em-http-request](https://github.com/igrigorik/em-http-request) (when using WebMock)
|
64
|
+
* [Net::HTTP](http://www.ruby-doc.org/stdlib/libdoc/net/http/rdoc/index.html) (when using FakeWeb and WebMock)
|
65
|
+
* [Typhoeus](https://github.com/typhoeus/typhoeus) (Typhoeus::Hydra, but not Typhoeus::Easy or Typhoeus::Multi)
|
66
|
+
* [Excon](https://github.com/geemus/excon)
|
67
|
+
* [Faraday](https://github.com/lostisland/faraday)
|
68
|
+
* And of course any library built on Net::HTTP, such as [Mechanize](https://github.com/sparklemotion/mechanize), [HTTParty](https://github.com/jnunemaker/httparty) or [Rest Client](https://github.com/rest-client/rest-client).
|
69
|
+
* Request matching is configurable based on HTTP method, URI, host, path, body and headers, or you can easily implement a custom request matcher to handle any need.
|
70
|
+
* The same request can receive different responses in different tests--just use different cassettes.
|
71
|
+
* The recorded requests and responses are stored on disk in a serialization format of your choice (currently YAML and JSON are built in, and you can easily implement your own custom serializer) and can easily be inspected and edited.
|
72
|
+
* Dynamic responses are supported using ERB.
|
73
|
+
* Optionally re-records cassettes on a configurable regular interval to keep them fresh and current.
|
74
|
+
* Disables all HTTP requests that you don't explicitly allow.
|
75
|
+
* Simple Cucumber integration is provided using tags.
|
76
|
+
* Includes convenient RSpec macros and integration with RSpec 2 metadata.
|
77
|
+
* Known to work well with many popular Ruby libraries including RSpec 1 & 2, Cucumber, Test::Unit, Capybara, Mechanize, Rest Client and HTTParty.
|
78
|
+
* Includes Rack and Faraday middleware.
|
79
|
+
|
80
|
+
The docs come in two flavors:
|
81
|
+
|
82
|
+
* The [relish docs](https://relishapp.com/vcr/vcr/docs) contain example-based documentation (VCR's Cucumber suite, in fact). It's a good place to look when you are first getting started with VCR, or if you want to see an example of how to use a feature.
|
83
|
+
* The [rubydoc.info docs](http://www.rubydoc.info/gems/vcr/frames) contain API documentation. The API docs contain detailed info about all of VCR's public API.
|
84
|
+
* See the [Upgrade](https://github.com/vcr/vcr/blob/master/Upgrade.md) doc for info about what's new and changed in VCR 2.0.
|
85
|
+
|
86
|
+
There is also a Railscast, which will get you up and running in no-time http://railscasts.com/episodes/291-testing-with-vcr.
|
87
|
+
|
88
|
+
**Release Policy**
|
89
|
+
|
90
|
+
VCR follows the principles of [semantic versioning](http://semver.org/). The [API documentation](http://rubydoc.info/gems/vcr/frames) defines VCR's public API. Patch level releases contain only bug fixes. Minor releases contain backward-compatible new features. Major new releases contain backwards-incompatible changes to the public API.
|
91
|
+
|
92
|
+
**Ruby Interpreter Compatibility**
|
93
|
+
|
94
|
+
VCR has been tested on the following ruby interpreters:
|
95
|
+
|
96
|
+
* MRI 1.9.3
|
97
|
+
* MRI 2.0.0
|
98
|
+
* MRI 2.1
|
99
|
+
* MRI 2.2
|
100
|
+
* MRI 2.3.0
|
101
|
+
* JRuby
|
102
|
+
* Rubinius
|
103
|
+
|
104
|
+
Note that as of VCR 3, 1.8.7 and 1.9.2 are not supported.
|
105
|
+
|
106
|
+
**Development**
|
107
|
+
|
108
|
+
* Source hosted on [GitHub](http://github.com/vcr/vcr).
|
109
|
+
* Direct questions and discussions to the [mailing list](http://groups.google.com/group/vcr-ruby).
|
110
|
+
* Report issues on [GitHub Issues](http://github.com/vcr/vcr/issues).
|
111
|
+
* Pull requests are very welcome! Please include spec and/or feature coverage for every patch,
|
112
|
+
and create a topic branch for every separate change you make.
|
113
|
+
* See the [Contributing](https://github.com/vcr/vcr/blob/master/CONTRIBUTING.md)
|
114
|
+
guide for instructions on running the specs and features.
|
115
|
+
* Code quality metrics are checked by [Code Climate](https://codeclimate.com/github/vcr/vcr).
|
116
|
+
* Documentation is generated with [YARD](http://yardoc.org/) ([cheat sheet](http://cheat.errtheblog.com/s/yard)).
|
117
|
+
To generate while developing:
|
118
|
+
|
119
|
+
```
|
120
|
+
yard server --reload
|
121
|
+
```
|
122
|
+
|
123
|
+
**Ports in Other Languages**
|
124
|
+
|
125
|
+
* [Betamax](https://github.com/sigmavirus24/betamax) (Python)
|
126
|
+
* [VCR.py](https://github.com/kevin1024/vcrpy) (Python)
|
127
|
+
* [Betamax](https://github.com/thegreatape/betamax) (Go)
|
128
|
+
* [DVR](https://github.com/orchestrate-io/dvr) (Go)
|
129
|
+
* [Go VCR](https://github.com/dnaeon/go-vcr) (Go)
|
130
|
+
* [Betamax](https://github.com/wjlroe/betamax) (Clojure)
|
131
|
+
* [vcr-clj](https://github.com/ifesdjeen/vcr-clj) (Clojure)
|
132
|
+
* [Betamax.NET](https://github.com/mfloryan/Betamax.Net) (C#/.NET)
|
133
|
+
* [ExVCR](https://github.com/parroty/exvcr) (Elixir)
|
134
|
+
* [HAVCR](https://github.com/cordawyn/havcr) (Haskell)
|
135
|
+
* [Mimic](https://github.com/acoulton/mimic) (PHP/Kohana)
|
136
|
+
* [PHP-VCR](https://github.com/php-vcr/php-vcr) (PHP)
|
137
|
+
* [Nock-VCR](https://github.com/carbonfive/nock-vcr) (JavaScript/Node)
|
138
|
+
* [Sepia](https://github.com/linkedin/sepia) (Javascript/Node)
|
139
|
+
* [VCR.js](https://github.com/elcuervo/vcr.js) (JavaScript)
|
140
|
+
* [NSURLConnectionVCR](https://bitbucket.org/martijnthe/nsurlconnectionvcr) (Objective-C)
|
141
|
+
* [VCRURLConnection](https://github.com/dstnbrkr/VCRURLConnection) (Objective-C)
|
142
|
+
* [VHS](https://github.com/diegoeche/vhs) (Erlang)
|
143
|
+
* [Betamax](https://github.com/betamaxteam/betamax) (Java)
|
144
|
+
* [http_replayer](https://github.com/ucarion/http_replayer) (Rust)
|
145
|
+
|
146
|
+
**Related Projects**
|
147
|
+
|
148
|
+
* [Mr. Video](https://github.com/quidproquo/mr_video) (Rails engine for managing VCR cassettes and episodes)
|
149
|
+
|
150
|
+
|
151
|
+
**Similar Libraries in Ruby**
|
152
|
+
|
153
|
+
* [Ephemeral Response](https://github.com/sandro/ephemeral_response)
|
154
|
+
* [Net::HTTP Spy](https://github.com/martinbtt/net-http-spy)
|
155
|
+
* [NetRecorder](https://github.com/chrisyoung/netrecorder)
|
156
|
+
* [Puffing Billy](https://github.com/oesmith/puffing-billy)
|
157
|
+
* [REST-assured](https://github.com/artemave/REST-assured)
|
158
|
+
* [Stale Fish](https://github.com/jsmestad/stale_fish)
|
159
|
+
* [WebFixtures](https://github.com/trydionel/web_fixtures)
|
160
|
+
|
161
|
+
|
162
|
+
Credits
|
163
|
+
=======
|
164
|
+
|
165
|
+
* [Aslak Hellesøy](https://github.com/aslakhellesoy) for [Cucumber](https://github.com/aslakhellesoy/cucumber).
|
166
|
+
* [Bartosz Blimke](https://github.com/bblimke) for [WebMock](https://github.com/bblimke/webmock).
|
167
|
+
* [Chris Kampmeier](https://github.com/chrisk) for [FakeWeb](https://github.com/chrisk/fakeweb).
|
168
|
+
* [Chris Young](https://github.com/chrisyoung) for [NetRecorder](https://github.com/chrisyoung/netrecorder),
|
169
|
+
the inspiration for VCR.
|
170
|
+
* [David Balatero](https://github.com/dbalatero) and [Hans Hasselberg](https://github.com/i0rek)
|
171
|
+
for help with [Typhoeus](https://github.com/typhoeus/typhoeus) support.
|
172
|
+
* [Wesley Beary](https://github.com/geemus) for help with [Excon](https://github.com/geemus/excon)
|
173
|
+
support.
|
174
|
+
* [Jacob Green](https://github.com/Jacobkg) for help with ongoing VCR
|
175
|
+
maintenance.
|
176
|
+
* [Jan Berdajs](https://github.com/mrbrdo) and [Daniel Berger](https://github.com/djberg96)
|
177
|
+
for improvements to thread-safety.
|
178
|
+
|
179
|
+
|
180
|
+
Thanks also to the following people who have contributed patches or helpful suggestions:
|
181
|
+
|
182
|
+
* [Aaron Brethorst](https://github.com/aaronbrethorst)
|
183
|
+
* [Alexander Wenzowski](https://github.com/wenzowski)
|
184
|
+
* [Austen Ito](https://github.com/austenito)
|
185
|
+
* [Avdi Grimm](https://github.com/avdi)
|
186
|
+
* [Bartosz Blimke](http://github.com/bblimke)
|
187
|
+
* [Benjamin Oakes](https://github.com/benjaminoakes)
|
188
|
+
* [Ben Hutton](https://github.com/benhutton)
|
189
|
+
* [Bradley Isotope](https://github.com/bradleyisotope)
|
190
|
+
* [Carlos Kirkconnell](https://github.com/kirkconnell)
|
191
|
+
* [Chad Jolly](https://github.com/cjolly)
|
192
|
+
* [Chris Le](https://github.com/chrisle)
|
193
|
+
* [Chris Gunther](https://github.com/cgunther)
|
194
|
+
* [Eduardo Maia](https://github.com/emaiax)
|
195
|
+
* [Eric Allam](https://github.com/rubymaverick)
|
196
|
+
* [Ezekiel Templin](https://github.com/ezkl)
|
197
|
+
* [Flaviu Simihaian](https://github.com/closedbracket)
|
198
|
+
* [Gordon Wilson](https://github.com/gordoncww)
|
199
|
+
* [Hans Hasselberg](https://github.com/i0rek)
|
200
|
+
* [Herman Verschooten](https://github.com/Hermanverschooten)
|
201
|
+
* [Ian Cordasco](https://github.com/sigmavirus24)
|
202
|
+
* [Ingemar](https://github.com/ingemar)
|
203
|
+
* [Ilya Scharrenbroich](https://github.com/quidproquo)
|
204
|
+
* [Jacob Green](https://github.com/Jacobkg)
|
205
|
+
* [James Bence](https://github.com/jbence)
|
206
|
+
* [Jay Shepherd](https://github.com/jayshepherd)
|
207
|
+
* [Jeff Pollard](https://github.com/Fluxx)
|
208
|
+
* [Joe Nelson](https://github.com/begriffs)
|
209
|
+
* [Jonathan Tron](https://github.com/JonathanTron)
|
210
|
+
* [Justin Smestad](https://github.com/jsmestad)
|
211
|
+
* [Karl Baum](https://github.com/kbaum)
|
212
|
+
* [Kris Luminar](https://github.com/kris-luminar)
|
213
|
+
* [Kurt Funai](https://github.com/kurtfunai)
|
214
|
+
* [Luke van der Hoeven](https://github.com/plukevdh)
|
215
|
+
* [Mark Burns](https://github.com/markburns)
|
216
|
+
* [Max Riveiro](https://github.com/kavu)
|
217
|
+
* [Michael Lavrisha](https://github.com/vrish88)
|
218
|
+
* [Michiel de Mare](https://github.com/mdemare)
|
219
|
+
* [Mike Dalton](https://github.com/kcdragon)
|
220
|
+
* [Mislav Marohnić](https://github.com/mislav)
|
221
|
+
* [Nathaniel Bibler](https://github.com/nbibler)
|
222
|
+
* [Noah Davis](https://github.com/noahd1)
|
223
|
+
* [Oliver Searle-Barnes](https://github.com/opsb)
|
224
|
+
* [Omer Rauchwerger](https://github.com/rauchy)
|
225
|
+
* [Paco Guzmán](https://github.com/pacoguzman)
|
226
|
+
* [Paul Morgan](https://github.com/jumanjiman)
|
227
|
+
* [playupchris](https://github.com/playupchris)
|
228
|
+
* [Ron Smith](https://github.com/ronwsmith)
|
229
|
+
* [Ryan Bates](https://github.com/ryanb)
|
230
|
+
* [Ryan Burrows](https://github.com/rhburrows)
|
231
|
+
* [Ryan Castillo](https://github.com/rmcastil)
|
232
|
+
* [Sathya Sekaran](https://github.com/sfsekaran)
|
233
|
+
* [Scott Carleton](https://github.com/ScotterC)
|
234
|
+
* [Shay Frendt](https://github.com/shayfrendt)
|
235
|
+
* [Steve Faulkner](https://github.com/southpolesteve)
|
236
|
+
* [Stephen Anderson](https://github.com/bendycode)
|
237
|
+
* [Todd Lunter](https://github.com/tlunter)
|
238
|
+
* [Tyler Hunt](https://github.com/tylerhunt)
|
239
|
+
* [Uģis Ozols](https://github.com/ugisozols)
|
240
|
+
* [vzvu3k6k](https://github.com/vzvu3k6k)
|
241
|
+
* [Wesley Beary](https://github.com/geemus)
|
242
|
+
|
243
|
+
|
244
|
+
# Backers
|
245
|
+
|
246
|
+
Support us with a monthly donation and help us continue our activities. [[Become a backer](https://opencollective.com/vcr#backer)]
|
247
|
+
|
248
|
+
<a href="https://opencollective.com/vcr/backer/0/website" target="_blank"><img src="https://opencollective.com/vcr/backer/0/avatar"></a>
|
249
|
+
<a href="https://opencollective.com/vcr/backer/1/website" target="_blank"><img src="https://opencollective.com/vcr/backer/1/avatar"></a>
|
250
|
+
<a href="https://opencollective.com/vcr/backer/2/website" target="_blank"><img src="https://opencollective.com/vcr/backer/2/avatar"></a>
|
251
|
+
<a href="https://opencollective.com/vcr/backer/3/website" target="_blank"><img src="https://opencollective.com/vcr/backer/3/avatar"></a>
|
252
|
+
<a href="https://opencollective.com/vcr/backer/4/website" target="_blank"><img src="https://opencollective.com/vcr/backer/4/avatar"></a>
|
253
|
+
<a href="https://opencollective.com/vcr/backer/5/website" target="_blank"><img src="https://opencollective.com/vcr/backer/5/avatar"></a>
|
254
|
+
<a href="https://opencollective.com/vcr/backer/6/website" target="_blank"><img src="https://opencollective.com/vcr/backer/6/avatar"></a>
|
255
|
+
<a href="https://opencollective.com/vcr/backer/7/website" target="_blank"><img src="https://opencollective.com/vcr/backer/7/avatar"></a>
|
256
|
+
<a href="https://opencollective.com/vcr/backer/8/website" target="_blank"><img src="https://opencollective.com/vcr/backer/8/avatar"></a>
|
257
|
+
<a href="https://opencollective.com/vcr/backer/9/website" target="_blank"><img src="https://opencollective.com/vcr/backer/9/avatar"></a>
|
258
|
+
<a href="https://opencollective.com/vcr/backer/10/website" target="_blank"><img src="https://opencollective.com/vcr/backer/10/avatar"></a>
|
259
|
+
<a href="https://opencollective.com/vcr/backer/11/website" target="_blank"><img src="https://opencollective.com/vcr/backer/11/avatar"></a>
|
260
|
+
<a href="https://opencollective.com/vcr/backer/12/website" target="_blank"><img src="https://opencollective.com/vcr/backer/12/avatar"></a>
|
261
|
+
<a href="https://opencollective.com/vcr/backer/13/website" target="_blank"><img src="https://opencollective.com/vcr/backer/13/avatar"></a>
|
262
|
+
<a href="https://opencollective.com/vcr/backer/14/website" target="_blank"><img src="https://opencollective.com/vcr/backer/14/avatar"></a>
|
263
|
+
<a href="https://opencollective.com/vcr/backer/15/website" target="_blank"><img src="https://opencollective.com/vcr/backer/15/avatar"></a>
|
264
|
+
<a href="https://opencollective.com/vcr/backer/16/website" target="_blank"><img src="https://opencollective.com/vcr/backer/16/avatar"></a>
|
265
|
+
<a href="https://opencollective.com/vcr/backer/17/website" target="_blank"><img src="https://opencollective.com/vcr/backer/17/avatar"></a>
|
266
|
+
<a href="https://opencollective.com/vcr/backer/18/website" target="_blank"><img src="https://opencollective.com/vcr/backer/18/avatar"></a>
|
267
|
+
<a href="https://opencollective.com/vcr/backer/19/website" target="_blank"><img src="https://opencollective.com/vcr/backer/19/avatar"></a>
|
268
|
+
<a href="https://opencollective.com/vcr/backer/20/website" target="_blank"><img src="https://opencollective.com/vcr/backer/20/avatar"></a>
|
269
|
+
<a href="https://opencollective.com/vcr/backer/21/website" target="_blank"><img src="https://opencollective.com/vcr/backer/21/avatar"></a>
|
270
|
+
<a href="https://opencollective.com/vcr/backer/22/website" target="_blank"><img src="https://opencollective.com/vcr/backer/22/avatar"></a>
|
271
|
+
<a href="https://opencollective.com/vcr/backer/23/website" target="_blank"><img src="https://opencollective.com/vcr/backer/23/avatar"></a>
|
272
|
+
<a href="https://opencollective.com/vcr/backer/24/website" target="_blank"><img src="https://opencollective.com/vcr/backer/24/avatar"></a>
|
273
|
+
<a href="https://opencollective.com/vcr/backer/25/website" target="_blank"><img src="https://opencollective.com/vcr/backer/25/avatar"></a>
|
274
|
+
<a href="https://opencollective.com/vcr/backer/26/website" target="_blank"><img src="https://opencollective.com/vcr/backer/26/avatar"></a>
|
275
|
+
<a href="https://opencollective.com/vcr/backer/27/website" target="_blank"><img src="https://opencollective.com/vcr/backer/27/avatar"></a>
|
276
|
+
<a href="https://opencollective.com/vcr/backer/28/website" target="_blank"><img src="https://opencollective.com/vcr/backer/28/avatar"></a>
|
277
|
+
<a href="https://opencollective.com/vcr/backer/29/website" target="_blank"><img src="https://opencollective.com/vcr/backer/29/avatar"></a>
|
278
|
+
|
279
|
+
|
280
|
+
# Sponsors
|
281
|
+
|
282
|
+
Become a sponsor and get your logo on our README on Github with a link to your site. [[Become a sponsor](https://opencollective.com/vcr#sponsor)]
|
283
|
+
|
284
|
+
<a href="https://opencollective.com/vcr/sponsor/0/website" target="_blank"><img src="https://opencollective.com/vcr/sponsor/0/avatar"></a>
|
285
|
+
<a href="https://opencollective.com/vcr/sponsor/1/website" target="_blank"><img src="https://opencollective.com/vcr/sponsor/1/avatar"></a>
|
286
|
+
<a href="https://opencollective.com/vcr/sponsor/2/website" target="_blank"><img src="https://opencollective.com/vcr/sponsor/2/avatar"></a>
|
287
|
+
<a href="https://opencollective.com/vcr/sponsor/3/website" target="_blank"><img src="https://opencollective.com/vcr/sponsor/3/avatar"></a>
|
288
|
+
<a href="https://opencollective.com/vcr/sponsor/4/website" target="_blank"><img src="https://opencollective.com/vcr/sponsor/4/avatar"></a>
|
289
|
+
<a href="https://opencollective.com/vcr/sponsor/5/website" target="_blank"><img src="https://opencollective.com/vcr/sponsor/5/avatar"></a>
|
290
|
+
<a href="https://opencollective.com/vcr/sponsor/6/website" target="_blank"><img src="https://opencollective.com/vcr/sponsor/6/avatar"></a>
|
291
|
+
<a href="https://opencollective.com/vcr/sponsor/7/website" target="_blank"><img src="https://opencollective.com/vcr/sponsor/7/avatar"></a>
|
292
|
+
<a href="https://opencollective.com/vcr/sponsor/8/website" target="_blank"><img src="https://opencollective.com/vcr/sponsor/8/avatar"></a>
|
293
|
+
<a href="https://opencollective.com/vcr/sponsor/9/website" target="_blank"><img src="https://opencollective.com/vcr/sponsor/9/avatar"></a>
|
294
|
+
<a href="https://opencollective.com/vcr/sponsor/10/website" target="_blank"><img src="https://opencollective.com/vcr/sponsor/10/avatar"></a>
|
295
|
+
<a href="https://opencollective.com/vcr/sponsor/11/website" target="_blank"><img src="https://opencollective.com/vcr/sponsor/11/avatar"></a>
|
296
|
+
<a href="https://opencollective.com/vcr/sponsor/12/website" target="_blank"><img src="https://opencollective.com/vcr/sponsor/12/avatar"></a>
|
297
|
+
<a href="https://opencollective.com/vcr/sponsor/13/website" target="_blank"><img src="https://opencollective.com/vcr/sponsor/13/avatar"></a>
|
298
|
+
<a href="https://opencollective.com/vcr/sponsor/14/website" target="_blank"><img src="https://opencollective.com/vcr/sponsor/14/avatar"></a>
|
299
|
+
<a href="https://opencollective.com/vcr/sponsor/15/website" target="_blank"><img src="https://opencollective.com/vcr/sponsor/15/avatar"></a>
|
300
|
+
<a href="https://opencollective.com/vcr/sponsor/16/website" target="_blank"><img src="https://opencollective.com/vcr/sponsor/16/avatar"></a>
|
301
|
+
<a href="https://opencollective.com/vcr/sponsor/17/website" target="_blank"><img src="https://opencollective.com/vcr/sponsor/17/avatar"></a>
|
302
|
+
<a href="https://opencollective.com/vcr/sponsor/18/website" target="_blank"><img src="https://opencollective.com/vcr/sponsor/18/avatar"></a>
|
303
|
+
<a href="https://opencollective.com/vcr/sponsor/19/website" target="_blank"><img src="https://opencollective.com/vcr/sponsor/19/avatar"></a>
|
304
|
+
<a href="https://opencollective.com/vcr/sponsor/20/website" target="_blank"><img src="https://opencollective.com/vcr/sponsor/20/avatar"></a>
|
305
|
+
<a href="https://opencollective.com/vcr/sponsor/21/website" target="_blank"><img src="https://opencollective.com/vcr/sponsor/21/avatar"></a>
|
306
|
+
<a href="https://opencollective.com/vcr/sponsor/22/website" target="_blank"><img src="https://opencollective.com/vcr/sponsor/22/avatar"></a>
|
307
|
+
<a href="https://opencollective.com/vcr/sponsor/23/website" target="_blank"><img src="https://opencollective.com/vcr/sponsor/23/avatar"></a>
|
308
|
+
<a href="https://opencollective.com/vcr/sponsor/24/website" target="_blank"><img src="https://opencollective.com/vcr/sponsor/24/avatar"></a>
|
309
|
+
<a href="https://opencollective.com/vcr/sponsor/25/website" target="_blank"><img src="https://opencollective.com/vcr/sponsor/25/avatar"></a>
|
310
|
+
<a href="https://opencollective.com/vcr/sponsor/26/website" target="_blank"><img src="https://opencollective.com/vcr/sponsor/26/avatar"></a>
|
311
|
+
<a href="https://opencollective.com/vcr/sponsor/27/website" target="_blank"><img src="https://opencollective.com/vcr/sponsor/27/avatar"></a>
|
312
|
+
<a href="https://opencollective.com/vcr/sponsor/28/website" target="_blank"><img src="https://opencollective.com/vcr/sponsor/28/avatar"></a>
|
313
|
+
<a href="https://opencollective.com/vcr/sponsor/29/website" target="_blank"><img src="https://opencollective.com/vcr/sponsor/29/avatar"></a>
|
314
|
+
|
315
|
+
|
316
|
+
|
317
|
+
Copyright
|
318
|
+
=========
|
319
|
+
|
320
|
+
Copyright (c) 2010-2015 Myron Marston
|
321
|
+
|
322
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
323
|
+
a copy of this software and associated documentation files (the
|
324
|
+
"Software"), to deal in the Software without restriction, including
|
325
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
326
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
327
|
+
permit persons to whom the Software is furnished to do so, subject to
|
328
|
+
the following conditions:
|
329
|
+
|
330
|
+
The above copyright notice and this permission notice shall be
|
331
|
+
included in all copies or substantial portions of the Software.
|
332
|
+
|
333
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
334
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
335
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
336
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
337
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
338
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
339
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/features/Upgrade.md
ADDED
@@ -0,0 +1,289 @@
|
|
1
|
+
See the [Changelog](changelog) for a complete list of changes from VCR
|
2
|
+
1.x to 2.0. This file simply lists the most pertinent ones to upgrading.
|
3
|
+
|
4
|
+
## Supported Rubies
|
5
|
+
|
6
|
+
Ruby 1.8.6 and 1.9.1 are no longer supported.
|
7
|
+
|
8
|
+
## Configuration Changes
|
9
|
+
|
10
|
+
In VCR 1.x, your configuration block would be something like this:
|
11
|
+
|
12
|
+
``` ruby
|
13
|
+
VCR.config do |c|
|
14
|
+
c.cassette_library_dir = 'cassettes'
|
15
|
+
c.stub_with :fakeweb, :typhoeus
|
16
|
+
end
|
17
|
+
```
|
18
|
+
|
19
|
+
This will continue to work in VCR 2.0 but will generate deprecation
|
20
|
+
warnings. Instead, you should change this to:
|
21
|
+
|
22
|
+
``` ruby
|
23
|
+
VCR.configure do |c|
|
24
|
+
c.cassette_library_dir = 'cassettes'
|
25
|
+
c.hook_into :fakeweb, :typhoeus
|
26
|
+
end
|
27
|
+
```
|
28
|
+
|
29
|
+
## New Cassette Format
|
30
|
+
|
31
|
+
The cassette format has changed between VCR 1.x and VCR 2.0.
|
32
|
+
VCR 1.x cassettes cannot be used with VCR 2.0.
|
33
|
+
|
34
|
+
The easiest way to upgrade is to simply delete your cassettes and
|
35
|
+
re-record all of them. VCR also provides a rake task that attempts
|
36
|
+
to upgrade your 1.x cassettes to the new 2.0 format. To use it, add
|
37
|
+
the following line to your Rakefile:
|
38
|
+
|
39
|
+
``` ruby
|
40
|
+
load 'vcr/tasks/vcr.rake'
|
41
|
+
```
|
42
|
+
|
43
|
+
Then run `rake vcr:migrate_cassettes DIR=path/to/your/cassettes/directory` to
|
44
|
+
upgrade your cassettes. Note that this rake task may be unable to
|
45
|
+
upgrade some cassettes that make extensive use of ERB. In addition, now
|
46
|
+
that VCR 2.0 does less normalization then before, it may not be able to
|
47
|
+
migrate the cassette perfectly. It's recommended that you delete and
|
48
|
+
re-record your cassettes if you are able.
|
49
|
+
|
50
|
+
## Custom Request Matchers
|
51
|
+
|
52
|
+
VCR 2.0 allows you to register custom request matchers:
|
53
|
+
|
54
|
+
``` ruby
|
55
|
+
VCR.configure do |c|
|
56
|
+
c.register_request_matcher :port do |request_1, request_2|
|
57
|
+
URI(request_1.uri).port == URI(request_2.uri).port
|
58
|
+
end
|
59
|
+
end
|
60
|
+
```
|
61
|
+
|
62
|
+
You can also pass any callable (an object that responds to #call, such as a lambda)
|
63
|
+
to the `:match_requests_on` option:
|
64
|
+
|
65
|
+
``` ruby
|
66
|
+
port_matcher = lambda do |request_1, request_2|
|
67
|
+
URI(request_1.uri).port == URI(request_2.uri).port
|
68
|
+
end
|
69
|
+
|
70
|
+
VCR.use_cassette("example", :match_requests_on => [:host, port_matcher, :method]) do
|
71
|
+
# make an HTTP request
|
72
|
+
end
|
73
|
+
```
|
74
|
+
|
75
|
+
In addition, a helper method is provided for generating a custom
|
76
|
+
matcher that ignores one or more query parameters:
|
77
|
+
|
78
|
+
``` ruby
|
79
|
+
uri_without_timestamp = VCR.request_matchers.uri_without_param(:timestamp)
|
80
|
+
VCR.configure do |c|
|
81
|
+
c.register_request_matcher(:uri_without_timestamp, &uri_without_timestamp)
|
82
|
+
end
|
83
|
+
```
|
84
|
+
|
85
|
+
## Custom Serializers
|
86
|
+
|
87
|
+
VCR 2.0 supports multiple serializers. `:yaml`, `:json`, `:psych` and
|
88
|
+
`:syck` are supported out of the box, and it's easy to implement your
|
89
|
+
own. Custom serializers must implement `#file_extension`, `#serialize`
|
90
|
+
and `#deserialize`:
|
91
|
+
|
92
|
+
``` ruby
|
93
|
+
VCR.use_cassette("example", :serialize_with => :json) do
|
94
|
+
# make an HTTP request
|
95
|
+
end
|
96
|
+
|
97
|
+
marshal_serializer = Object.new
|
98
|
+
marshal_serializer.instance_eval do
|
99
|
+
def file_extension
|
100
|
+
"marsh"
|
101
|
+
end
|
102
|
+
|
103
|
+
def serialize(hash)
|
104
|
+
Marshal.dump(hash)
|
105
|
+
end
|
106
|
+
|
107
|
+
def deserialize(string)
|
108
|
+
Marshal.load(string)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
VCR.configure do |c|
|
113
|
+
c.cassette_serializers[:marshal] = marshal_serializer
|
114
|
+
c.default_cassette_options = { :serialize_with => :marshal }
|
115
|
+
end
|
116
|
+
```
|
117
|
+
|
118
|
+
## Request Hooks
|
119
|
+
|
120
|
+
VCR 2.0 has new request hooks, allowing you to inject custom logic
|
121
|
+
before an HTTP request, after an HTTP request, or around an HTTP
|
122
|
+
request:
|
123
|
+
|
124
|
+
``` ruby
|
125
|
+
VCR.configure do |c|
|
126
|
+
c.before_http_request do |request|
|
127
|
+
# do something with the request
|
128
|
+
end
|
129
|
+
|
130
|
+
c.after_http_request do |request, response|
|
131
|
+
# do something with the request or response
|
132
|
+
end
|
133
|
+
|
134
|
+
# around_http_request only works on ruby 1.9
|
135
|
+
c.around_http_request do |request|
|
136
|
+
uri = URI(request.uri)
|
137
|
+
if uri.host == 'api.geocoder.com'
|
138
|
+
# extract an address like "1700 E Pine St, Seattle, WA"
|
139
|
+
# from a query like "address=1700+E+Pine+St%2C+Seattle%2C+WA"
|
140
|
+
address = CGI.unescape(uri.query.split('=').last)
|
141
|
+
VCR.use_cassette("geocoding/#{address}", &request)
|
142
|
+
else
|
143
|
+
request.proceed
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
147
|
+
```
|
148
|
+
|
149
|
+
## Ignore a Request Based on Anything
|
150
|
+
|
151
|
+
You can now define what requests get ignored using a block. This
|
152
|
+
gives you the flexibility to ignore a requets based on anything.
|
153
|
+
|
154
|
+
``` ruby
|
155
|
+
VCR.configure do |c|
|
156
|
+
c.ignore_request do |request|
|
157
|
+
uri = URI(request.uri)
|
158
|
+
uri.host == 'localhost' && uri.port == 7500
|
159
|
+
end
|
160
|
+
end
|
161
|
+
```
|
162
|
+
|
163
|
+
## Integration with RSpec 2 Metadata
|
164
|
+
|
165
|
+
VCR can integrate directly with RSpec metadata:
|
166
|
+
|
167
|
+
``` ruby
|
168
|
+
VCR.configure do |c|
|
169
|
+
c.configure_rspec_metadata!
|
170
|
+
end
|
171
|
+
|
172
|
+
RSpec.configure do |c|
|
173
|
+
# so we can use `:vcr` rather than `:vcr => true`;
|
174
|
+
# in RSpec 3 this will no longer be necessary.
|
175
|
+
c.treat_symbols_as_metadata_keys_with_true_values = true
|
176
|
+
end
|
177
|
+
|
178
|
+
# apply it to an example group
|
179
|
+
describe MyAPIWrapper, :vcr do
|
180
|
+
end
|
181
|
+
|
182
|
+
describe MyAPIWrapper do
|
183
|
+
# apply it to an individual example
|
184
|
+
it "does something", :vcr do
|
185
|
+
end
|
186
|
+
|
187
|
+
# set some cassette options
|
188
|
+
it "does something", :vcr => { :record => :new_episodes } do
|
189
|
+
end
|
190
|
+
|
191
|
+
# override the cassette name
|
192
|
+
it "does something", :vcr => { :cassette_name => "something" } do
|
193
|
+
end
|
194
|
+
end
|
195
|
+
```
|
196
|
+
|
197
|
+
## Improved Faraday Integration
|
198
|
+
|
199
|
+
VCR 1.x integrated with Faraday but required that you insert
|
200
|
+
`VCR::Middleware::Faraday` into your middleware stack and configure
|
201
|
+
`stub_with :faraday`. VCR 2 now takes care of inserting itself
|
202
|
+
into the Faraday middleware stack if you configure `hook_into :faraday`.
|
203
|
+
|
204
|
+
## Improved Unhandled Error Messages
|
205
|
+
|
206
|
+
When VCR is unsure how to handle a request, the error message now contains
|
207
|
+
suggestions for how you can configure VCR or your test so it can handle
|
208
|
+
the request.
|
209
|
+
|
210
|
+
## Debug Logger
|
211
|
+
|
212
|
+
VCR 2.0 has a new configuration option that will turn on a logging mode
|
213
|
+
so you can get more insight into what VCR is doing, for troubleshooting
|
214
|
+
purposes:
|
215
|
+
|
216
|
+
``` ruby
|
217
|
+
VCR.configure do |c|
|
218
|
+
c.debug_logger = File.open('log/vcr.log')
|
219
|
+
# or...
|
220
|
+
c.debug_logger = $stderr
|
221
|
+
end
|
222
|
+
```
|
223
|
+
|
224
|
+
## Playback Changes
|
225
|
+
|
226
|
+
In VCR 1.x, a single HTTP interaction could be played back multiple
|
227
|
+
times. This was mostly due to how VCR was implemented using FakeWeb
|
228
|
+
and WebMock, and was not really by design. It's more in keeping with
|
229
|
+
the philosophy of VCR to record the entire sequence of HTTP interactions
|
230
|
+
(including the duplicate requests). In VCR 2, each recorded HTTP
|
231
|
+
interaction can only be played back once unless you use the new
|
232
|
+
`:allow_playback_repeats` option.
|
233
|
+
|
234
|
+
In VCR 1.x, request matching was delegated to the HTTP stubbing library
|
235
|
+
(typically FakeWeb or WebMock). They contain some normalization logic
|
236
|
+
that can treat some URIs that are different strings as equivalent.
|
237
|
+
For example, WebMock ignores the ordering of query parameters:
|
238
|
+
|
239
|
+
``` ruby
|
240
|
+
> require 'webmock'
|
241
|
+
=> true
|
242
|
+
> uri1 = "http://foo.com/bar?a=1&b=2"
|
243
|
+
=> "http://foo.com/bar?a=1&b=2"
|
244
|
+
> uri2 = "http://foo.com/bar?b=2&a=1"
|
245
|
+
=> "http://foo.com/bar?b=2&a=1"
|
246
|
+
> uri1 == uri2
|
247
|
+
=> false
|
248
|
+
> WebMock::Util::URI.normalize_uri(uri1) == WebMock::Util::URI.normalize_uri(uri2)
|
249
|
+
=> true
|
250
|
+
```
|
251
|
+
|
252
|
+
VCR 2, the `:uri` matcher simply [uses string
|
253
|
+
equality](https://github.com/myronmarston/vcr/blob/v2.0.0/lib/vcr/request_matcher_registry.rb#L111).
|
254
|
+
This means that there are some cases of non-deterministic URIs that VCR
|
255
|
+
1.x matched but VCR 2.0 will not match. If you need the `:uri` matcher
|
256
|
+
to be tolerant of slight variations like these, you can easily override
|
257
|
+
it:
|
258
|
+
|
259
|
+
``` ruby
|
260
|
+
VCR.configure do |c|
|
261
|
+
c.register_request_matcher(:uri) do |r1, r2|
|
262
|
+
WebMock::Util::URI.normalize_uri(r1.uri) == WebMock::Util::URI.normalize_uri(r2.uri)
|
263
|
+
end
|
264
|
+
end
|
265
|
+
```
|
266
|
+
|
267
|
+
## Preserve Exact Body Bytes
|
268
|
+
|
269
|
+
Sometimes the request or response body of an HTTP interaction cannot
|
270
|
+
be serialized and deserialized properly. Usually this is due to the body
|
271
|
+
having invalid UTF-8 bytes. This new option configures VCR to base64
|
272
|
+
encode the body in order to preserve the bytes exactly. It can either
|
273
|
+
be configured globally with a block, or set on individual cassettes:
|
274
|
+
|
275
|
+
``` ruby
|
276
|
+
VCR.configure do |c|
|
277
|
+
c.preserve_exact_body_bytes do |http_message|
|
278
|
+
http_message.body.encoding.name == 'ASCII-8BIT' ||
|
279
|
+
!http_message.body.valid_encoding?
|
280
|
+
end
|
281
|
+
end
|
282
|
+
|
283
|
+
# or....
|
284
|
+
|
285
|
+
VCR.use_cassette("my_cassette", :preserve_exact_body_bytes => true) do
|
286
|
+
# ...
|
287
|
+
end
|
288
|
+
```
|
289
|
+
|