vcr 2.0.0.beta1 → 2.0.0.beta2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/.travis.yml +3 -0
- data/CHANGELOG.md +37 -2
- data/Gemfile +2 -2
- data/README.md +10 -1
- data/Rakefile +43 -7
- data/Upgrade.md +45 -0
- data/features/.nav +1 -0
- data/features/cassettes/automatic_re_recording.feature +19 -17
- data/features/cassettes/dynamic_erb.feature +32 -28
- data/features/cassettes/exclusive.feature +28 -24
- data/features/cassettes/format.feature +213 -31
- data/features/cassettes/update_content_length_header.feature +20 -18
- data/features/configuration/filter_sensitive_data.feature +4 -4
- data/features/configuration/hooks.feature +27 -23
- data/features/http_libraries/em_http_request.feature +79 -75
- data/features/record_modes/all.feature +14 -14
- data/features/record_modes/new_episodes.feature +15 -15
- data/features/record_modes/none.feature +15 -15
- data/features/record_modes/once.feature +15 -15
- data/features/request_matching/body.feature +25 -23
- data/features/request_matching/custom_matcher.feature +25 -23
- data/features/request_matching/headers.feature +32 -36
- data/features/request_matching/host.feature +27 -25
- data/features/request_matching/identical_request_sequence.feature +27 -25
- data/features/request_matching/method.feature +27 -25
- data/features/request_matching/path.feature +27 -25
- data/features/request_matching/playback_repeats.feature +27 -25
- data/features/request_matching/uri.feature +27 -25
- data/features/request_matching/uri_without_param.feature +28 -26
- data/features/step_definitions/cli_steps.rb +71 -17
- data/features/support/env.rb +3 -1
- data/features/support/http_lib_filters.rb +6 -3
- data/features/support/vcr_cucumber_helpers.rb +4 -2
- data/lib/vcr.rb +6 -2
- data/lib/vcr/cassette.rb +75 -51
- data/lib/vcr/cassette/migrator.rb +111 -0
- data/lib/vcr/cassette/serializers.rb +35 -0
- data/lib/vcr/cassette/serializers/json.rb +23 -0
- data/lib/vcr/cassette/serializers/psych.rb +24 -0
- data/lib/vcr/cassette/serializers/syck.rb +35 -0
- data/lib/vcr/cassette/serializers/yaml.rb +24 -0
- data/lib/vcr/configuration.rb +6 -1
- data/lib/vcr/errors.rb +1 -1
- data/lib/vcr/library_hooks/excon.rb +1 -7
- data/lib/vcr/library_hooks/typhoeus.rb +6 -22
- data/lib/vcr/library_hooks/webmock.rb +1 -1
- data/lib/vcr/middleware/faraday.rb +1 -1
- data/lib/vcr/request_matcher_registry.rb +43 -30
- data/lib/vcr/structs.rb +209 -0
- data/lib/vcr/tasks/vcr.rake +9 -0
- data/lib/vcr/version.rb +1 -1
- data/spec/fixtures/cassette_spec/1_x_cassette.yml +110 -0
- data/spec/fixtures/cassette_spec/example.yml +79 -78
- data/spec/fixtures/cassette_spec/with_localhost_requests.yml +79 -77
- data/spec/fixtures/fake_example.com_responses.yml +78 -76
- data/spec/fixtures/match_requests_on.yml +147 -145
- data/spec/monkey_patches.rb +5 -5
- data/spec/support/http_library_adapters.rb +48 -0
- data/spec/support/shared_example_groups/hook_into_http_library.rb +53 -20
- data/spec/support/sinatra_app.rb +12 -0
- data/spec/vcr/cassette/http_interaction_list_spec.rb +1 -1
- data/spec/vcr/cassette/migrator_spec.rb +183 -0
- data/spec/vcr/cassette/serializers_spec.rb +122 -0
- data/spec/vcr/cassette_spec.rb +147 -83
- data/spec/vcr/configuration_spec.rb +11 -1
- data/spec/vcr/library_hooks/typhoeus_spec.rb +3 -3
- data/spec/vcr/library_hooks/webmock_spec.rb +7 -1
- data/spec/vcr/request_ignorer_spec.rb +1 -1
- data/spec/vcr/request_matcher_registry_spec.rb +46 -4
- data/spec/vcr/structs_spec.rb +309 -0
- data/spec/vcr_spec.rb +7 -0
- data/vcr.gemspec +9 -12
- metadata +75 -61
- data/lib/vcr/structs/http_interaction.rb +0 -58
- data/lib/vcr/structs/normalizers/body.rb +0 -24
- data/lib/vcr/structs/normalizers/header.rb +0 -64
- data/lib/vcr/structs/normalizers/status_message.rb +0 -17
- data/lib/vcr/structs/normalizers/uri.rb +0 -34
- data/lib/vcr/structs/request.rb +0 -13
- data/lib/vcr/structs/response.rb +0 -13
- data/lib/vcr/structs/response_status.rb +0 -5
- data/lib/vcr/util/yaml.rb +0 -11
- data/spec/support/shared_example_groups/normalizers.rb +0 -94
- data/spec/vcr/structs/http_interaction_spec.rb +0 -89
- data/spec/vcr/structs/request_spec.rb +0 -39
- data/spec/vcr/structs/response_spec.rb +0 -44
- data/spec/vcr/structs/response_status_spec.rb +0 -9
@@ -1,4 +1,4 @@
|
|
1
|
-
@exclude-jruby @exclude-rbx
|
1
|
+
@exclude-jruby @exclude-rbx
|
2
2
|
Feature: EM HTTP Request
|
3
3
|
|
4
4
|
EM HTTP Request allows multiple simultaneous asynchronous requests.
|
@@ -59,58 +59,60 @@ Feature: EM HTTP Request
|
|
59
59
|
"""
|
60
60
|
And the file "cassettes/em_http.yml" should contain YAML like:
|
61
61
|
"""
|
62
|
-
---
|
63
|
-
|
64
|
-
|
65
|
-
method:
|
62
|
+
---
|
63
|
+
http_interactions:
|
64
|
+
- request:
|
65
|
+
method: get
|
66
66
|
uri: http://localhost:7777/foo
|
67
|
-
body:
|
68
|
-
headers:
|
69
|
-
response:
|
70
|
-
status:
|
67
|
+
body: ''
|
68
|
+
headers: {}
|
69
|
+
response:
|
70
|
+
status:
|
71
71
|
code: 200
|
72
72
|
message: OK
|
73
|
-
headers:
|
74
|
-
|
73
|
+
headers:
|
74
|
+
Content-Type:
|
75
75
|
- text/html;charset=utf-8
|
76
|
-
|
77
|
-
-
|
76
|
+
Content-Length:
|
77
|
+
- '9'
|
78
78
|
body: Hello foo
|
79
|
-
http_version:
|
80
|
-
|
81
|
-
|
82
|
-
method:
|
79
|
+
http_version:
|
80
|
+
recorded_at: Tue, 01 Nov 2011 04:58:44 GMT
|
81
|
+
- request:
|
82
|
+
method: get
|
83
83
|
uri: http://localhost:7777/bar
|
84
|
-
body:
|
85
|
-
headers:
|
86
|
-
response:
|
87
|
-
status:
|
84
|
+
body: ''
|
85
|
+
headers: {}
|
86
|
+
response:
|
87
|
+
status:
|
88
88
|
code: 200
|
89
89
|
message: OK
|
90
|
-
headers:
|
91
|
-
|
90
|
+
headers:
|
91
|
+
Content-Type:
|
92
92
|
- text/html;charset=utf-8
|
93
|
-
|
94
|
-
-
|
93
|
+
Content-Length:
|
94
|
+
- '9'
|
95
95
|
body: Hello bar
|
96
|
-
http_version:
|
97
|
-
|
98
|
-
|
99
|
-
method:
|
96
|
+
http_version:
|
97
|
+
recorded_at: Tue, 01 Nov 2011 04:58:44 GMT
|
98
|
+
- request:
|
99
|
+
method: get
|
100
100
|
uri: http://localhost:7777/bazz
|
101
|
-
body:
|
102
|
-
headers:
|
103
|
-
response:
|
104
|
-
status:
|
101
|
+
body: ''
|
102
|
+
headers: {}
|
103
|
+
response:
|
104
|
+
status:
|
105
105
|
code: 200
|
106
106
|
message: OK
|
107
|
-
headers:
|
108
|
-
|
107
|
+
headers:
|
108
|
+
Content-Type:
|
109
109
|
- text/html;charset=utf-8
|
110
|
-
|
111
|
-
-
|
110
|
+
Content-Length:
|
111
|
+
- '10'
|
112
112
|
body: Hello bazz
|
113
|
-
http_version:
|
113
|
+
http_version:
|
114
|
+
recorded_at: Tue, 01 Nov 2011 04:58:44 GMT
|
115
|
+
recorded_with: VCR 2.0.0
|
114
116
|
"""
|
115
117
|
|
116
118
|
When I run `ruby make_requests.rb Goodbye`
|
@@ -152,58 +154,60 @@ Feature: EM HTTP Request
|
|
152
154
|
"""
|
153
155
|
And the file "cassettes/em_http.yml" should contain YAML like:
|
154
156
|
"""
|
155
|
-
---
|
156
|
-
|
157
|
-
|
158
|
-
method:
|
157
|
+
---
|
158
|
+
http_interactions:
|
159
|
+
- request:
|
160
|
+
method: get
|
159
161
|
uri: http://localhost:7777/foo
|
160
|
-
body:
|
161
|
-
headers:
|
162
|
-
response:
|
163
|
-
status:
|
162
|
+
body: ''
|
163
|
+
headers: {}
|
164
|
+
response:
|
165
|
+
status:
|
164
166
|
code: 200
|
165
167
|
message: OK
|
166
|
-
headers:
|
167
|
-
|
168
|
+
headers:
|
169
|
+
Content-Type:
|
168
170
|
- text/html;charset=utf-8
|
169
|
-
|
170
|
-
-
|
171
|
+
Content-Length:
|
172
|
+
- '9'
|
171
173
|
body: Hello foo
|
172
|
-
http_version:
|
173
|
-
|
174
|
-
|
175
|
-
method:
|
174
|
+
http_version:
|
175
|
+
recorded_at: Tue, 01 Nov 2011 04:58:44 GMT
|
176
|
+
- request:
|
177
|
+
method: get
|
176
178
|
uri: http://localhost:7777/bar
|
177
|
-
body:
|
178
|
-
headers:
|
179
|
-
response:
|
180
|
-
status:
|
179
|
+
body: ''
|
180
|
+
headers: {}
|
181
|
+
response:
|
182
|
+
status:
|
181
183
|
code: 200
|
182
184
|
message: OK
|
183
|
-
headers:
|
184
|
-
|
185
|
+
headers:
|
186
|
+
Content-Type:
|
185
187
|
- text/html;charset=utf-8
|
186
|
-
|
187
|
-
-
|
188
|
+
Content-Length:
|
189
|
+
- '9'
|
188
190
|
body: Hello bar
|
189
|
-
http_version:
|
190
|
-
|
191
|
-
|
192
|
-
method:
|
191
|
+
http_version:
|
192
|
+
recorded_at: Tue, 01 Nov 2011 04:58:44 GMT
|
193
|
+
- request:
|
194
|
+
method: get
|
193
195
|
uri: http://localhost:7777/bazz
|
194
|
-
body:
|
195
|
-
headers:
|
196
|
-
response:
|
197
|
-
status:
|
196
|
+
body: ''
|
197
|
+
headers: {}
|
198
|
+
response:
|
199
|
+
status:
|
198
200
|
code: 200
|
199
201
|
message: OK
|
200
|
-
headers:
|
201
|
-
|
202
|
+
headers:
|
203
|
+
Content-Type:
|
202
204
|
- text/html;charset=utf-8
|
203
|
-
|
204
|
-
-
|
205
|
+
Content-Length:
|
206
|
+
- '10'
|
205
207
|
body: Hello bazz
|
206
|
-
http_version:
|
208
|
+
http_version:
|
209
|
+
recorded_at: Tue, 01 Nov 2011 04:58:44 GMT
|
210
|
+
recorded_with: VCR 2.0.0
|
207
211
|
"""
|
208
212
|
|
209
213
|
When I run `ruby make_requests.rb Goodbye`
|
@@ -26,24 +26,24 @@ Feature: :all
|
|
26
26
|
"""
|
27
27
|
And a previously recorded cassette file "cassettes/example.yml" with:
|
28
28
|
"""
|
29
|
-
---
|
30
|
-
|
31
|
-
|
32
|
-
method:
|
29
|
+
---
|
30
|
+
http_interactions:
|
31
|
+
- request:
|
32
|
+
method: get
|
33
33
|
uri: http://localhost:7777/
|
34
|
-
body:
|
35
|
-
headers:
|
36
|
-
response:
|
37
|
-
status:
|
34
|
+
body: ''
|
35
|
+
headers: {}
|
36
|
+
response:
|
37
|
+
status:
|
38
38
|
code: 200
|
39
39
|
message: OK
|
40
|
-
headers:
|
41
|
-
|
42
|
-
-
|
43
|
-
content-length:
|
44
|
-
- "20"
|
40
|
+
headers:
|
41
|
+
Content-Length:
|
42
|
+
- '20'
|
45
43
|
body: old response
|
46
|
-
http_version:
|
44
|
+
http_version: '1.1'
|
45
|
+
recorded_at: Tue, 01 Nov 2011 04:58:44 GMT
|
46
|
+
recorded_with: VCR 2.0.0
|
47
47
|
"""
|
48
48
|
|
49
49
|
Scenario: Re-record previously recorded response
|
@@ -25,24 +25,24 @@ Feature: :new_episodes
|
|
25
25
|
"""
|
26
26
|
And a previously recorded cassette file "cassettes/example.yml" with:
|
27
27
|
"""
|
28
|
-
---
|
29
|
-
|
30
|
-
|
31
|
-
method:
|
32
|
-
uri: http://example.com
|
33
|
-
body:
|
34
|
-
headers:
|
35
|
-
response:
|
36
|
-
status:
|
28
|
+
---
|
29
|
+
http_interactions:
|
30
|
+
- request:
|
31
|
+
method: get
|
32
|
+
uri: http://example.com/foo
|
33
|
+
body: ''
|
34
|
+
headers: {}
|
35
|
+
response:
|
36
|
+
status:
|
37
37
|
code: 200
|
38
38
|
message: OK
|
39
|
-
headers:
|
40
|
-
|
41
|
-
-
|
42
|
-
content-length:
|
43
|
-
- "20"
|
39
|
+
headers:
|
40
|
+
Content-Length:
|
41
|
+
- '20'
|
44
42
|
body: example.com response
|
45
|
-
http_version:
|
43
|
+
http_version: '1.1'
|
44
|
+
recorded_at: Tue, 01 Nov 2011 04:58:44 GMT
|
45
|
+
recorded_with: VCR 2.0.0
|
46
46
|
"""
|
47
47
|
|
48
48
|
Scenario: Previously recorded responses are replayed
|
@@ -21,24 +21,24 @@ Feature: :none
|
|
21
21
|
"""
|
22
22
|
And a previously recorded cassette file "cassettes/example.yml" with:
|
23
23
|
"""
|
24
|
-
---
|
25
|
-
|
26
|
-
|
27
|
-
method:
|
28
|
-
uri: http://example.com
|
29
|
-
body:
|
30
|
-
headers:
|
31
|
-
response:
|
32
|
-
status:
|
24
|
+
---
|
25
|
+
http_interactions:
|
26
|
+
- request:
|
27
|
+
method: get
|
28
|
+
uri: http://example.com/foo
|
29
|
+
body: ''
|
30
|
+
headers: {}
|
31
|
+
response:
|
32
|
+
status:
|
33
33
|
code: 200
|
34
34
|
message: OK
|
35
|
-
headers:
|
36
|
-
|
37
|
-
-
|
38
|
-
content-length:
|
39
|
-
- "5"
|
35
|
+
headers:
|
36
|
+
Content-Length:
|
37
|
+
- '5'
|
40
38
|
body: Hello
|
41
|
-
http_version:
|
39
|
+
http_version: '1.1'
|
40
|
+
recorded_at: Tue, 01 Nov 2011 04:58:44 GMT
|
41
|
+
recorded_with: VCR 2.0.0
|
42
42
|
"""
|
43
43
|
|
44
44
|
Scenario: Previously recorded responses are replayed
|
@@ -28,24 +28,24 @@ Feature: :once
|
|
28
28
|
"""
|
29
29
|
And a previously recorded cassette file "cassettes/example.yml" with:
|
30
30
|
"""
|
31
|
-
---
|
32
|
-
|
33
|
-
|
34
|
-
method:
|
35
|
-
uri: http://example.com
|
36
|
-
body:
|
37
|
-
headers:
|
38
|
-
response:
|
39
|
-
status:
|
31
|
+
---
|
32
|
+
http_interactions:
|
33
|
+
- request:
|
34
|
+
method: get
|
35
|
+
uri: http://example.com/foo
|
36
|
+
body: ''
|
37
|
+
headers: {}
|
38
|
+
response:
|
39
|
+
status:
|
40
40
|
code: 200
|
41
41
|
message: OK
|
42
|
-
headers:
|
43
|
-
|
44
|
-
-
|
45
|
-
content-length:
|
46
|
-
- "20"
|
42
|
+
headers:
|
43
|
+
Content-Length:
|
44
|
+
- '20'
|
47
45
|
body: example.com response
|
48
|
-
http_version:
|
46
|
+
http_version: '1.1'
|
47
|
+
recorded_at: Tue, 01 Nov 2011 04:58:44 GMT
|
48
|
+
recorded_with: VCR 2.0.0
|
49
49
|
"""
|
50
50
|
|
51
51
|
Scenario: Previously recorded responses are replayed
|
@@ -5,37 +5,39 @@ Feature: Matching on Body
|
|
5
5
|
Background:
|
6
6
|
Given a previously recorded cassette file "cassettes/example.yml" with:
|
7
7
|
"""
|
8
|
-
---
|
9
|
-
|
10
|
-
|
11
|
-
method:
|
12
|
-
uri: http://example.net
|
8
|
+
---
|
9
|
+
http_interactions:
|
10
|
+
- request:
|
11
|
+
method: post
|
12
|
+
uri: http://example.net/some/long/path
|
13
13
|
body: body1
|
14
|
-
headers:
|
15
|
-
response:
|
16
|
-
status:
|
14
|
+
headers: {}
|
15
|
+
response:
|
16
|
+
status:
|
17
17
|
code: 200
|
18
18
|
message: OK
|
19
|
-
headers:
|
20
|
-
|
21
|
-
-
|
19
|
+
headers:
|
20
|
+
Content-Length:
|
21
|
+
- '14'
|
22
22
|
body: body1 response
|
23
|
-
http_version:
|
24
|
-
|
25
|
-
|
26
|
-
method:
|
27
|
-
uri: http://example.net
|
23
|
+
http_version: '1.1'
|
24
|
+
recorded_at: Tue, 01 Nov 2011 04:58:44 GMT
|
25
|
+
- request:
|
26
|
+
method: post
|
27
|
+
uri: http://example.net/some/long/path
|
28
28
|
body: body2
|
29
|
-
headers:
|
30
|
-
response:
|
31
|
-
status:
|
29
|
+
headers: {}
|
30
|
+
response:
|
31
|
+
status:
|
32
32
|
code: 200
|
33
33
|
message: OK
|
34
|
-
headers:
|
35
|
-
|
36
|
-
-
|
34
|
+
headers:
|
35
|
+
Content-Length:
|
36
|
+
- '14'
|
37
37
|
body: body2 response
|
38
|
-
http_version:
|
38
|
+
http_version: '1.1'
|
39
|
+
recorded_at: Tue, 01 Nov 2011 04:58:44 GMT
|
40
|
+
recorded_with: VCR 2.0.0
|
39
41
|
"""
|
40
42
|
|
41
43
|
Scenario Outline: Replay interaction that matches the body
|
@@ -15,37 +15,39 @@ Feature: Register and use a custom matcher
|
|
15
15
|
Background:
|
16
16
|
Given a previously recorded cassette file "cassettes/example.yml" with:
|
17
17
|
"""
|
18
|
-
---
|
19
|
-
|
20
|
-
|
21
|
-
method:
|
18
|
+
---
|
19
|
+
http_interactions:
|
20
|
+
- request:
|
21
|
+
method: get
|
22
22
|
uri: http://foo.com:9000/foo
|
23
|
-
body:
|
24
|
-
headers:
|
25
|
-
response:
|
26
|
-
status:
|
23
|
+
body: ''
|
24
|
+
headers: {}
|
25
|
+
response:
|
26
|
+
status:
|
27
27
|
code: 200
|
28
28
|
message: OK
|
29
|
-
headers:
|
30
|
-
|
31
|
-
-
|
29
|
+
headers:
|
30
|
+
Content-Length:
|
31
|
+
- '18'
|
32
32
|
body: port 9000 response
|
33
|
-
http_version:
|
34
|
-
|
35
|
-
|
36
|
-
method:
|
33
|
+
http_version: '1.1'
|
34
|
+
recorded_at: Tue, 01 Nov 2011 04:58:44 GMT
|
35
|
+
- request:
|
36
|
+
method: get
|
37
37
|
uri: http://foo.com:8000/foo
|
38
|
-
body:
|
39
|
-
headers:
|
40
|
-
response:
|
41
|
-
status:
|
38
|
+
body: ''
|
39
|
+
headers: {}
|
40
|
+
response:
|
41
|
+
status:
|
42
42
|
code: 200
|
43
43
|
message: OK
|
44
|
-
headers:
|
45
|
-
|
46
|
-
-
|
44
|
+
headers:
|
45
|
+
Content-Length:
|
46
|
+
- '18'
|
47
47
|
body: port 8000 response
|
48
|
-
http_version:
|
48
|
+
http_version: '1.1'
|
49
|
+
recorded_at: Tue, 01 Nov 2011 04:58:44 GMT
|
50
|
+
recorded_with: VCR 2.0.0
|
49
51
|
"""
|
50
52
|
|
51
53
|
Scenario Outline: Use a callable as a custom request matcher
|