vcr 2.2.4 → 2.2.5
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +2 -0
- data/CHANGELOG.md +20 -0
- data/README.md +7 -1
- data/features/cassettes/no_cassette.feature +4 -0
- data/features/test_frameworks/cucumber.feature +14 -2
- data/lib/vcr/errors.rb +9 -2
- data/lib/vcr/library_hooks/excon.rb +15 -7
- data/lib/vcr/library_hooks/typhoeus.rb +1 -1
- data/lib/vcr/test_frameworks/cucumber.rb +5 -1
- data/lib/vcr/version.rb +1 -1
- data/spec/support/shared_example_groups/hook_into_http_library.rb +1 -1
- data/spec/vcr/errors_spec.rb +10 -0
- data/spec/vcr/test_frameworks/cucumber_spec.rb +9 -0
- data/vcr.gemspec +2 -2
- metadata +15 -10
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,23 @@
|
|
1
|
+
## 2.2.5 (September 7, 2012)
|
2
|
+
|
3
|
+
[Full Changelog](http://github.com/myronmarston/vcr/compare/v2.2.4...v2.2.5)
|
4
|
+
|
5
|
+
Enhancements:
|
6
|
+
|
7
|
+
* Include note about `debug_logger` option in error message for
|
8
|
+
unhandled HTTP requests. Thanks to [Jacob Green](https://github.com/Jacobkg)
|
9
|
+
for implementing this.
|
10
|
+
|
11
|
+
Bug Fixes:
|
12
|
+
|
13
|
+
* Fix another edge case bug on the excon adapter that was causing it
|
14
|
+
to mis-record in certain situations that used Excon's :expects option.
|
15
|
+
* Fix the `:use_scenario_name` cucumber tags option to work properly
|
16
|
+
with scenario outlines. Thanks to [Joe
|
17
|
+
Nelson](https://github.com/begriffs) and [Stephen
|
18
|
+
Anderson](https://github.com/bendycode) for the initial bug fixes and
|
19
|
+
[Jacob Green](https://github.com/Jacobkg) for some further improvements.
|
20
|
+
|
1
21
|
## 2.2.4 (July 19, 2012)
|
2
22
|
|
3
23
|
[Full Changelog](http://github.com/myronmarston/vcr/compare/v2.2.3...v2.2.4)
|
data/README.md
CHANGED
@@ -132,6 +132,8 @@ yard server --reload
|
|
132
132
|
support.
|
133
133
|
* [Wesley Beary](https://github.com/geemus) for help with [Excon](https://github.com/geemus/excon)
|
134
134
|
support.
|
135
|
+
* [Jacob Green](https://github.com/Jacobkg) for help with ongoing VCR
|
136
|
+
maintenance.
|
135
137
|
|
136
138
|
Thanks also to the following people who have contributed patches or helpful suggestions:
|
137
139
|
|
@@ -149,11 +151,14 @@ Thanks also to the following people who have contributed patches or helpful sugg
|
|
149
151
|
* [Flaviu Simihaian](https://github.com/closedbracket)
|
150
152
|
* [Gordon Wilson](https://github.com/gordoncww)
|
151
153
|
* [Ingemar](https://github.com/ingemar)
|
154
|
+
* [Jacob Green](https://github.com/Jacobkg)
|
152
155
|
* [Jeff Pollard](https://github.com/Fluxx)
|
156
|
+
* [Joe Nelson](https://github.com/begriffs)
|
157
|
+
* [Jonathan Tron](https://github.com/JonathanTron)
|
153
158
|
* [Justin Smestad](https://github.com/jsmestad)
|
154
159
|
* [Karl Baum](https://github.com/kbaum)
|
155
160
|
* [Michael Lavrisha](https://github.com/vrish88)
|
156
|
-
* [Mislav
|
161
|
+
* [Mislav Marohnić](https://github.com/mislav)
|
157
162
|
* [Nathaniel Bibler](https://github.com/nbibler)
|
158
163
|
* [Oliver Searle-Barnes](https://github.com/opsb)
|
159
164
|
* [Omer Rauchwerger](https://github.com/rauchy)
|
@@ -161,6 +166,7 @@ Thanks also to the following people who have contributed patches or helpful sugg
|
|
161
166
|
* [playupchris](https://github.com/playupchris)
|
162
167
|
* [Ryan Bates](https://github.com/ryanb)
|
163
168
|
* [Sathya Sekaran](https://github.com/sfsekaran)
|
169
|
+
* [Steven Anderson](https://github.com/bendycode)
|
164
170
|
* [Tyler Hunt](https://github.com/tylerhunt)
|
165
171
|
* [Wesley Beary](https://github.com/geemus)
|
166
172
|
|
@@ -6,6 +6,10 @@ Feature: Error for HTTP request made when no cassette is in use
|
|
6
6
|
use. The error is helpful to pinpoint where HTTP requests are
|
7
7
|
made so you can use a VCR cassette at that point in your code.
|
8
8
|
|
9
|
+
If you want insight about how VCR attempted to handle the request,
|
10
|
+
you can use the [debug\_logger](../configuration/debug-logging)
|
11
|
+
configuration option to log more details.
|
12
|
+
|
9
13
|
If you want to allow an HTTP request to proceed as normal, you can
|
10
14
|
set the [allow\_http\_connections\_when\_no\_cassette](../configuration/allow-http-connections-when-no-cassette)
|
11
15
|
configuration option or you can temporarily turn VCR off:
|
@@ -27,6 +27,8 @@ Feature: Usage with Cucumber
|
|
27
27
|
You can also have VCR name your cassettes automatically according to the feature
|
28
28
|
and scenario name by providing :use_scenario_name => true to '#tag' or '#tags'.
|
29
29
|
In this case, the cassette will be named "<feature_name>/<scenario_name>".
|
30
|
+
For scenario outlines, VCR will record one cassette per row, and the cassettes
|
31
|
+
will be named "<feature_name>/<scenario_name>/<row_name>.
|
30
32
|
|
31
33
|
@exclude-jruby
|
32
34
|
Scenario: Record HTTP interactions in a scenario by tagging it
|
@@ -93,6 +95,14 @@ Feature: Usage with Cucumber
|
|
93
95
|
When a request is made to "http://localhost:7777/localhost_request_1"
|
94
96
|
Then the response should be "Hello localhost_request_1"
|
95
97
|
|
98
|
+
@vcr
|
99
|
+
Scenario Outline: tagged scenario outline
|
100
|
+
When a request is made to "http://localhost:7777/localhost_request_1"
|
101
|
+
Then the response should be "Hello localhost_request_1"
|
102
|
+
Examples:
|
103
|
+
| key | value |
|
104
|
+
| foo | bar |
|
105
|
+
|
96
106
|
@disallowed_1
|
97
107
|
Scenario: tagged scenario
|
98
108
|
When a request is made to "http://localhost:7777/allowed" within a cassette named "allowed"
|
@@ -105,7 +115,7 @@ Feature: Usage with Cucumber
|
|
105
115
|
"""
|
106
116
|
And the directory "features/cassettes" does not exist
|
107
117
|
When I run `cucumber WITH_SERVER=true features/vcr_example.feature`
|
108
|
-
Then it should fail with "
|
118
|
+
Then it should fail with "5 scenarios (2 failed, 3 passed)"
|
109
119
|
And the output should contain each of the following:
|
110
120
|
| An HTTP request has been made that VCR does not know how to handle: |
|
111
121
|
| GET http://localhost:7777/disallowed_1 |
|
@@ -116,11 +126,12 @@ Feature: Usage with Cucumber
|
|
116
126
|
And the file "features/cassettes/nested_cassette.yml" should contain "Hello nested_cassette"
|
117
127
|
And the file "features/cassettes/allowed.yml" should contain "Hello allowed"
|
118
128
|
And the file "features/cassettes/VCR_example/tagged_scenario.yml" should contain "Hello localhost_request_1"
|
129
|
+
And the file "features/cassettes/VCR_example/tagged_scenario_outline/_foo_bar_.yml" should contain "Hello localhost_request_1"
|
119
130
|
|
120
131
|
# Run again without the server; we'll get the same responses because VCR
|
121
132
|
# will replay the recorded responses.
|
122
133
|
When I run `cucumber features/vcr_example.feature`
|
123
|
-
Then it should fail with "
|
134
|
+
Then it should fail with "5 scenarios (2 failed, 3 passed)"
|
124
135
|
And the output should contain each of the following:
|
125
136
|
| An HTTP request has been made that VCR does not know how to handle: |
|
126
137
|
| GET http://localhost:7777/disallowed_1 |
|
@@ -131,3 +142,4 @@ Feature: Usage with Cucumber
|
|
131
142
|
And the file "features/cassettes/nested_cassette.yml" should contain "Hello nested_cassette"
|
132
143
|
And the file "features/cassettes/allowed.yml" should contain "Hello allowed"
|
133
144
|
And the file "features/cassettes/VCR_example/tagged_scenario.yml" should contain "Hello localhost_request_1"
|
145
|
+
And the file "features/cassettes/VCR_example/tagged_scenario_outline/_foo_bar_.yml" should contain "Hello localhost_request_1"
|
data/lib/vcr/errors.rb
CHANGED
@@ -183,6 +183,13 @@ module VCR
|
|
183
183
|
"change your :match_requests_on cassette option to be more lenient",
|
184
184
|
"or use a custom request matcher to allow it to match"],
|
185
185
|
"https://www.relishapp.com/myronmarston/vcr/v/%s/docs/request-matching"
|
186
|
+
],
|
187
|
+
|
188
|
+
:try_debug_logger => [
|
189
|
+
["If you're surprised VCR is raising this error",
|
190
|
+
"and want insight about how VCR attempted to handle the request,",
|
191
|
+
"you can use the debug_logger configuraiton option to log more details"],
|
192
|
+
"https://www.relishapp.com/myronmarston/vcr/v/%s/docs/configuration/debug-logging"
|
186
193
|
]
|
187
194
|
}
|
188
195
|
|
@@ -196,7 +203,7 @@ module VCR
|
|
196
203
|
def suggestions
|
197
204
|
return no_cassette_suggestions unless cassette = VCR.current_cassette
|
198
205
|
|
199
|
-
[:use_new_episodes, :ignore_request].tap do |suggestions|
|
206
|
+
[:try_debug_logger, :use_new_episodes, :ignore_request].tap do |suggestions|
|
200
207
|
suggestions.push(*record_mode_suggestion)
|
201
208
|
suggestions << :allow_playback_repeats if cassette.http_interactions.has_used_interaction_matching?(request)
|
202
209
|
suggestions.map! { |k| suggestion_for(k) }
|
@@ -205,7 +212,7 @@ module VCR
|
|
205
212
|
end
|
206
213
|
|
207
214
|
def no_cassette_suggestions
|
208
|
-
[:use_a_cassette, :allow_http_connections_when_no_cassette, :ignore_request].map do |key|
|
215
|
+
[:try_debug_logger, :use_a_cassette, :allow_http_connections_when_no_cassette, :ignore_request].map do |key|
|
209
216
|
suggestion_for(key)
|
210
217
|
end
|
211
218
|
end
|
@@ -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.
|
5
|
+
VCR::VersionChecker.new('Excon', Excon::VERSION, '0.9.6', '0.16').check_version!
|
6
6
|
|
7
7
|
module VCR
|
8
8
|
class LibraryHooks
|
@@ -46,22 +46,30 @@ module VCR
|
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
|
+
PARAMS_TO_DELETE = [:expects, :idempotent,
|
50
|
+
:instrumentor_name, :instrumentor,
|
51
|
+
:response_block, :request_block]
|
52
|
+
|
49
53
|
def real_request_params
|
50
54
|
# Excon supports a variety of options that affect how it handles failure
|
51
55
|
# and retry; we don't want to use any options here--we just want to get
|
52
56
|
# a raw response, and then the main request (with :mock => true) can
|
53
57
|
# handle failure/retry on its own with its set options.
|
54
|
-
params.merge(:mock => false, :retry_limit => 0)
|
55
|
-
[:expects, :idempotent, :instrumentor_name, :instrumentor, :response_block, :request_block].each do |key|
|
56
|
-
p.delete(key)
|
57
|
-
end
|
58
|
-
end
|
58
|
+
scrub_params_from params.merge(:mock => false, :retry_limit => 0)
|
59
59
|
end
|
60
60
|
|
61
61
|
def new_connection
|
62
62
|
# Ensure the connection is constructed with the exact same args
|
63
63
|
# that the orginal connection was constructed with.
|
64
|
-
|
64
|
+
args, options = params.fetch(:__construction_args)
|
65
|
+
options = scrub_params_from(options) if options.is_a?(Hash)
|
66
|
+
::Excon::Connection.new(*[args, options].compact)
|
67
|
+
end
|
68
|
+
|
69
|
+
def scrub_params_from(hash)
|
70
|
+
hash = hash.dup
|
71
|
+
PARAMS_TO_DELETE.each { |key| hash.delete(key) }
|
72
|
+
hash
|
65
73
|
end
|
66
74
|
|
67
75
|
def perform_real_request
|
@@ -2,7 +2,7 @@ require 'vcr/util/version_checker'
|
|
2
2
|
require 'vcr/request_handler'
|
3
3
|
require 'typhoeus'
|
4
4
|
|
5
|
-
VCR::VersionChecker.new('Typhoeus', Typhoeus::VERSION, '0.3.2', '0.
|
5
|
+
VCR::VersionChecker.new('Typhoeus', Typhoeus::VERSION, '0.3.2', '0.4').check_version!
|
6
6
|
|
7
7
|
module VCR
|
8
8
|
class LibraryHooks
|
@@ -40,7 +40,11 @@ module VCR
|
|
40
40
|
options = original_options.dup
|
41
41
|
|
42
42
|
cassette_name = if options.delete(:use_scenario_name)
|
43
|
-
|
43
|
+
feature = scenario.respond_to?(:scenario_outline) ? scenario.scenario_outline.feature : scenario.feature
|
44
|
+
name = feature.name.split("\n").first
|
45
|
+
name << "/#{scenario.scenario_outline.name}" if scenario.respond_to?(:scenario_outline)
|
46
|
+
name << "/#{scenario.name}"
|
47
|
+
name
|
44
48
|
else
|
45
49
|
"cucumber_tags/#{tag_name.gsub(/\A@/, '')}"
|
46
50
|
end
|
data/lib/vcr/version.rb
CHANGED
@@ -56,7 +56,7 @@ shared_examples_for "a hook into an HTTP library" do |library_hook_name, library
|
|
56
56
|
test_record_and_playback "with a complex escaped query param", "q=#{CGI.escape("A&(! 234k !@ kasdj232\#$ kjw35")}"
|
57
57
|
|
58
58
|
it 'plays back an empty body response exactly as it was recorded (e.g. nil vs empty string)' do
|
59
|
-
pending "awaiting an external fix", :if => library.gsub('_', '/').include?('net/http') do
|
59
|
+
pending "awaiting an external fix", :if => library.gsub('_', '/').include?('net/http') && library_hook_name != :webmock do
|
60
60
|
get_body = lambda do
|
61
61
|
VCR.use_cassette('empty_body', :record => :once) do
|
62
62
|
get_body_object make_http_request(:get, "http://localhost:#{VCR::SinatraApp.port}/204")
|
data/spec/vcr/errors_spec.rb
CHANGED
@@ -42,6 +42,10 @@ module VCR
|
|
42
42
|
it 'does not double-insert the asterisks for the bullet points' do
|
43
43
|
message.should_not match(/\s+\*\s+\*/)
|
44
44
|
end
|
45
|
+
|
46
|
+
it 'mentions the debug logging configuration option' do
|
47
|
+
message.should include('debug_logger')
|
48
|
+
end
|
45
49
|
end
|
46
50
|
|
47
51
|
context 'when there is a current cassette' do
|
@@ -122,6 +126,12 @@ module VCR
|
|
122
126
|
message.should include('2 HTTP interactions ')
|
123
127
|
end
|
124
128
|
end
|
129
|
+
|
130
|
+
it 'mentions the debug logging configuration option' do
|
131
|
+
VCR.use_cassette('example', :record => :new_episodes) do
|
132
|
+
message.should include('debug_logger')
|
133
|
+
end
|
134
|
+
end
|
125
135
|
end
|
126
136
|
end
|
127
137
|
end
|
@@ -61,6 +61,15 @@ describe VCR::CucumberTags do
|
|
61
61
|
test_tag(:name, 'tag1', 'My feature name/My scenario name')
|
62
62
|
end
|
63
63
|
|
64
|
+
it "makes a unique name for each element of scenario outline" do
|
65
|
+
subject.send(tag_method, 'tag1', :use_scenario_name => true)
|
66
|
+
|
67
|
+
scenario_with_outline = stub(:name => "My row name",
|
68
|
+
:scenario_outline => stub(:feature => stub(:name => "My feature name\nThe preamble text is not included"),
|
69
|
+
:name => "My scenario outline name"))
|
70
|
+
test_tag(:name, 'tag1', 'My feature name/My scenario outline name/My row name', scenario_with_outline)
|
71
|
+
end
|
72
|
+
|
64
73
|
it 'does not pass :use_scenario_name along the given options to the cassette' do
|
65
74
|
subject.send(tag_method, 'tag1', :use_scenario_name => true)
|
66
75
|
|
data/vcr.gemspec
CHANGED
@@ -29,7 +29,7 @@ Gem::Specification.new do |s|
|
|
29
29
|
s.add_development_dependency 'fakeweb', '~> 1.3.0'
|
30
30
|
s.add_development_dependency 'webmock', '~> 1.8.3'
|
31
31
|
|
32
|
-
s.add_development_dependency 'faraday', '~> 0.8
|
32
|
+
s.add_development_dependency 'faraday', '~> 0.8'
|
33
33
|
s.add_development_dependency 'httpclient', '~> 2.2'
|
34
34
|
s.add_development_dependency 'excon', '>= 0.11.0', '< 1.0'
|
35
35
|
|
@@ -45,7 +45,7 @@ Gem::Specification.new do |s|
|
|
45
45
|
s.add_development_dependency 'patron', '~> 0.4.15'
|
46
46
|
s.add_development_dependency 'em-http-request', '~> 1.0.2'
|
47
47
|
s.add_development_dependency 'curb', '~> 0.8.0'
|
48
|
-
s.add_development_dependency 'typhoeus', '
|
48
|
+
s.add_development_dependency 'typhoeus', '>= 0.3.3', '< 0.5.0'
|
49
49
|
s.add_development_dependency 'yajl-ruby', '~> 1.1.0'
|
50
50
|
end
|
51
51
|
end
|
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:
|
4
|
+
hash: 13
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 2
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 2.2.
|
9
|
+
- 5
|
10
|
+
version: 2.2.5
|
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-
|
18
|
+
date: 2012-09-08 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
version_requirements: &id001 !ruby/object:Gem::Requirement
|
@@ -150,14 +150,11 @@ dependencies:
|
|
150
150
|
requirements:
|
151
151
|
- - ~>
|
152
152
|
- !ruby/object:Gem::Version
|
153
|
-
hash:
|
153
|
+
hash: 27
|
154
154
|
segments:
|
155
155
|
- 0
|
156
156
|
- 8
|
157
|
-
|
158
|
-
- rc
|
159
|
-
- 2
|
160
|
-
version: 0.8.0.rc2
|
157
|
+
version: "0.8"
|
161
158
|
name: faraday
|
162
159
|
type: :development
|
163
160
|
prerelease: false
|
@@ -364,7 +361,7 @@ dependencies:
|
|
364
361
|
version_requirements: &id022 !ruby/object:Gem::Requirement
|
365
362
|
none: false
|
366
363
|
requirements:
|
367
|
-
- -
|
364
|
+
- - ">="
|
368
365
|
- !ruby/object:Gem::Version
|
369
366
|
hash: 21
|
370
367
|
segments:
|
@@ -372,6 +369,14 @@ dependencies:
|
|
372
369
|
- 3
|
373
370
|
- 3
|
374
371
|
version: 0.3.3
|
372
|
+
- - <
|
373
|
+
- !ruby/object:Gem::Version
|
374
|
+
hash: 11
|
375
|
+
segments:
|
376
|
+
- 0
|
377
|
+
- 5
|
378
|
+
- 0
|
379
|
+
version: 0.5.0
|
375
380
|
name: typhoeus
|
376
381
|
type: :development
|
377
382
|
prerelease: false
|