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.
Files changed (88) hide show
  1. data/.gitignore +1 -0
  2. data/.travis.yml +3 -0
  3. data/CHANGELOG.md +37 -2
  4. data/Gemfile +2 -2
  5. data/README.md +10 -1
  6. data/Rakefile +43 -7
  7. data/Upgrade.md +45 -0
  8. data/features/.nav +1 -0
  9. data/features/cassettes/automatic_re_recording.feature +19 -17
  10. data/features/cassettes/dynamic_erb.feature +32 -28
  11. data/features/cassettes/exclusive.feature +28 -24
  12. data/features/cassettes/format.feature +213 -31
  13. data/features/cassettes/update_content_length_header.feature +20 -18
  14. data/features/configuration/filter_sensitive_data.feature +4 -4
  15. data/features/configuration/hooks.feature +27 -23
  16. data/features/http_libraries/em_http_request.feature +79 -75
  17. data/features/record_modes/all.feature +14 -14
  18. data/features/record_modes/new_episodes.feature +15 -15
  19. data/features/record_modes/none.feature +15 -15
  20. data/features/record_modes/once.feature +15 -15
  21. data/features/request_matching/body.feature +25 -23
  22. data/features/request_matching/custom_matcher.feature +25 -23
  23. data/features/request_matching/headers.feature +32 -36
  24. data/features/request_matching/host.feature +27 -25
  25. data/features/request_matching/identical_request_sequence.feature +27 -25
  26. data/features/request_matching/method.feature +27 -25
  27. data/features/request_matching/path.feature +27 -25
  28. data/features/request_matching/playback_repeats.feature +27 -25
  29. data/features/request_matching/uri.feature +27 -25
  30. data/features/request_matching/uri_without_param.feature +28 -26
  31. data/features/step_definitions/cli_steps.rb +71 -17
  32. data/features/support/env.rb +3 -1
  33. data/features/support/http_lib_filters.rb +6 -3
  34. data/features/support/vcr_cucumber_helpers.rb +4 -2
  35. data/lib/vcr.rb +6 -2
  36. data/lib/vcr/cassette.rb +75 -51
  37. data/lib/vcr/cassette/migrator.rb +111 -0
  38. data/lib/vcr/cassette/serializers.rb +35 -0
  39. data/lib/vcr/cassette/serializers/json.rb +23 -0
  40. data/lib/vcr/cassette/serializers/psych.rb +24 -0
  41. data/lib/vcr/cassette/serializers/syck.rb +35 -0
  42. data/lib/vcr/cassette/serializers/yaml.rb +24 -0
  43. data/lib/vcr/configuration.rb +6 -1
  44. data/lib/vcr/errors.rb +1 -1
  45. data/lib/vcr/library_hooks/excon.rb +1 -7
  46. data/lib/vcr/library_hooks/typhoeus.rb +6 -22
  47. data/lib/vcr/library_hooks/webmock.rb +1 -1
  48. data/lib/vcr/middleware/faraday.rb +1 -1
  49. data/lib/vcr/request_matcher_registry.rb +43 -30
  50. data/lib/vcr/structs.rb +209 -0
  51. data/lib/vcr/tasks/vcr.rake +9 -0
  52. data/lib/vcr/version.rb +1 -1
  53. data/spec/fixtures/cassette_spec/1_x_cassette.yml +110 -0
  54. data/spec/fixtures/cassette_spec/example.yml +79 -78
  55. data/spec/fixtures/cassette_spec/with_localhost_requests.yml +79 -77
  56. data/spec/fixtures/fake_example.com_responses.yml +78 -76
  57. data/spec/fixtures/match_requests_on.yml +147 -145
  58. data/spec/monkey_patches.rb +5 -5
  59. data/spec/support/http_library_adapters.rb +48 -0
  60. data/spec/support/shared_example_groups/hook_into_http_library.rb +53 -20
  61. data/spec/support/sinatra_app.rb +12 -0
  62. data/spec/vcr/cassette/http_interaction_list_spec.rb +1 -1
  63. data/spec/vcr/cassette/migrator_spec.rb +183 -0
  64. data/spec/vcr/cassette/serializers_spec.rb +122 -0
  65. data/spec/vcr/cassette_spec.rb +147 -83
  66. data/spec/vcr/configuration_spec.rb +11 -1
  67. data/spec/vcr/library_hooks/typhoeus_spec.rb +3 -3
  68. data/spec/vcr/library_hooks/webmock_spec.rb +7 -1
  69. data/spec/vcr/request_ignorer_spec.rb +1 -1
  70. data/spec/vcr/request_matcher_registry_spec.rb +46 -4
  71. data/spec/vcr/structs_spec.rb +309 -0
  72. data/spec/vcr_spec.rb +7 -0
  73. data/vcr.gemspec +9 -12
  74. metadata +75 -61
  75. data/lib/vcr/structs/http_interaction.rb +0 -58
  76. data/lib/vcr/structs/normalizers/body.rb +0 -24
  77. data/lib/vcr/structs/normalizers/header.rb +0 -64
  78. data/lib/vcr/structs/normalizers/status_message.rb +0 -17
  79. data/lib/vcr/structs/normalizers/uri.rb +0 -34
  80. data/lib/vcr/structs/request.rb +0 -13
  81. data/lib/vcr/structs/response.rb +0 -13
  82. data/lib/vcr/structs/response_status.rb +0 -5
  83. data/lib/vcr/util/yaml.rb +0 -11
  84. data/spec/support/shared_example_groups/normalizers.rb +0 -94
  85. data/spec/vcr/structs/http_interaction_spec.rb +0 -89
  86. data/spec/vcr/structs/request_spec.rb +0 -39
  87. data/spec/vcr/structs/response_spec.rb +0 -44
  88. data/spec/vcr/structs/response_status_spec.rb +0 -9
@@ -1,4 +1,4 @@
1
- @exclude-jruby @exclude-rbx @exclude-travis-186
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
- - !ruby/struct:VCR::HTTPInteraction
64
- request: !ruby/struct:VCR::Request
65
- method: :get
62
+ ---
63
+ http_interactions:
64
+ - request:
65
+ method: get
66
66
  uri: http://localhost:7777/foo
67
- body:
68
- headers:
69
- response: !ruby/struct:VCR::Response
70
- status: !ruby/struct:VCR::ResponseStatus
67
+ body: ''
68
+ headers: {}
69
+ response:
70
+ status:
71
71
  code: 200
72
72
  message: OK
73
- headers:
74
- content-type:
73
+ headers:
74
+ Content-Type:
75
75
  - text/html;charset=utf-8
76
- content-length:
77
- - "9"
76
+ Content-Length:
77
+ - '9'
78
78
  body: Hello foo
79
- http_version: "1.1"
80
- - !ruby/struct:VCR::HTTPInteraction
81
- request: !ruby/struct:VCR::Request
82
- method: :get
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: !ruby/struct:VCR::Response
87
- status: !ruby/struct:VCR::ResponseStatus
84
+ body: ''
85
+ headers: {}
86
+ response:
87
+ status:
88
88
  code: 200
89
89
  message: OK
90
- headers:
91
- content-type:
90
+ headers:
91
+ Content-Type:
92
92
  - text/html;charset=utf-8
93
- content-length:
94
- - "9"
93
+ Content-Length:
94
+ - '9'
95
95
  body: Hello bar
96
- http_version: "1.1"
97
- - !ruby/struct:VCR::HTTPInteraction
98
- request: !ruby/struct:VCR::Request
99
- method: :get
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: !ruby/struct:VCR::Response
104
- status: !ruby/struct:VCR::ResponseStatus
101
+ body: ''
102
+ headers: {}
103
+ response:
104
+ status:
105
105
  code: 200
106
106
  message: OK
107
- headers:
108
- content-type:
107
+ headers:
108
+ Content-Type:
109
109
  - text/html;charset=utf-8
110
- content-length:
111
- - "10"
110
+ Content-Length:
111
+ - '10'
112
112
  body: Hello bazz
113
- http_version: "1.1"
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
- - !ruby/struct:VCR::HTTPInteraction
157
- request: !ruby/struct:VCR::Request
158
- method: :get
157
+ ---
158
+ http_interactions:
159
+ - request:
160
+ method: get
159
161
  uri: http://localhost:7777/foo
160
- body:
161
- headers:
162
- response: !ruby/struct:VCR::Response
163
- status: !ruby/struct:VCR::ResponseStatus
162
+ body: ''
163
+ headers: {}
164
+ response:
165
+ status:
164
166
  code: 200
165
167
  message: OK
166
- headers:
167
- content-type:
168
+ headers:
169
+ Content-Type:
168
170
  - text/html;charset=utf-8
169
- content-length:
170
- - "9"
171
+ Content-Length:
172
+ - '9'
171
173
  body: Hello foo
172
- http_version: "1.1"
173
- - !ruby/struct:VCR::HTTPInteraction
174
- request: !ruby/struct:VCR::Request
175
- method: :get
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: !ruby/struct:VCR::Response
180
- status: !ruby/struct:VCR::ResponseStatus
179
+ body: ''
180
+ headers: {}
181
+ response:
182
+ status:
181
183
  code: 200
182
184
  message: OK
183
- headers:
184
- content-type:
185
+ headers:
186
+ Content-Type:
185
187
  - text/html;charset=utf-8
186
- content-length:
187
- - "9"
188
+ Content-Length:
189
+ - '9'
188
190
  body: Hello bar
189
- http_version: "1.1"
190
- - !ruby/struct:VCR::HTTPInteraction
191
- request: !ruby/struct:VCR::Request
192
- method: :get
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: !ruby/struct:VCR::Response
197
- status: !ruby/struct:VCR::ResponseStatus
196
+ body: ''
197
+ headers: {}
198
+ response:
199
+ status:
198
200
  code: 200
199
201
  message: OK
200
- headers:
201
- content-type:
202
+ headers:
203
+ Content-Type:
202
204
  - text/html;charset=utf-8
203
- content-length:
204
- - "10"
205
+ Content-Length:
206
+ - '10'
205
207
  body: Hello bazz
206
- http_version: "1.1"
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
- - !ruby/struct:VCR::HTTPInteraction
31
- request: !ruby/struct:VCR::Request
32
- method: :get
29
+ ---
30
+ http_interactions:
31
+ - request:
32
+ method: get
33
33
  uri: http://localhost:7777/
34
- body:
35
- headers:
36
- response: !ruby/struct:VCR::Response
37
- status: !ruby/struct:VCR::ResponseStatus
34
+ body: ''
35
+ headers: {}
36
+ response:
37
+ status:
38
38
  code: 200
39
39
  message: OK
40
- headers:
41
- content-type:
42
- - text/html;charset=utf-8
43
- content-length:
44
- - "20"
40
+ headers:
41
+ Content-Length:
42
+ - '20'
45
43
  body: old response
46
- http_version: "1.1"
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
- - !ruby/struct:VCR::HTTPInteraction
30
- request: !ruby/struct:VCR::Request
31
- method: :get
32
- uri: http://example.com:80/foo
33
- body:
34
- headers:
35
- response: !ruby/struct:VCR::Response
36
- status: !ruby/struct:VCR::ResponseStatus
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
- content-type:
41
- - text/html;charset=utf-8
42
- content-length:
43
- - "20"
39
+ headers:
40
+ Content-Length:
41
+ - '20'
44
42
  body: example.com response
45
- http_version: "1.1"
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
- - !ruby/struct:VCR::HTTPInteraction
26
- request: !ruby/struct:VCR::Request
27
- method: :get
28
- uri: http://example.com:80/foo
29
- body:
30
- headers:
31
- response: !ruby/struct:VCR::Response
32
- status: !ruby/struct:VCR::ResponseStatus
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
- content-type:
37
- - text/html;charset=utf-8
38
- content-length:
39
- - "5"
35
+ headers:
36
+ Content-Length:
37
+ - '5'
40
38
  body: Hello
41
- http_version: "1.1"
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
- - !ruby/struct:VCR::HTTPInteraction
33
- request: !ruby/struct:VCR::Request
34
- method: :get
35
- uri: http://example.com:80/foo
36
- body:
37
- headers:
38
- response: !ruby/struct:VCR::Response
39
- status: !ruby/struct:VCR::ResponseStatus
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
- content-type:
44
- - text/html;charset=utf-8
45
- content-length:
46
- - "20"
42
+ headers:
43
+ Content-Length:
44
+ - '20'
47
45
  body: example.com response
48
- http_version: "1.1"
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
- - !ruby/struct:VCR::HTTPInteraction
10
- request: !ruby/struct:VCR::Request
11
- method: :post
12
- uri: http://example.net:80/some/long/path
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: !ruby/struct:VCR::Response
16
- status: !ruby/struct:VCR::ResponseStatus
14
+ headers: {}
15
+ response:
16
+ status:
17
17
  code: 200
18
18
  message: OK
19
- headers:
20
- content-length:
21
- - "14"
19
+ headers:
20
+ Content-Length:
21
+ - '14'
22
22
  body: body1 response
23
- http_version: "1.1"
24
- - !ruby/struct:VCR::HTTPInteraction
25
- request: !ruby/struct:VCR::Request
26
- method: :post
27
- uri: http://example.net:80/some/long/path
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: !ruby/struct:VCR::Response
31
- status: !ruby/struct:VCR::ResponseStatus
29
+ headers: {}
30
+ response:
31
+ status:
32
32
  code: 200
33
33
  message: OK
34
- headers:
35
- content-length:
36
- - "14"
34
+ headers:
35
+ Content-Length:
36
+ - '14'
37
37
  body: body2 response
38
- http_version: "1.1"
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
- - !ruby/struct:VCR::HTTPInteraction
20
- request: !ruby/struct:VCR::Request
21
- method: :get
18
+ ---
19
+ http_interactions:
20
+ - request:
21
+ method: get
22
22
  uri: http://foo.com:9000/foo
23
- body:
24
- headers:
25
- response: !ruby/struct:VCR::Response
26
- status: !ruby/struct:VCR::ResponseStatus
23
+ body: ''
24
+ headers: {}
25
+ response:
26
+ status:
27
27
  code: 200
28
28
  message: OK
29
- headers:
30
- content-length:
31
- - "18"
29
+ headers:
30
+ Content-Length:
31
+ - '18'
32
32
  body: port 9000 response
33
- http_version: "1.1"
34
- - !ruby/struct:VCR::HTTPInteraction
35
- request: !ruby/struct:VCR::Request
36
- method: :get
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: !ruby/struct:VCR::Response
41
- status: !ruby/struct:VCR::ResponseStatus
38
+ body: ''
39
+ headers: {}
40
+ response:
41
+ status:
42
42
  code: 200
43
43
  message: OK
44
- headers:
45
- content-length:
46
- - "18"
44
+ headers:
45
+ Content-Length:
46
+ - '18'
47
47
  body: port 8000 response
48
- http_version: "1.1"
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