vcr 1.11.3 → 2.0.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/.travis.yml +6 -2
- data/CHANGELOG.md +49 -1
- data/Gemfile +1 -5
- data/Guardfile +0 -5
- data/README.md +3 -2
- data/Rakefile +11 -16
- data/cucumber.yml +0 -4
- data/features/.nav +14 -2
- data/features/cassettes/automatic_re_recording.feature +4 -6
- data/features/cassettes/dynamic_erb.feature +6 -8
- data/features/cassettes/exclusive.feature +111 -0
- data/features/cassettes/format.feature +16 -14
- data/features/cassettes/naming.feature +4 -6
- data/features/cassettes/no_cassette.feature +25 -28
- data/features/cassettes/update_content_length_header.feature +9 -9
- data/features/configuration/allow_http_connections_when_no_cassette.feature +6 -8
- data/features/configuration/cassette_library_dir.feature +4 -6
- data/features/configuration/default_cassette_options.feature +12 -10
- data/features/configuration/filter_sensitive_data.feature +12 -17
- data/features/configuration/{stub_with.feature → hook_into.feature} +63 -62
- data/features/configuration/hooks.feature +23 -33
- data/features/configuration/ignore_hosts.feature +16 -17
- data/features/configuration/ignore_localhost.feature +33 -42
- data/features/http_libraries/em_http_request.feature +7 -8
- data/features/http_libraries/net_http.feature +26 -28
- data/features/middleware/faraday.feature +17 -56
- data/features/middleware/rack.feature +8 -11
- data/features/record_modes/all.feature +5 -7
- data/features/record_modes/new_episodes.feature +5 -7
- data/features/record_modes/none.feature +6 -6
- data/features/record_modes/once.feature +6 -8
- data/features/request_matching/README.md +28 -0
- data/features/request_matching/body.feature +81 -0
- data/features/request_matching/custom_matcher.feature +125 -0
- data/features/request_matching/headers.feature +85 -0
- data/features/request_matching/host.feature +85 -0
- data/features/request_matching/identical_request_sequence.feature +79 -0
- data/features/request_matching/method.feature +86 -0
- data/features/request_matching/path.feature +86 -0
- data/features/request_matching/playback_repeats.feature +87 -0
- data/features/request_matching/uri.feature +84 -0
- data/features/request_matching/uri_without_param.feature +85 -0
- data/features/step_definitions/cli_steps.rb +4 -28
- data/features/support/env.rb +11 -9
- data/features/support/http_lib_filters.rb +2 -11
- data/features/support/vcr_cucumber_helpers.rb +4 -5
- data/features/test_frameworks/cucumber.feature +17 -18
- data/features/test_frameworks/rspec.feature +8 -12
- data/features/test_frameworks/shoulda.feature +5 -8
- data/features/test_frameworks/test_unit.feature +5 -8
- data/lib/vcr.rb +38 -58
- data/lib/vcr/cassette.rb +41 -60
- data/lib/vcr/cassette/http_interaction_list.rb +56 -0
- data/lib/vcr/cassette/reader.rb +29 -31
- data/lib/vcr/configuration.rb +76 -0
- data/lib/vcr/deprecations.rb +39 -0
- data/lib/vcr/errors.rb +22 -0
- data/lib/vcr/library_hooks.rb +19 -0
- data/lib/vcr/library_hooks/excon.rb +136 -0
- data/lib/vcr/library_hooks/fakeweb.rb +110 -0
- data/lib/vcr/library_hooks/faraday.rb +3 -0
- data/lib/vcr/library_hooks/typhoeus.rb +98 -0
- data/lib/vcr/library_hooks/webmock.rb +100 -0
- data/lib/vcr/middleware/faraday.rb +43 -36
- data/lib/vcr/middleware/rack.rb +28 -4
- data/lib/vcr/request_handler.rb +43 -0
- data/lib/vcr/request_ignorer.rb +31 -0
- data/lib/vcr/request_matcher_registry.rb +86 -0
- data/lib/vcr/structs/http_interaction.rb +24 -18
- data/lib/vcr/structs/normalizers/body.rb +1 -1
- data/lib/vcr/structs/normalizers/header.rb +1 -1
- data/lib/vcr/structs/normalizers/status_message.rb +1 -1
- data/lib/vcr/structs/normalizers/uri.rb +1 -1
- data/lib/vcr/structs/request.rb +0 -13
- data/lib/vcr/structs/response.rb +2 -9
- data/lib/vcr/structs/response_status.rb +0 -4
- data/lib/vcr/test_frameworks/cucumber.rb +1 -1
- data/lib/vcr/test_frameworks/rspec.rb +1 -1
- data/lib/vcr/util/hooks.rb +28 -19
- data/lib/vcr/util/internet_connection.rb +29 -2
- data/lib/vcr/util/version_checker.rb +60 -0
- data/lib/vcr/version.rb +1 -1
- data/script/FullBuildRakeFile +0 -7
- data/script/full_build +1 -1
- data/spec/capture_warnings.rb +36 -31
- data/spec/fixtures/{1.9.1/cassette_spec → cassette_spec}/empty.yml +0 -0
- data/spec/fixtures/{not_1.9.1/cassette_spec → cassette_spec}/example.yml +0 -0
- data/spec/fixtures/{not_1.9.1/cassette_spec → cassette_spec}/with_localhost_requests.yml +0 -0
- data/spec/fixtures/{not_1.9.1/fake_example.com_responses.yml → fake_example.com_responses.yml} +0 -0
- data/spec/fixtures/{not_1.9.1/match_requests_on.yml → match_requests_on.yml} +0 -0
- data/spec/monkey_patches.rb +40 -11
- data/spec/spec_helper.rb +7 -43
- data/spec/support/http_library_adapters.rb +3 -13
- data/spec/support/shared_example_groups/{http_library.rb → hook_into_http_library.rb} +39 -111
- data/spec/support/shared_example_groups/version_checking.rb +9 -9
- data/spec/vcr/cassette/http_interaction_list_spec.rb +178 -0
- data/spec/vcr/cassette/reader_spec.rb +2 -2
- data/spec/vcr/cassette_spec.rb +121 -156
- data/spec/vcr/configuration_spec.rb +143 -0
- data/spec/vcr/deprecations_spec.rb +91 -0
- data/spec/vcr/{http_stubbing_adapters → library_hooks}/excon_spec.rb +6 -9
- data/spec/vcr/library_hooks/fakeweb_spec.rb +83 -0
- data/spec/vcr/{http_stubbing_adapters → library_hooks}/typhoeus_spec.rb +7 -11
- data/spec/vcr/library_hooks/webmock_spec.rb +17 -0
- data/spec/vcr/library_hooks_spec.rb +51 -0
- data/spec/vcr/middleware/faraday_spec.rb +17 -44
- data/spec/vcr/middleware/rack_spec.rb +94 -58
- data/spec/vcr/request_ignorer_spec.rb +54 -0
- data/spec/vcr/request_matcher_registry_spec.rb +223 -0
- data/spec/vcr/structs/request_spec.rb +0 -33
- data/spec/vcr/structs/response_spec.rb +0 -24
- data/spec/vcr/structs/response_status_spec.rb +0 -9
- data/spec/vcr/util/hooks_spec.rb +3 -5
- data/spec/vcr/version_spec.rb +1 -1
- data/spec/vcr_spec.rb +79 -91
- data/vcr.gemspec +1 -1
- metadata +83 -103
- data/features/cassettes/request_matching.feature +0 -383
- data/lib/vcr/config.rb +0 -84
- data/lib/vcr/deprecations/cassette.rb +0 -29
- data/lib/vcr/deprecations/config.rb +0 -18
- data/lib/vcr/deprecations/http_stubbing_adapters/common.rb +0 -9
- data/lib/vcr/deprecations/http_stubbing_adapters/fakeweb.rb +0 -11
- data/lib/vcr/extensions/net_http.rb +0 -32
- data/lib/vcr/http_stubbing_adapters/common.rb +0 -202
- data/lib/vcr/http_stubbing_adapters/excon.rb +0 -178
- data/lib/vcr/http_stubbing_adapters/fakeweb.rb +0 -107
- data/lib/vcr/http_stubbing_adapters/faraday.rb +0 -26
- data/lib/vcr/http_stubbing_adapters/multi_object_proxy.rb +0 -43
- data/lib/vcr/http_stubbing_adapters/typhoeus.rb +0 -115
- data/lib/vcr/http_stubbing_adapters/webmock.rb +0 -120
- data/lib/vcr/middleware/cassette_arguments.rb +0 -19
- data/lib/vcr/middleware/common.rb +0 -20
- data/lib/vcr/request_matcher.rb +0 -94
- data/lib/vcr/rspec.rb +0 -2
- data/lib/vcr/util/basic_object.rb +0 -43
- data/lib/vcr/util/ping.rb +0 -30
- data/lib/vcr/util/regexes.rb +0 -37
- data/spec/fixtures/1.9.1/0_3_1_cassette.yml +0 -29
- data/spec/fixtures/1.9.1/cassette_spec/example.yml +0 -110
- data/spec/fixtures/1.9.1/cassette_spec/with_localhost_requests.yml +0 -109
- data/spec/fixtures/1.9.1/example_net_http.yml +0 -14
- data/spec/fixtures/1.9.1/example_net_http_request.yml +0 -12
- data/spec/fixtures/1.9.1/example_net_http_response.yml +0 -25
- data/spec/fixtures/1.9.1/fake_example.com_responses.yml +0 -108
- data/spec/fixtures/1.9.1/match_requests_on.yml +0 -185
- data/spec/fixtures/not_1.9.1/0_3_1_cassette.yml +0 -29
- data/spec/fixtures/not_1.9.1/cassette_spec/empty.yml +0 -0
- data/spec/fixtures/not_1.9.1/example_net_http.yml +0 -14
- data/spec/fixtures/not_1.9.1/example_net_http_request.yml +0 -12
- data/spec/fixtures/not_1.9.1/example_net_http_response.yml +0 -25
- data/spec/support/shared_example_groups/http_stubbing_adapter.rb +0 -133
- data/spec/support/shared_example_groups/ignore_localhost_deprecation.rb +0 -28
- data/spec/vcr/config_spec.rb +0 -181
- data/spec/vcr/deprecations/cassette_spec.rb +0 -57
- data/spec/vcr/deprecations/config_spec.rb +0 -30
- data/spec/vcr/deprecations/http_stubbing_adapters/common_spec.rb +0 -7
- data/spec/vcr/deprecations/http_stubbing_adapters/fakeweb_spec.rb +0 -16
- data/spec/vcr/extensions/net_http_spec.rb +0 -80
- data/spec/vcr/http_stubbing_adapters/fakeweb_spec.rb +0 -19
- data/spec/vcr/http_stubbing_adapters/faraday_spec.rb +0 -76
- data/spec/vcr/http_stubbing_adapters/multi_object_proxy_spec.rb +0 -101
- data/spec/vcr/http_stubbing_adapters/webmock_spec.rb +0 -17
- data/spec/vcr/middleware/cassette_arguments_spec.rb +0 -32
- data/spec/vcr/request_matcher_spec.rb +0 -230
@@ -7,7 +7,7 @@ Feature: Hooks
|
|
7
7
|
- `before_playback`: Called before a cassette sets up its stubs for playback.
|
8
8
|
|
9
9
|
To use these, call `config.before_record` or `config.before_playback` in
|
10
|
-
your `VCR.
|
10
|
+
your `VCR.configure` block. Provide a block that accepts 0, 1 or 2 arguments.
|
11
11
|
|
12
12
|
The first argument, if the block accepts it, will be an HTTP interaction.
|
13
13
|
Changes you make to the interaction will be reflected in the recording or
|
@@ -22,7 +22,7 @@ Feature: Hooks
|
|
22
22
|
You can also use tagging to apply hooks to particular cassettes. Consider
|
23
23
|
this code:
|
24
24
|
|
25
|
-
VCR.
|
25
|
+
VCR.configure do |c|
|
26
26
|
c.before_record(:twitter) { ... } # modify the interactions somehow
|
27
27
|
end
|
28
28
|
|
@@ -60,17 +60,15 @@ Feature: Hooks
|
|
60
60
|
|
61
61
|
Scenario: Replace sensitive data with before_record hook
|
62
62
|
Given a file named "before_record_example.rb" with:
|
63
|
-
"""
|
64
|
-
require 'vcr_cucumber_helpers'
|
65
|
-
|
63
|
+
"""ruby
|
66
64
|
start_sinatra_app(:port => 7777) do
|
67
65
|
get('/') { "Hello <secret>" }
|
68
66
|
end
|
69
67
|
|
70
68
|
require 'vcr'
|
71
69
|
|
72
|
-
VCR.
|
73
|
-
c.
|
70
|
+
VCR.configure do |c|
|
71
|
+
c.hook_into :fakeweb
|
74
72
|
c.cassette_library_dir = 'cassettes'
|
75
73
|
|
76
74
|
c.before_record do |i|
|
@@ -79,7 +77,7 @@ Feature: Hooks
|
|
79
77
|
|
80
78
|
end
|
81
79
|
|
82
|
-
VCR.use_cassette('recording_example'
|
80
|
+
VCR.use_cassette('recording_example') do
|
83
81
|
Net::HTTP.get_response('localhost', '/', 7777)
|
84
82
|
end
|
85
83
|
"""
|
@@ -89,22 +87,20 @@ Feature: Hooks
|
|
89
87
|
|
90
88
|
Scenario: Prevent recording by ignoring interaction in before_record hook
|
91
89
|
Given a file named "before_record_ignore.rb" with:
|
92
|
-
"""
|
93
|
-
require 'vcr_cucumber_helpers'
|
94
|
-
|
90
|
+
"""ruby
|
95
91
|
start_sinatra_app(:port => 7777) do
|
96
92
|
get('/') { "Hello World" }
|
97
93
|
end
|
98
94
|
|
99
95
|
require 'vcr'
|
100
96
|
|
101
|
-
VCR.
|
102
|
-
c.
|
97
|
+
VCR.configure do |c|
|
98
|
+
c.hook_into :fakeweb
|
103
99
|
c.cassette_library_dir = 'cassettes'
|
104
100
|
c.before_record { |i| i.ignore! }
|
105
101
|
end
|
106
102
|
|
107
|
-
VCR.use_cassette('recording_example'
|
103
|
+
VCR.use_cassette('recording_example') do
|
108
104
|
response = Net::HTTP.get_response('localhost', '/', 7777)
|
109
105
|
puts "Response: #{response.body}"
|
110
106
|
end
|
@@ -115,11 +111,11 @@ Feature: Hooks
|
|
115
111
|
|
116
112
|
Scenario: Change playback with before_playback hook
|
117
113
|
Given a file named "before_playback_example.rb" with:
|
118
|
-
"""
|
114
|
+
"""ruby
|
119
115
|
require 'vcr'
|
120
116
|
|
121
|
-
VCR.
|
122
|
-
c.
|
117
|
+
VCR.configure do |c|
|
118
|
+
c.hook_into :fakeweb
|
123
119
|
c.cassette_library_dir = 'cassettes'
|
124
120
|
|
125
121
|
c.before_playback do |i|
|
@@ -127,7 +123,7 @@ Feature: Hooks
|
|
127
123
|
end
|
128
124
|
end
|
129
125
|
|
130
|
-
VCR.use_cassette('example'
|
126
|
+
VCR.use_cassette('example') do
|
131
127
|
response = Net::HTTP.get_response('example.com', '/foo')
|
132
128
|
puts "Response: #{response.body}"
|
133
129
|
end
|
@@ -158,17 +154,15 @@ Feature: Hooks
|
|
158
154
|
http_version: "1.1"
|
159
155
|
"""
|
160
156
|
And a file named "before_playback_ignore.rb" with:
|
161
|
-
"""
|
162
|
-
require 'vcr_cucumber_helpers'
|
163
|
-
|
157
|
+
"""ruby
|
164
158
|
start_sinatra_app(:port => 7777) do
|
165
159
|
get('/') { "sinatra response" }
|
166
160
|
end
|
167
161
|
|
168
162
|
require 'vcr'
|
169
163
|
|
170
|
-
VCR.
|
171
|
-
c.
|
164
|
+
VCR.configure do |c|
|
165
|
+
c.hook_into :fakeweb
|
172
166
|
c.cassette_library_dir = 'cassettes'
|
173
167
|
c.before_playback { |i| i.ignore! }
|
174
168
|
end
|
@@ -183,17 +177,15 @@ Feature: Hooks
|
|
183
177
|
|
184
178
|
Scenario: Multiple hooks are run in order
|
185
179
|
Given a file named "multiple_hooks.rb" with:
|
186
|
-
"""
|
187
|
-
require 'vcr_cucumber_helpers'
|
188
|
-
|
180
|
+
"""ruby
|
189
181
|
start_sinatra_app(:port => 7777) do
|
190
182
|
get('/') { "Hello World" }
|
191
183
|
end
|
192
184
|
|
193
185
|
require 'vcr'
|
194
186
|
|
195
|
-
VCR.
|
196
|
-
c.
|
187
|
+
VCR.configure do |c|
|
188
|
+
c.hook_into :fakeweb
|
197
189
|
c.cassette_library_dir = 'cassettes'
|
198
190
|
|
199
191
|
c.before_record { puts "In before_record hook 1" }
|
@@ -224,17 +216,15 @@ Feature: Hooks
|
|
224
216
|
|
225
217
|
Scenario: Use tagging to apply hooks to only certain cassettes
|
226
218
|
Given a file named "tagged_hooks.rb" with:
|
227
|
-
"""
|
228
|
-
require 'vcr_cucumber_helpers'
|
229
|
-
|
219
|
+
"""ruby
|
230
220
|
start_sinatra_app(:port => 7777) do
|
231
221
|
get('/') { "Hello World" }
|
232
222
|
end
|
233
223
|
|
234
224
|
require 'vcr'
|
235
225
|
|
236
|
-
VCR.
|
237
|
-
c.
|
226
|
+
VCR.configure do |c|
|
227
|
+
c.hook_into :fakeweb
|
238
228
|
c.cassette_library_dir = 'cassettes'
|
239
229
|
|
240
230
|
c.before_record(:tag_1) { |i| puts "In before_record hook for tag_1 (#{i.response.body})" }
|
@@ -11,9 +11,7 @@ Feature: ignore_hosts
|
|
11
11
|
|
12
12
|
Background:
|
13
13
|
Given a file named "sinatra_app.rb" with:
|
14
|
-
"""
|
15
|
-
require 'vcr_cucumber_helpers'
|
16
|
-
|
14
|
+
"""ruby
|
17
15
|
response_count = 0
|
18
16
|
start_sinatra_app(:port => 7777) do
|
19
17
|
get('/') { "Response #{response_count += 1}" }
|
@@ -22,20 +20,19 @@ Feature: ignore_hosts
|
|
22
20
|
|
23
21
|
Scenario Outline: ignored host requests are not recorded and are always allowed
|
24
22
|
Given a file named "ignore_hosts.rb" with:
|
25
|
-
"""
|
26
|
-
require 'vcr_cucumber_helpers'
|
23
|
+
"""ruby
|
27
24
|
include_http_adapter_for("<http_lib>")
|
28
25
|
require 'sinatra_app.rb'
|
29
26
|
|
30
27
|
require 'vcr'
|
31
28
|
|
32
|
-
VCR.
|
29
|
+
VCR.configure do |c|
|
33
30
|
c.ignore_hosts '127.0.0.1', 'localhost'
|
34
31
|
c.cassette_library_dir = 'cassettes'
|
35
|
-
|
32
|
+
<configuration>
|
36
33
|
end
|
37
34
|
|
38
|
-
VCR.use_cassette('example'
|
35
|
+
VCR.use_cassette('example') do
|
39
36
|
puts response_body_for(:get, "http://localhost:7777/")
|
40
37
|
end
|
41
38
|
|
@@ -50,13 +47,15 @@ Feature: ignore_hosts
|
|
50
47
|
And the file "cassettes/example.yml" should not exist
|
51
48
|
|
52
49
|
Examples:
|
53
|
-
|
|
54
|
-
| :fakeweb
|
55
|
-
| :webmock
|
56
|
-
| :webmock
|
57
|
-
| :webmock
|
58
|
-
| :webmock
|
59
|
-
| :webmock
|
60
|
-
| :
|
61
|
-
| :
|
50
|
+
| configuration | http_lib |
|
51
|
+
| c.hook_into :fakeweb | net/http |
|
52
|
+
| c.hook_into :webmock | net/http |
|
53
|
+
| c.hook_into :webmock | httpclient |
|
54
|
+
| c.hook_into :webmock | curb |
|
55
|
+
| c.hook_into :webmock | patron |
|
56
|
+
| c.hook_into :webmock | em-http-request |
|
57
|
+
| c.hook_into :webmock | typhoeus |
|
58
|
+
| c.hook_into :typhoeus | typhoeus |
|
59
|
+
| c.hook_into :excon | excon |
|
60
|
+
| | faraday (w/ net_http) |
|
62
61
|
|
@@ -11,75 +11,64 @@ Feature: ignore_localhost
|
|
11
11
|
|
12
12
|
Background:
|
13
13
|
Given a file named "sinatra_app.rb" with:
|
14
|
-
"""
|
15
|
-
require 'vcr_cucumber_helpers'
|
16
|
-
|
14
|
+
"""ruby
|
17
15
|
response_count = 0
|
18
16
|
start_sinatra_app(:port => 7777) do
|
19
17
|
get('/') { "Response #{response_count += 1}" }
|
20
18
|
end
|
21
19
|
"""
|
22
20
|
|
23
|
-
Scenario Outline: localhost requests are not treated differently by default
|
21
|
+
Scenario Outline: localhost requests are not treated differently by default
|
24
22
|
Given a file named "localhost_not_ignored.rb" with:
|
25
|
-
"""
|
26
|
-
require 'vcr_cucumber_helpers'
|
23
|
+
"""ruby
|
27
24
|
include_http_adapter_for("<http_lib>")
|
28
25
|
require 'sinatra_app.rb'
|
29
26
|
|
30
27
|
require 'vcr'
|
31
28
|
|
32
|
-
VCR.
|
33
|
-
<additional_config>
|
29
|
+
VCR.configure do |c|
|
34
30
|
c.cassette_library_dir = 'cassettes'
|
35
|
-
|
31
|
+
<configuration>
|
36
32
|
end
|
37
33
|
|
38
|
-
VCR.use_cassette('localhost'
|
34
|
+
VCR.use_cassette('localhost') do
|
39
35
|
response_body_for(:get, "http://localhost:7777/")
|
40
36
|
end
|
41
37
|
|
42
38
|
response_body_for(:get, "http://localhost:7777/")
|
43
39
|
"""
|
44
40
|
When I run `ruby localhost_not_ignored.rb`
|
45
|
-
Then it should fail with "
|
41
|
+
Then it should fail with "Real HTTP connections are disabled"
|
46
42
|
And the file "cassettes/localhost.yml" should contain "body: Response 1"
|
47
43
|
|
48
44
|
Examples:
|
49
|
-
|
|
50
|
-
| :fakeweb
|
51
|
-
| :
|
52
|
-
| :webmock
|
53
|
-
| :webmock
|
54
|
-
| :webmock
|
55
|
-
| :webmock
|
56
|
-
| :webmock
|
57
|
-
|
|
58
|
-
| :
|
59
|
-
|
|
60
|
-
| :webmock | em-http-request | Real HTTP connections are disabled | |
|
61
|
-
| :webmock | em-http-request | Real HTTP connections are disabled | c.ignore_localhost = false |
|
62
|
-
| :typhoeus | typhoeus | Real HTTP requests are not allowed | |
|
63
|
-
| :typhoeus | typhoeus | Real HTTP requests are not allowed | c.ignore_localhost = false |
|
64
|
-
| :excon | excon | Real HTTP connections are disabled | |
|
65
|
-
| :excon | excon | Real HTTP connections are disabled | c.ignore_localhost = false |
|
45
|
+
| configuration | http_lib |
|
46
|
+
| c.hook_into :fakeweb | net/http |
|
47
|
+
| c.hook_into :webmock | net/http |
|
48
|
+
| c.hook_into :webmock | httpclient |
|
49
|
+
| c.hook_into :webmock | curb |
|
50
|
+
| c.hook_into :webmock | patron |
|
51
|
+
| c.hook_into :webmock | em-http-request |
|
52
|
+
| c.hook_into :webmock | typhoeus |
|
53
|
+
| c.hook_into :typhoeus | typhoeus |
|
54
|
+
| c.hook_into :excon | excon |
|
55
|
+
| | faraday (w/ net_http) |
|
66
56
|
|
67
57
|
Scenario Outline: localhost requests are allowed and not recorded when ignore_localhost = true
|
68
58
|
Given a file named "ignore_localhost_true.rb" with:
|
69
|
-
"""
|
70
|
-
require 'vcr_cucumber_helpers'
|
59
|
+
"""ruby
|
71
60
|
include_http_adapter_for("<http_lib>")
|
72
61
|
require 'sinatra_app.rb'
|
73
62
|
|
74
63
|
require 'vcr'
|
75
64
|
|
76
|
-
VCR.
|
65
|
+
VCR.configure do |c|
|
77
66
|
c.ignore_localhost = true
|
78
67
|
c.cassette_library_dir = 'cassettes'
|
79
|
-
|
68
|
+
<configuration>
|
80
69
|
end
|
81
70
|
|
82
|
-
VCR.use_cassette('localhost'
|
71
|
+
VCR.use_cassette('localhost') do
|
83
72
|
puts response_body_for(:get, "http://localhost:7777/")
|
84
73
|
end
|
85
74
|
|
@@ -94,13 +83,15 @@ Feature: ignore_localhost
|
|
94
83
|
And the file "cassettes/localhost.yml" should not exist
|
95
84
|
|
96
85
|
Examples:
|
97
|
-
|
|
98
|
-
| :fakeweb
|
99
|
-
| :webmock
|
100
|
-
| :webmock
|
101
|
-
| :webmock
|
102
|
-
| :webmock
|
103
|
-
| :webmock
|
104
|
-
| :
|
105
|
-
| :
|
86
|
+
| configuration | http_lib |
|
87
|
+
| c.hook_into :fakeweb | net/http |
|
88
|
+
| c.hook_into :webmock | net/http |
|
89
|
+
| c.hook_into :webmock | httpclient |
|
90
|
+
| c.hook_into :webmock | curb |
|
91
|
+
| c.hook_into :webmock | patron |
|
92
|
+
| c.hook_into :webmock | em-http-request |
|
93
|
+
| c.hook_into :webmock | typhoeus |
|
94
|
+
| c.hook_into :typhoeus | typhoeus |
|
95
|
+
| c.hook_into :excon | excon |
|
96
|
+
| | faraday (w/ net_http) |
|
106
97
|
|
@@ -7,9 +7,8 @@ Feature: EM HTTP Request
|
|
7
7
|
|
8
8
|
Background:
|
9
9
|
Given a file named "vcr_setup.rb" with:
|
10
|
-
"""
|
10
|
+
"""ruby
|
11
11
|
require 'em-http-request'
|
12
|
-
require 'vcr_cucumber_helpers'
|
13
12
|
|
14
13
|
start_sinatra_app(:port => 7777) do
|
15
14
|
%w[ foo bar bazz ].each_with_index do |path, index|
|
@@ -22,18 +21,18 @@ Feature: EM HTTP Request
|
|
22
21
|
|
23
22
|
require 'vcr'
|
24
23
|
|
25
|
-
VCR.
|
26
|
-
c.
|
24
|
+
VCR.configure do |c|
|
25
|
+
c.hook_into :webmock
|
27
26
|
c.cassette_library_dir = 'cassettes'
|
28
27
|
end
|
29
28
|
"""
|
30
29
|
|
31
30
|
Scenario: multiple simultaneous HttpRequest objects
|
32
31
|
Given a file named "make_requests.rb" with:
|
33
|
-
"""
|
32
|
+
"""ruby
|
34
33
|
require 'vcr_setup'
|
35
34
|
|
36
|
-
VCR.use_cassette('em_http'
|
35
|
+
VCR.use_cassette('em_http') do
|
37
36
|
EventMachine.run do
|
38
37
|
http_array = %w[ foo bar bazz ].map do |p|
|
39
38
|
EventMachine::HttpRequest.new("http://localhost:7777/#{p}").get
|
@@ -124,10 +123,10 @@ Feature: EM HTTP Request
|
|
124
123
|
|
125
124
|
Scenario: MultiRequest
|
126
125
|
Given a file named "make_requests.rb" with:
|
127
|
-
"""
|
126
|
+
"""ruby
|
128
127
|
require 'vcr_setup'
|
129
128
|
|
130
|
-
VCR.use_cassette('em_http'
|
129
|
+
VCR.use_cassette('em_http') do
|
131
130
|
EventMachine.run do
|
132
131
|
multi = EventMachine::MultiRequest.new
|
133
132
|
|
@@ -6,9 +6,7 @@ Feature: Net::HTTP
|
|
6
6
|
|
7
7
|
Background:
|
8
8
|
Given a file named "vcr_setup.rb" with:
|
9
|
-
"""
|
10
|
-
require 'vcr_cucumber_helpers'
|
11
|
-
|
9
|
+
"""ruby
|
12
10
|
if ARGV[0] == '--with-server'
|
13
11
|
start_sinatra_app(:port => 7777) do
|
14
12
|
get('/') { 'VCR works with Net::HTTP gets!' }
|
@@ -21,15 +19,15 @@ Feature: Net::HTTP
|
|
21
19
|
|
22
20
|
Scenario Outline: Calling #post on new Net::HTTP instance
|
23
21
|
Given a file named "vcr_net_http.rb" with:
|
24
|
-
"""
|
22
|
+
"""ruby
|
25
23
|
require 'vcr_setup.rb'
|
26
24
|
|
27
|
-
VCR.
|
28
|
-
c.
|
25
|
+
VCR.configure do |c|
|
26
|
+
c.hook_into <hook_into>
|
29
27
|
c.cassette_library_dir = 'cassettes'
|
30
28
|
end
|
31
29
|
|
32
|
-
VCR.use_cassette('net_http'
|
30
|
+
VCR.use_cassette('net_http') do
|
33
31
|
puts Net::HTTP.new('localhost', 7777).post('/', '').body
|
34
32
|
end
|
35
33
|
"""
|
@@ -41,17 +39,17 @@ Feature: Net::HTTP
|
|
41
39
|
Then the output should contain "VCR works with Net::HTTP posts!"
|
42
40
|
|
43
41
|
Examples:
|
44
|
-
|
|
42
|
+
| hook_into |
|
45
43
|
| :fakeweb |
|
46
44
|
| :webmock |
|
47
45
|
|
48
46
|
Scenario Outline: Return from yielded block
|
49
47
|
Given a file named "vcr_net_http.rb" with:
|
50
|
-
"""
|
48
|
+
"""ruby
|
51
49
|
require 'vcr_setup.rb'
|
52
50
|
|
53
|
-
VCR.
|
54
|
-
c.
|
51
|
+
VCR.configure do |c|
|
52
|
+
c.hook_into <hook_into>
|
55
53
|
c.cassette_library_dir = 'cassettes'
|
56
54
|
end
|
57
55
|
|
@@ -61,7 +59,7 @@ Feature: Net::HTTP
|
|
61
59
|
end
|
62
60
|
end
|
63
61
|
|
64
|
-
VCR.use_cassette('net_http'
|
62
|
+
VCR.use_cassette('net_http') do
|
65
63
|
puts perform_request.body
|
66
64
|
end
|
67
65
|
"""
|
@@ -73,21 +71,21 @@ Feature: Net::HTTP
|
|
73
71
|
Then the output should contain "VCR works with Net::HTTP gets!"
|
74
72
|
|
75
73
|
Examples:
|
76
|
-
|
|
74
|
+
| hook_into |
|
77
75
|
| :fakeweb |
|
78
76
|
| :webmock |
|
79
77
|
|
80
78
|
Scenario Outline: Use Net::ReadAdapter to read body in fragments
|
81
79
|
Given a file named "vcr_net_http.rb" with:
|
82
|
-
"""
|
80
|
+
"""ruby
|
83
81
|
require 'vcr_setup.rb'
|
84
82
|
|
85
|
-
VCR.
|
86
|
-
c.
|
83
|
+
VCR.configure do |c|
|
84
|
+
c.hook_into <hook_into>
|
87
85
|
c.cassette_library_dir = 'cassettes'
|
88
86
|
end
|
89
87
|
|
90
|
-
VCR.use_cassette('net_http'
|
88
|
+
VCR.use_cassette('net_http') do
|
91
89
|
body = ''
|
92
90
|
|
93
91
|
Net::HTTP.new('localhost', 7777).request_get('/') do |response|
|
@@ -105,22 +103,22 @@ Feature: Net::HTTP
|
|
105
103
|
Then the output should contain "VCR works with Net::HTTP gets!"
|
106
104
|
|
107
105
|
Examples:
|
108
|
-
|
|
106
|
+
| hook_into |
|
109
107
|
| :fakeweb |
|
110
108
|
| :webmock |
|
111
109
|
|
112
110
|
Scenario Outline: Use open-uri (which is built on top of Net::HTTP and uses a seldom-used Net::HTTP API)
|
113
111
|
Given a file named "vcr_net_http.rb" with:
|
114
|
-
"""
|
112
|
+
"""ruby
|
115
113
|
require 'open-uri'
|
116
114
|
require 'vcr_setup.rb'
|
117
115
|
|
118
|
-
VCR.
|
119
|
-
c.
|
116
|
+
VCR.configure do |c|
|
117
|
+
c.hook_into <hook_into>
|
120
118
|
c.cassette_library_dir = 'cassettes'
|
121
119
|
end
|
122
120
|
|
123
|
-
VCR.use_cassette('net_http'
|
121
|
+
VCR.use_cassette('net_http') do
|
124
122
|
puts open('http://localhost:7777/').read
|
125
123
|
end
|
126
124
|
"""
|
@@ -132,23 +130,23 @@ Feature: Net::HTTP
|
|
132
130
|
Then the output should contain "VCR works with Net::HTTP gets!"
|
133
131
|
|
134
132
|
Examples:
|
135
|
-
|
|
133
|
+
| hook_into |
|
136
134
|
| :fakeweb |
|
137
135
|
| :webmock |
|
138
136
|
|
139
137
|
Scenario Outline: Make an HTTPS request
|
140
138
|
Given a file named "vcr_https.rb" with:
|
141
|
-
"""
|
139
|
+
"""ruby
|
142
140
|
require 'vcr'
|
143
141
|
|
144
|
-
VCR.
|
145
|
-
c.
|
142
|
+
VCR.configure do |c|
|
143
|
+
c.hook_into <hook_into>
|
146
144
|
c.cassette_library_dir = 'cassettes'
|
147
145
|
end
|
148
146
|
|
149
147
|
uri = URI("https://raw.github.com/gist/fb555cb593f3349d53af/6921dd638337d3f6a51b0e02e7f30e3c414f70d6/vcr_gist")
|
150
148
|
|
151
|
-
VCR.use_cassette('https'
|
149
|
+
VCR.use_cassette('https') do
|
152
150
|
http = Net::HTTP.new(uri.host, uri.port)
|
153
151
|
http.use_ssl = true
|
154
152
|
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
@@ -166,6 +164,6 @@ Feature: Net::HTTP
|
|
166
164
|
Then the output should contain "HTTPS replaying works"
|
167
165
|
|
168
166
|
Examples:
|
169
|
-
|
|
167
|
+
| hook_into |
|
170
168
|
| :fakeweb |
|
171
169
|
| :webmock |
|