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
@@ -2,47 +2,47 @@ Feature: Matching on Headers
|
|
2
2
|
|
3
3
|
Use the `:headers` request matcher to match requests on the request headers.
|
4
4
|
|
5
|
-
|
5
|
+
Scenario Outline: Replay interaction that matches the headers
|
6
6
|
Given a previously recorded cassette file "cassettes/example.yml" with:
|
7
7
|
"""
|
8
|
-
---
|
9
|
-
|
10
|
-
|
11
|
-
method:
|
12
|
-
uri: http://example.net
|
13
|
-
body:
|
14
|
-
headers:
|
15
|
-
|
16
|
-
-
|
17
|
-
response:
|
18
|
-
status:
|
8
|
+
---
|
9
|
+
http_interactions:
|
10
|
+
- request:
|
11
|
+
method: post
|
12
|
+
uri: http://example.net/some/long/path
|
13
|
+
body: ''
|
14
|
+
headers:
|
15
|
+
X-User-Id:
|
16
|
+
- '1'
|
17
|
+
response:
|
18
|
+
status:
|
19
19
|
code: 200
|
20
20
|
message: OK
|
21
|
-
headers:
|
22
|
-
|
23
|
-
-
|
21
|
+
headers:
|
22
|
+
Content-Length:
|
23
|
+
- '15'
|
24
24
|
body: user 1 response
|
25
|
-
http_version:
|
26
|
-
|
27
|
-
|
28
|
-
method:
|
29
|
-
uri: http://example.net
|
30
|
-
body:
|
31
|
-
headers:
|
32
|
-
|
33
|
-
-
|
34
|
-
response:
|
35
|
-
status:
|
25
|
+
http_version: '1.1'
|
26
|
+
recorded_at: Tue, 01 Nov 2011 04:58:44 GMT
|
27
|
+
- request:
|
28
|
+
method: post
|
29
|
+
uri: http://example.net/some/long/path
|
30
|
+
body: ''
|
31
|
+
headers:
|
32
|
+
X-User-Id:
|
33
|
+
- '2'
|
34
|
+
response:
|
35
|
+
status:
|
36
36
|
code: 200
|
37
37
|
message: OK
|
38
|
-
headers:
|
39
|
-
|
40
|
-
-
|
38
|
+
headers:
|
39
|
+
Content-Length:
|
40
|
+
- '15'
|
41
41
|
body: user 2 response
|
42
|
-
http_version:
|
42
|
+
http_version: '1.1'
|
43
|
+
recorded_at: Tue, 01 Nov 2011 04:58:44 GMT
|
44
|
+
recorded_with: VCR 2.0.0
|
43
45
|
"""
|
44
|
-
|
45
|
-
Scenario Outline: Replay interaction that matches the headers
|
46
46
|
And a file named "header_matching.rb" with:
|
47
47
|
"""ruby
|
48
48
|
include_http_adapter_for("<http_lib>")
|
@@ -71,14 +71,10 @@ Feature: Matching on Headers
|
|
71
71
|
|
72
72
|
Examples:
|
73
73
|
| configuration | http_lib |
|
74
|
-
| c.hook_into :fakeweb | net/http |
|
75
|
-
| c.hook_into :webmock | net/http |
|
76
74
|
| c.hook_into :webmock | httpclient |
|
77
75
|
| c.hook_into :webmock | curb |
|
78
76
|
| c.hook_into :webmock | patron |
|
79
77
|
| c.hook_into :webmock | em-http-request |
|
80
|
-
| c.hook_into :webmock | typhoeus |
|
81
|
-
| c.hook_into :typhoeus | typhoeus |
|
82
78
|
| c.hook_into :excon | excon |
|
83
79
|
| | faraday (w/ net_http) |
|
84
80
|
| | faraday (w/ typhoeus) |
|
@@ -9,37 +9,39 @@ Feature: Matching on Host
|
|
9
9
|
Background:
|
10
10
|
Given a previously recorded cassette file "cassettes/example.yml" with:
|
11
11
|
"""
|
12
|
-
---
|
13
|
-
|
14
|
-
|
15
|
-
method:
|
16
|
-
uri: http://host1.com
|
17
|
-
body:
|
18
|
-
headers:
|
19
|
-
response:
|
20
|
-
status:
|
12
|
+
---
|
13
|
+
http_interactions:
|
14
|
+
- request:
|
15
|
+
method: post
|
16
|
+
uri: http://host1.com/some/long/path
|
17
|
+
body: ''
|
18
|
+
headers: {}
|
19
|
+
response:
|
20
|
+
status:
|
21
21
|
code: 200
|
22
22
|
message: OK
|
23
|
-
headers:
|
24
|
-
|
25
|
-
-
|
23
|
+
headers:
|
24
|
+
Content-Length:
|
25
|
+
- '14'
|
26
26
|
body: host1 response
|
27
|
-
http_version:
|
28
|
-
|
29
|
-
|
30
|
-
method:
|
31
|
-
uri: http://host2.com
|
32
|
-
body:
|
33
|
-
headers:
|
34
|
-
response:
|
35
|
-
status:
|
27
|
+
http_version: '1.1'
|
28
|
+
recorded_at: Tue, 01 Nov 2011 04:58:44 GMT
|
29
|
+
- request:
|
30
|
+
method: post
|
31
|
+
uri: http://host2.com/some/other/long/path
|
32
|
+
body: ''
|
33
|
+
headers: {}
|
34
|
+
response:
|
35
|
+
status:
|
36
36
|
code: 200
|
37
37
|
message: OK
|
38
|
-
headers:
|
39
|
-
|
40
|
-
-
|
38
|
+
headers:
|
39
|
+
Content-Length:
|
40
|
+
- '16'
|
41
41
|
body: host2 response
|
42
|
-
http_version:
|
42
|
+
http_version: '1.1'
|
43
|
+
recorded_at: Tue, 01 Nov 2011 04:58:44 GMT
|
44
|
+
recorded_with: VCR 2.0.0
|
43
45
|
"""
|
44
46
|
|
45
47
|
Scenario Outline: Replay interaction that matches the host
|
@@ -8,37 +8,39 @@ Feature: Identical requests are replayed in sequence
|
|
8
8
|
Scenario Outline: identical requests are replayed in sequence
|
9
9
|
Given a previously recorded cassette file "cassettes/example.yml" with:
|
10
10
|
"""
|
11
|
-
---
|
12
|
-
|
13
|
-
|
14
|
-
method:
|
15
|
-
uri: http://example.com
|
16
|
-
body:
|
17
|
-
headers:
|
18
|
-
response:
|
19
|
-
status:
|
11
|
+
---
|
12
|
+
http_interactions:
|
13
|
+
- request:
|
14
|
+
method: get
|
15
|
+
uri: http://example.com/foo
|
16
|
+
body: ''
|
17
|
+
headers: {}
|
18
|
+
response:
|
19
|
+
status:
|
20
20
|
code: 200
|
21
21
|
message: OK
|
22
|
-
headers:
|
23
|
-
|
24
|
-
-
|
22
|
+
headers:
|
23
|
+
Content-Length:
|
24
|
+
- '10'
|
25
25
|
body: Response 1
|
26
|
-
http_version:
|
27
|
-
|
28
|
-
|
29
|
-
method:
|
30
|
-
uri: http://example.com
|
31
|
-
body:
|
32
|
-
headers:
|
33
|
-
response:
|
34
|
-
status:
|
26
|
+
http_version: '1.1'
|
27
|
+
recorded_at: Tue, 01 Nov 2011 04:58:44 GMT
|
28
|
+
- request:
|
29
|
+
method: get
|
30
|
+
uri: http://example.com/foo
|
31
|
+
body: ''
|
32
|
+
headers: {}
|
33
|
+
response:
|
34
|
+
status:
|
35
35
|
code: 200
|
36
36
|
message: OK
|
37
|
-
headers:
|
38
|
-
|
39
|
-
-
|
37
|
+
headers:
|
38
|
+
Content-Length:
|
39
|
+
- '10'
|
40
40
|
body: Response 2
|
41
|
-
http_version:
|
41
|
+
http_version: '1.1'
|
42
|
+
recorded_at: Tue, 01 Nov 2011 04:58:44 GMT
|
43
|
+
recorded_with: VCR 2.0.0
|
42
44
|
"""
|
43
45
|
And a file named "rotate_responses.rb" with:
|
44
46
|
"""ruby
|
@@ -10,37 +10,39 @@ Feature: Matching on Method
|
|
10
10
|
Background:
|
11
11
|
Given a previously recorded cassette file "cassettes/example.yml" with:
|
12
12
|
"""
|
13
|
-
---
|
14
|
-
|
15
|
-
|
16
|
-
method:
|
17
|
-
uri: http://post-request.com
|
18
|
-
body:
|
19
|
-
headers:
|
20
|
-
response:
|
21
|
-
status:
|
13
|
+
---
|
14
|
+
http_interactions:
|
15
|
+
- request:
|
16
|
+
method: post
|
17
|
+
uri: http://post-request.com/
|
18
|
+
body: ''
|
19
|
+
headers: {}
|
20
|
+
response:
|
21
|
+
status:
|
22
22
|
code: 200
|
23
23
|
message: OK
|
24
|
-
headers:
|
25
|
-
|
26
|
-
-
|
24
|
+
headers:
|
25
|
+
Content-Length:
|
26
|
+
- '13'
|
27
27
|
body: post response
|
28
|
-
http_version:
|
29
|
-
|
30
|
-
|
31
|
-
method:
|
32
|
-
uri: http://get-request.com
|
33
|
-
body:
|
34
|
-
headers:
|
35
|
-
response:
|
36
|
-
status:
|
28
|
+
http_version: '1.1'
|
29
|
+
recorded_at: Tue, 01 Nov 2011 04:58:44 GMT
|
30
|
+
- request:
|
31
|
+
method: get
|
32
|
+
uri: http://get-request.com/
|
33
|
+
body: ''
|
34
|
+
headers: {}
|
35
|
+
response:
|
36
|
+
status:
|
37
37
|
code: 200
|
38
38
|
message: OK
|
39
|
-
headers:
|
40
|
-
|
41
|
-
-
|
39
|
+
headers:
|
40
|
+
Content-Length:
|
41
|
+
- '12'
|
42
42
|
body: get response
|
43
|
-
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
|
44
46
|
"""
|
45
47
|
|
46
48
|
Scenario Outline: Replay interaction that matches the HTTP method
|
@@ -10,37 +10,39 @@ Feature: Matching on Path
|
|
10
10
|
Background:
|
11
11
|
Given a previously recorded cassette file "cassettes/example.yml" with:
|
12
12
|
"""
|
13
|
-
---
|
14
|
-
|
15
|
-
|
16
|
-
method:
|
17
|
-
uri: http://host1.com
|
18
|
-
body:
|
19
|
-
headers:
|
20
|
-
response:
|
21
|
-
status:
|
13
|
+
---
|
14
|
+
http_interactions:
|
15
|
+
- request:
|
16
|
+
method: post
|
17
|
+
uri: http://host1.com/about?date=2011-09-01
|
18
|
+
body: ''
|
19
|
+
headers: {}
|
20
|
+
response:
|
21
|
+
status:
|
22
22
|
code: 200
|
23
23
|
message: OK
|
24
|
-
headers:
|
25
|
-
|
26
|
-
-
|
24
|
+
headers:
|
25
|
+
Content-Length:
|
26
|
+
- '14'
|
27
27
|
body: about response
|
28
|
-
http_version:
|
29
|
-
|
30
|
-
|
31
|
-
method:
|
32
|
-
uri: http://host2.com
|
33
|
-
body:
|
34
|
-
headers:
|
35
|
-
response:
|
36
|
-
status:
|
28
|
+
http_version: '1.1'
|
29
|
+
recorded_at: Tue, 01 Nov 2011 04:58:44 GMT
|
30
|
+
- request:
|
31
|
+
method: post
|
32
|
+
uri: http://host2.com/home?date=2011-09-01
|
33
|
+
body: ''
|
34
|
+
headers: {}
|
35
|
+
response:
|
36
|
+
status:
|
37
37
|
code: 200
|
38
38
|
message: OK
|
39
|
-
headers:
|
40
|
-
|
41
|
-
-
|
39
|
+
headers:
|
40
|
+
Content-Length:
|
41
|
+
- '15'
|
42
42
|
body: home response
|
43
|
-
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
|
44
46
|
"""
|
45
47
|
|
46
48
|
Scenario Outline: Replay interaction that matches the path
|
@@ -15,37 +15,39 @@ Feature: Playback repeats
|
|
15
15
|
Scenario: Responses do not repeat by default
|
16
16
|
Given a previously recorded cassette file "cassettes/example.yml" with:
|
17
17
|
"""
|
18
|
-
---
|
19
|
-
|
20
|
-
|
21
|
-
method:
|
22
|
-
uri: http://example.com
|
23
|
-
body:
|
24
|
-
headers:
|
25
|
-
response:
|
26
|
-
status:
|
18
|
+
---
|
19
|
+
http_interactions:
|
20
|
+
- request:
|
21
|
+
method: get
|
22
|
+
uri: http://example.com/foo
|
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
|
+
- '10'
|
32
32
|
body: Response 1
|
33
|
-
http_version:
|
34
|
-
|
35
|
-
|
36
|
-
method:
|
37
|
-
uri: http://example.com
|
38
|
-
body:
|
39
|
-
headers:
|
40
|
-
response:
|
41
|
-
status:
|
33
|
+
http_version: '1.1'
|
34
|
+
recorded_at: Tue, 01 Nov 2011 04:58:44 GMT
|
35
|
+
- request:
|
36
|
+
method: get
|
37
|
+
uri: http://example.com/foo
|
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
|
+
- '10'
|
47
47
|
body: Response 2
|
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
|
And a file named "playback_repeats.rb" with:
|
51
53
|
"""ruby
|
@@ -8,37 +8,39 @@ Feature: Matching on URI
|
|
8
8
|
Background:
|
9
9
|
Given a previously recorded cassette file "cassettes/example.yml" with:
|
10
10
|
"""
|
11
|
-
---
|
12
|
-
|
13
|
-
|
14
|
-
method:
|
15
|
-
uri: http://example.com
|
16
|
-
body:
|
17
|
-
headers:
|
18
|
-
response:
|
19
|
-
status:
|
11
|
+
---
|
12
|
+
http_interactions:
|
13
|
+
- request:
|
14
|
+
method: post
|
15
|
+
uri: http://example.com/foo
|
16
|
+
body: ''
|
17
|
+
headers: {}
|
18
|
+
response:
|
19
|
+
status:
|
20
20
|
code: 200
|
21
21
|
message: OK
|
22
|
-
headers:
|
23
|
-
|
24
|
-
-
|
22
|
+
headers:
|
23
|
+
Content-Length:
|
24
|
+
- '12'
|
25
25
|
body: foo response
|
26
|
-
http_version:
|
27
|
-
|
28
|
-
|
29
|
-
method:
|
30
|
-
uri: http://example.com
|
31
|
-
body:
|
32
|
-
headers:
|
33
|
-
response:
|
34
|
-
status:
|
26
|
+
http_version: '1.1'
|
27
|
+
recorded_at: Tue, 01 Nov 2011 04:58:44 GMT
|
28
|
+
- request:
|
29
|
+
method: post
|
30
|
+
uri: http://example.com/bar
|
31
|
+
body: ''
|
32
|
+
headers: {}
|
33
|
+
response:
|
34
|
+
status:
|
35
35
|
code: 200
|
36
36
|
message: OK
|
37
|
-
headers:
|
38
|
-
|
39
|
-
-
|
37
|
+
headers:
|
38
|
+
Content-Length:
|
39
|
+
- '12'
|
40
40
|
body: bar response
|
41
|
-
http_version:
|
41
|
+
http_version: '1.1'
|
42
|
+
recorded_at: Tue, 01 Nov 2011 04:58:44 GMT
|
43
|
+
recorded_with: VCR 2.0.0
|
42
44
|
"""
|
43
45
|
|
44
46
|
Scenario Outline: Replay interaction that matches the request URI
|