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
@@ -1,14 +0,0 @@
|
|
1
|
-
--- !ruby/object:Net::HTTP
|
2
|
-
address: example.com
|
3
|
-
close_on_empty_response: false
|
4
|
-
curr_http_version: "1.1"
|
5
|
-
debug_output:
|
6
|
-
newimpl: true
|
7
|
-
open_timeout:
|
8
|
-
port: 80
|
9
|
-
read_timeout: 60
|
10
|
-
seems_1_0_server: false
|
11
|
-
socket:
|
12
|
-
ssl_context:
|
13
|
-
started: true
|
14
|
-
use_ssl: false
|
@@ -1,25 +0,0 @@
|
|
1
|
-
--- !ruby/object:Net::HTTPOK
|
2
|
-
body: The response from example.com
|
3
|
-
body_exist: true
|
4
|
-
code: "200"
|
5
|
-
header:
|
6
|
-
last-modified:
|
7
|
-
- Tue, 15 Nov 2005 13:24:10 GMT
|
8
|
-
connection:
|
9
|
-
- close
|
10
|
-
date:
|
11
|
-
- Wed, 31 Mar 2010 02:43:26 GMT
|
12
|
-
content-type:
|
13
|
-
- text/html; charset=UTF-8
|
14
|
-
etag:
|
15
|
-
- "\"24ec5-1b6-4059a80bfd280\""
|
16
|
-
server:
|
17
|
-
- Apache/2.2.3 (CentOS)
|
18
|
-
content-length:
|
19
|
-
- "438"
|
20
|
-
accept-ranges:
|
21
|
-
- bytes
|
22
|
-
http_version: "1.1"
|
23
|
-
message: OK
|
24
|
-
read: true
|
25
|
-
socket:
|
@@ -1,108 +0,0 @@
|
|
1
|
-
---
|
2
|
-
- !ruby/struct:VCR::HTTPInteraction
|
3
|
-
:request: !ruby/struct:VCR::Request
|
4
|
-
:method: :get
|
5
|
-
:uri: http://example.com:80/foo
|
6
|
-
:body:
|
7
|
-
:headers:
|
8
|
-
:response: !ruby/struct:VCR::Response
|
9
|
-
:status: !ruby/struct:VCR::ResponseStatus
|
10
|
-
:code: 200
|
11
|
-
:message: OK
|
12
|
-
:headers:
|
13
|
-
etag:
|
14
|
-
- "\"24ec5-1b6-4059a80bfd280\""
|
15
|
-
last-modified:
|
16
|
-
- Tue, 15 Nov 2005 13:24:10 GMT
|
17
|
-
connection:
|
18
|
-
- Keep-Alive
|
19
|
-
content-type:
|
20
|
-
- text/html; charset=UTF-8
|
21
|
-
date:
|
22
|
-
- Wed, 31 Mar 2010 02:43:23 GMT
|
23
|
-
server:
|
24
|
-
- Apache/2.2.3 (CentOS)
|
25
|
-
content-length:
|
26
|
-
- "438"
|
27
|
-
age:
|
28
|
-
- "3285"
|
29
|
-
accept-ranges:
|
30
|
-
- bytes
|
31
|
-
:body: example.com get response 1 with path=foo
|
32
|
-
:http_version: "1.1"
|
33
|
-
- !ruby/struct:VCR::HTTPInteraction
|
34
|
-
:request: !ruby/struct:VCR::Request
|
35
|
-
:method: :get
|
36
|
-
:uri: http://example.com:80/foo
|
37
|
-
:body:
|
38
|
-
:headers:
|
39
|
-
:response: !ruby/struct:VCR::Response
|
40
|
-
:status: !ruby/struct:VCR::ResponseStatus
|
41
|
-
:code: 200
|
42
|
-
:message: OK
|
43
|
-
:headers:
|
44
|
-
etag:
|
45
|
-
- "\"24ec5-1b6-4059a80bfd280\""
|
46
|
-
last-modified:
|
47
|
-
- Tue, 15 Nov 2005 13:24:10 GMT
|
48
|
-
connection:
|
49
|
-
- Keep-Alive
|
50
|
-
content-type:
|
51
|
-
- text/html; charset=UTF-8
|
52
|
-
date:
|
53
|
-
- Wed, 31 Mar 2010 02:43:23 GMT
|
54
|
-
server:
|
55
|
-
- Apache/2.2.3 (CentOS)
|
56
|
-
content-length:
|
57
|
-
- "438"
|
58
|
-
age:
|
59
|
-
- "3285"
|
60
|
-
accept-ranges:
|
61
|
-
- bytes
|
62
|
-
:body: example.com get response 2 with path=foo
|
63
|
-
:http_version: "1.1"
|
64
|
-
- !ruby/struct:VCR::HTTPInteraction
|
65
|
-
:request: !ruby/struct:VCR::Request
|
66
|
-
:method: :post
|
67
|
-
:uri: http://example.com:80/
|
68
|
-
:body:
|
69
|
-
:headers:
|
70
|
-
:response: !ruby/struct:VCR::Response
|
71
|
-
:status: !ruby/struct:VCR::ResponseStatus
|
72
|
-
:code: 200
|
73
|
-
:message: OK
|
74
|
-
:headers:
|
75
|
-
etag:
|
76
|
-
- "\"24ec5-1b6-4059a80bfd280\""
|
77
|
-
last-modified:
|
78
|
-
- Tue, 15 Nov 2005 13:24:10 GMT
|
79
|
-
content-type:
|
80
|
-
- text/html; charset=UTF-8
|
81
|
-
connection:
|
82
|
-
- close
|
83
|
-
server:
|
84
|
-
- Apache/2.2.3 (CentOS)
|
85
|
-
date:
|
86
|
-
- Wed, 31 Mar 2010 02:43:26 GMT
|
87
|
-
content-length:
|
88
|
-
- "438"
|
89
|
-
accept-ranges:
|
90
|
-
- bytes
|
91
|
-
:body: example.com post response with id=3
|
92
|
-
:http_version: "1.1"
|
93
|
-
- !ruby/struct:VCR::HTTPInteraction
|
94
|
-
:request: !ruby/struct:VCR::Request
|
95
|
-
:method: :get
|
96
|
-
:uri: http://example.com:80/two_set_cookie_headers
|
97
|
-
:body:
|
98
|
-
:headers:
|
99
|
-
:response: !ruby/struct:VCR::Response
|
100
|
-
:status: !ruby/struct:VCR::ResponseStatus
|
101
|
-
:code: 200
|
102
|
-
:message: OK
|
103
|
-
:headers:
|
104
|
-
set-cookie:
|
105
|
-
- bar=bazz
|
106
|
-
- foo=bar
|
107
|
-
:body: this response has two set-cookie headers
|
108
|
-
:http_version: "1.1"
|
@@ -1,185 +0,0 @@
|
|
1
|
-
---
|
2
|
-
- !ruby/struct:VCR::HTTPInteraction
|
3
|
-
:request: !ruby/struct:VCR::Request
|
4
|
-
:method: :post
|
5
|
-
:uri: http://example.com:80/method
|
6
|
-
:body:
|
7
|
-
:headers:
|
8
|
-
:response: !ruby/struct:VCR::Response
|
9
|
-
:status: !ruby/struct:VCR::ResponseStatus
|
10
|
-
:code: 200
|
11
|
-
:message: OK
|
12
|
-
:headers:
|
13
|
-
etag:
|
14
|
-
- "\"24ec5-1b6-4059a80bfd280\""
|
15
|
-
:body: post method response
|
16
|
-
:http_version: "1.1"
|
17
|
-
- !ruby/struct:VCR::HTTPInteraction
|
18
|
-
:request: !ruby/struct:VCR::Request
|
19
|
-
:method: :get
|
20
|
-
:uri: http://example.com:80/method
|
21
|
-
:body:
|
22
|
-
:headers:
|
23
|
-
:response: !ruby/struct:VCR::Response
|
24
|
-
:status: !ruby/struct:VCR::ResponseStatus
|
25
|
-
:code: 200
|
26
|
-
:message: OK
|
27
|
-
:headers:
|
28
|
-
etag:
|
29
|
-
- "\"24ec5-1b6-4059a80bfd280\""
|
30
|
-
:body: get method response
|
31
|
-
:http_version: "1.1"
|
32
|
-
- !ruby/struct:VCR::HTTPInteraction
|
33
|
-
:request: !ruby/struct:VCR::Request
|
34
|
-
:method: :post
|
35
|
-
:uri: http://example1.com:80/host
|
36
|
-
:body:
|
37
|
-
:headers:
|
38
|
-
:response: !ruby/struct:VCR::Response
|
39
|
-
:status: !ruby/struct:VCR::ResponseStatus
|
40
|
-
:code: 200
|
41
|
-
:message: OK
|
42
|
-
:headers:
|
43
|
-
etag:
|
44
|
-
- "\"24ec5-1b6-4059a80bfd280\""
|
45
|
-
:body: example1.com host response
|
46
|
-
:http_version: "1.1"
|
47
|
-
- !ruby/struct:VCR::HTTPInteraction
|
48
|
-
:request: !ruby/struct:VCR::Request
|
49
|
-
:method: :post
|
50
|
-
:uri: http://example2.com:80/host
|
51
|
-
:body:
|
52
|
-
:headers:
|
53
|
-
:response: !ruby/struct:VCR::Response
|
54
|
-
:status: !ruby/struct:VCR::ResponseStatus
|
55
|
-
:code: 200
|
56
|
-
:message: OK
|
57
|
-
:headers:
|
58
|
-
etag:
|
59
|
-
- "\"24ec5-1b6-4059a80bfd280\""
|
60
|
-
:body: example2.com host response
|
61
|
-
:http_version: "1.1"
|
62
|
-
- !ruby/struct:VCR::HTTPInteraction
|
63
|
-
:request: !ruby/struct:VCR::Request
|
64
|
-
:method: :post
|
65
|
-
:uri: http://example.com:80/path1
|
66
|
-
:body:
|
67
|
-
:headers:
|
68
|
-
:response: !ruby/struct:VCR::Response
|
69
|
-
:status: !ruby/struct:VCR::ResponseStatus
|
70
|
-
:code: 200
|
71
|
-
:message: OK
|
72
|
-
:headers:
|
73
|
-
etag:
|
74
|
-
- "\"24ec5-1b6-4059a80bfd280\""
|
75
|
-
:body: path1 response
|
76
|
-
:http_version: "1.1"
|
77
|
-
- !ruby/struct:VCR::HTTPInteraction
|
78
|
-
:request: !ruby/struct:VCR::Request
|
79
|
-
:method: :post
|
80
|
-
:uri: http://example.com:80/path2
|
81
|
-
:body:
|
82
|
-
:headers:
|
83
|
-
:response: !ruby/struct:VCR::Response
|
84
|
-
:status: !ruby/struct:VCR::ResponseStatus
|
85
|
-
:code: 200
|
86
|
-
:message: OK
|
87
|
-
:headers:
|
88
|
-
etag:
|
89
|
-
- "\"24ec5-1b6-4059a80bfd280\""
|
90
|
-
:body: path2 response
|
91
|
-
:http_version: "1.1"
|
92
|
-
- !ruby/struct:VCR::HTTPInteraction
|
93
|
-
:request: !ruby/struct:VCR::Request
|
94
|
-
:method: :post
|
95
|
-
:uri: http://example.com:80/uri1
|
96
|
-
:body:
|
97
|
-
:headers:
|
98
|
-
:response: !ruby/struct:VCR::Response
|
99
|
-
:status: !ruby/struct:VCR::ResponseStatus
|
100
|
-
:code: 200
|
101
|
-
:message: OK
|
102
|
-
:headers:
|
103
|
-
etag:
|
104
|
-
- "\"24ec5-1b6-4059a80bfd280\""
|
105
|
-
:body: uri1 response
|
106
|
-
:http_version: "1.1"
|
107
|
-
- !ruby/struct:VCR::HTTPInteraction
|
108
|
-
:request: !ruby/struct:VCR::Request
|
109
|
-
:method: :post
|
110
|
-
:uri: http://example.com:80/uri2
|
111
|
-
:body:
|
112
|
-
:headers:
|
113
|
-
:response: !ruby/struct:VCR::Response
|
114
|
-
:status: !ruby/struct:VCR::ResponseStatus
|
115
|
-
:code: 200
|
116
|
-
:message: OK
|
117
|
-
:headers:
|
118
|
-
etag:
|
119
|
-
- "\"24ec5-1b6-4059a80bfd280\""
|
120
|
-
:body: uri2 response
|
121
|
-
:http_version: "1.1"
|
122
|
-
- !ruby/struct:VCR::HTTPInteraction
|
123
|
-
:request: !ruby/struct:VCR::Request
|
124
|
-
:method: :post
|
125
|
-
:uri: http://example.com:80/
|
126
|
-
:body: param=val1
|
127
|
-
:headers:
|
128
|
-
:response: !ruby/struct:VCR::Response
|
129
|
-
:status: !ruby/struct:VCR::ResponseStatus
|
130
|
-
:code: 200
|
131
|
-
:message: OK
|
132
|
-
:headers:
|
133
|
-
etag:
|
134
|
-
- "\"24ec5-1b6-4059a80bfd280\""
|
135
|
-
:body: val1 body response
|
136
|
-
:http_version: "1.1"
|
137
|
-
- !ruby/struct:VCR::HTTPInteraction
|
138
|
-
:request: !ruby/struct:VCR::Request
|
139
|
-
:method: :post
|
140
|
-
:uri: http://example.com:80/
|
141
|
-
:body: param=val2
|
142
|
-
:headers:
|
143
|
-
:response: !ruby/struct:VCR::Response
|
144
|
-
:status: !ruby/struct:VCR::ResponseStatus
|
145
|
-
:code: 200
|
146
|
-
:message: OK
|
147
|
-
:headers:
|
148
|
-
etag:
|
149
|
-
- "\"24ec5-1b6-4059a80bfd280\""
|
150
|
-
:body: val2 body response
|
151
|
-
:http_version: "1.1"
|
152
|
-
- !ruby/struct:VCR::HTTPInteraction
|
153
|
-
:request: !ruby/struct:VCR::Request
|
154
|
-
:method: :post
|
155
|
-
:uri: http://example.com:80/
|
156
|
-
:body:
|
157
|
-
:headers:
|
158
|
-
x-http-header1:
|
159
|
-
- val1
|
160
|
-
:response: !ruby/struct:VCR::Response
|
161
|
-
:status: !ruby/struct:VCR::ResponseStatus
|
162
|
-
:code: 200
|
163
|
-
:message: OK
|
164
|
-
:headers:
|
165
|
-
etag:
|
166
|
-
- "\"24ec5-1b6-4059a80bfd280\""
|
167
|
-
:body: val1 header response
|
168
|
-
:http_version: "1.1"
|
169
|
-
- !ruby/struct:VCR::HTTPInteraction
|
170
|
-
:request: !ruby/struct:VCR::Request
|
171
|
-
:method: :post
|
172
|
-
:uri: http://example.com:80/
|
173
|
-
:body:
|
174
|
-
:headers:
|
175
|
-
x-http-header1:
|
176
|
-
- val2
|
177
|
-
:response: !ruby/struct:VCR::Response
|
178
|
-
:status: !ruby/struct:VCR::ResponseStatus
|
179
|
-
:code: 200
|
180
|
-
:message: OK
|
181
|
-
:headers:
|
182
|
-
etag:
|
183
|
-
- "\"24ec5-1b6-4059a80bfd280\""
|
184
|
-
:body: val2 header response
|
185
|
-
:http_version: "1.1"
|
@@ -1,29 +0,0 @@
|
|
1
|
-
---
|
2
|
-
- !ruby/struct:VCR::RecordedResponse
|
3
|
-
method: :post
|
4
|
-
uri: http://example.com:80/
|
5
|
-
response: !ruby/object:Net::HTTPOK
|
6
|
-
body: The response from example.com
|
7
|
-
body_exist: true
|
8
|
-
code: "200"
|
9
|
-
header:
|
10
|
-
etag:
|
11
|
-
- "\"24ec5-1b6-4059a80bfd280\""
|
12
|
-
last-modified:
|
13
|
-
- Tue, 15 Nov 2005 13:24:10 GMT
|
14
|
-
content-type:
|
15
|
-
- text/html; charset=UTF-8
|
16
|
-
connection:
|
17
|
-
- close
|
18
|
-
server:
|
19
|
-
- Apache/2.2.3 (CentOS)
|
20
|
-
date:
|
21
|
-
- Wed, 31 Mar 2010 02:43:26 GMT
|
22
|
-
content-length:
|
23
|
-
- "438"
|
24
|
-
accept-ranges:
|
25
|
-
- bytes
|
26
|
-
http_version: "1.1"
|
27
|
-
message: OK
|
28
|
-
read: true
|
29
|
-
socket:
|
File without changes
|
@@ -1,14 +0,0 @@
|
|
1
|
-
--- !ruby/object:Net::HTTP
|
2
|
-
address: example.com
|
3
|
-
close_on_empty_response: false
|
4
|
-
curr_http_version: "1.1"
|
5
|
-
debug_output:
|
6
|
-
newimpl: true
|
7
|
-
open_timeout:
|
8
|
-
port: 80
|
9
|
-
read_timeout: 60
|
10
|
-
seems_1_0_server: false
|
11
|
-
socket:
|
12
|
-
ssl_context:
|
13
|
-
started: true
|
14
|
-
use_ssl: false
|
@@ -1,25 +0,0 @@
|
|
1
|
-
--- !ruby/object:Net::HTTPOK
|
2
|
-
body: The response from example.com
|
3
|
-
body_exist: true
|
4
|
-
code: "200"
|
5
|
-
header:
|
6
|
-
last-modified:
|
7
|
-
- Tue, 15 Nov 2005 13:24:10 GMT
|
8
|
-
connection:
|
9
|
-
- close
|
10
|
-
date:
|
11
|
-
- Wed, 31 Mar 2010 02:43:26 GMT
|
12
|
-
content-type:
|
13
|
-
- text/html; charset=UTF-8
|
14
|
-
etag:
|
15
|
-
- "\"24ec5-1b6-4059a80bfd280\""
|
16
|
-
server:
|
17
|
-
- Apache/2.2.3 (CentOS)
|
18
|
-
content-length:
|
19
|
-
- "438"
|
20
|
-
accept-ranges:
|
21
|
-
- bytes
|
22
|
-
http_version: "1.1"
|
23
|
-
message: OK
|
24
|
-
read: true
|
25
|
-
socket:
|
@@ -1,133 +0,0 @@
|
|
1
|
-
shared_examples_for "an http stubbing adapter" do |supported_http_libraries, supported_request_match_attributes, *other|
|
2
|
-
before(:each) { VCR.stub!(:http_stubbing_adapter).and_return(subject) }
|
3
|
-
subject { described_class }
|
4
|
-
|
5
|
-
describe '.set_http_connections_allowed_to_default' do
|
6
|
-
[true, false].each do |default|
|
7
|
-
context "when VCR::Config.allow_http_connections_when_no_cassette is #{default}" do
|
8
|
-
before(:each) { VCR::Config.allow_http_connections_when_no_cassette = default }
|
9
|
-
|
10
|
-
it "sets http_connections_allowed to #{default}" do
|
11
|
-
subject.http_connections_allowed = !default
|
12
|
-
expect {
|
13
|
-
subject.set_http_connections_allowed_to_default
|
14
|
-
}.to change { subject.http_connections_allowed? }.from(!default).to(default)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
describe '.exclusively_enabled' do
|
21
|
-
def adapter_enabled?(adapter)
|
22
|
-
enabled = nil
|
23
|
-
subject.exclusively_enabled { enabled = adapter.enabled? }
|
24
|
-
enabled
|
25
|
-
end
|
26
|
-
|
27
|
-
VCR::HttpStubbingAdapters::Common.adapters.each do |adapter|
|
28
|
-
if adapter == described_class
|
29
|
-
it "yields with #{adapter} enabled" do
|
30
|
-
adapter_enabled?(adapter).should eq(true)
|
31
|
-
end
|
32
|
-
else
|
33
|
-
it "yields without #{adapter} enabled" do
|
34
|
-
adapter_enabled?(adapter).should eq(false)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
it 're-enables all adapters afterwards' do
|
40
|
-
VCR::HttpStubbingAdapters::Common.adapters.each { |a| a.should be_enabled }
|
41
|
-
subject.exclusively_enabled { }
|
42
|
-
VCR::HttpStubbingAdapters::Common.adapters.each { |a| a.should be_enabled }
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
if other.include?(:needs_net_http_extension)
|
47
|
-
describe '.request_uri' do
|
48
|
-
it 'returns the uri for the given http request' do
|
49
|
-
net_http = Net::HTTP.new('example.com', 80)
|
50
|
-
request = Net::HTTP::Get.new('/foo/bar')
|
51
|
-
subject.request_uri(net_http, request).should eq('http://example.com:80/foo/bar')
|
52
|
-
end
|
53
|
-
|
54
|
-
it 'handles basic auth' do
|
55
|
-
net_http = Net::HTTP.new('example.com',80)
|
56
|
-
request = Net::HTTP::Get.new('/auth.txt')
|
57
|
-
request.basic_auth 'user', 'pass'
|
58
|
-
subject.request_uri(net_http, request).should eq('http://user:pass@example.com:80/auth.txt')
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
describe '.request_stubbed? using specific match_attributes' do
|
63
|
-
let(:interactions) { VCR::YAML.load_file(File.join(VCR::SPEC_ROOT, 'fixtures', YAML_SERIALIZATION_VERSION, 'match_requests_on.yml')) }
|
64
|
-
|
65
|
-
@supported_request_match_attributes = supported_request_match_attributes
|
66
|
-
def self.matching_on(attribute, valid1, valid2, invalid, &block)
|
67
|
-
supported_request_match_attributes = @supported_request_match_attributes
|
68
|
-
|
69
|
-
describe ":#{attribute}" do
|
70
|
-
if supported_request_match_attributes.include?(attribute)
|
71
|
-
before(:each) { subject.stub_requests(interactions, [attribute]) }
|
72
|
-
module_eval(&block)
|
73
|
-
|
74
|
-
[valid1, valid2].each do |val|
|
75
|
-
it "returns true for a #{val.inspect} request" do
|
76
|
-
subject.request_stubbed?(request(val), [attribute]).should eq(true)
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
it "returns false for another #{attribute}" do
|
81
|
-
subject.request_stubbed?(request(invalid), [attribute]).should eq(false)
|
82
|
-
end
|
83
|
-
else
|
84
|
-
it 'raises an error indicating matching requests on this attribute is not supported' do
|
85
|
-
expect { subject.request_stubbed?(VCR::Request.new, [attribute]) }.to raise_error(/does not support matching requests on #{attribute}/)
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
matching_on :method, :get, :post, :put do
|
92
|
-
def request(http_method)
|
93
|
-
VCR::Request.new(http_method, 'http://some-wrong-domain.com/', nil, {})
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
matching_on :host, 'example1.com', 'example2.com', 'example3.com' do
|
98
|
-
def request(host)
|
99
|
-
VCR::Request.new(:get, "http://#{host}/some/wrong/path", nil, {})
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
matching_on :uri, 'http://example.com/uri1', 'http://example.com/uri2', 'http://example.com/uri3' do
|
104
|
-
def request(uri)
|
105
|
-
VCR::Request.new(:get, uri, nil, {})
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
matching_on :path, '/path1', '/path2', '/path3' do
|
110
|
-
def request(path)
|
111
|
-
VCR::Request.new(:get, "http://example.com#{path}", nil, {})
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
matching_on :body, 'param=val1', 'param=val2', 'param=val3' do
|
116
|
-
def request(body)
|
117
|
-
VCR::Request.new(:put, "http://wrong-domain.com/wrong/path", body, {})
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
matching_on :headers, { 'X-HTTP-HEADER1' => 'val1' }, { 'X-HTTP-HEADER1' => 'val2' }, { 'X-HTTP-HEADER1' => 'val3' } do
|
122
|
-
def request(headers)
|
123
|
-
VCR::Request.new(:get, "http://wrong-domain.com/wrong/path", nil, headers)
|
124
|
-
end
|
125
|
-
end
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
supported_http_libraries.each do |library|
|
130
|
-
it_behaves_like 'an http library', library, supported_request_match_attributes, *other
|
131
|
-
end
|
132
|
-
end
|
133
|
-
|