vcr 2.0.0.beta2 → 2.0.0.rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +1 -0
- data/.travis.yml +0 -2
- data/CHANGELOG.md +22 -1
- data/CONTRIBUTING.md +46 -0
- data/Gemfile +1 -9
- data/README.md +8 -2
- data/Rakefile +12 -1
- data/cucumber.yml +8 -9
- data/features/.nav +10 -4
- data/features/cassettes/format.feature +1 -1
- data/features/cassettes/no_cassette.feature +8 -11
- data/features/configuration/allow_http_connections_when_no_cassette.feature +4 -4
- data/features/configuration/filter_sensitive_data.feature +3 -0
- data/features/configuration/hook_into.feature +4 -8
- data/features/configuration/ignore_request.feature +191 -0
- data/features/getting_started.md +38 -21
- data/features/hooks/after_http_request.feature +44 -0
- data/features/hooks/around_http_request.feature +56 -0
- data/features/hooks/before_http_request.feature +44 -0
- data/features/hooks/before_playback.feature +181 -0
- data/features/hooks/before_record.feature +172 -0
- data/features/middleware/faraday.feature +7 -3
- data/features/record_modes/none.feature +2 -1
- data/features/record_modes/once.feature +2 -1
- data/features/request_matching/body.feature +2 -2
- data/features/request_matching/custom_matcher.feature +2 -2
- data/features/request_matching/headers.feature +2 -2
- data/features/request_matching/host.feature +2 -2
- data/features/request_matching/identical_request_sequence.feature +2 -2
- data/features/request_matching/method.feature +2 -2
- data/features/request_matching/path.feature +2 -2
- data/features/request_matching/playback_repeats.feature +2 -1
- data/features/request_matching/uri.feature +2 -2
- data/features/support/env.rb +21 -12
- data/features/test_frameworks/cucumber.feature +9 -4
- data/features/test_frameworks/{rspec.feature → rspec_macro.feature} +7 -7
- data/features/test_frameworks/rspec_metadata.feature +90 -0
- data/lib/vcr.rb +1 -1
- data/lib/vcr/cassette.rb +3 -3
- data/lib/vcr/cassette/http_interaction_list.rb +13 -9
- data/lib/vcr/cassette/migrator.rb +1 -1
- data/lib/vcr/configuration.rb +37 -0
- data/lib/vcr/errors.rb +172 -6
- data/lib/vcr/library_hooks.rb +4 -6
- data/lib/vcr/library_hooks/excon.rb +23 -11
- data/lib/vcr/library_hooks/fakeweb.rb +85 -24
- data/lib/vcr/library_hooks/faraday.rb +30 -2
- data/lib/vcr/library_hooks/typhoeus.rb +25 -3
- data/lib/vcr/library_hooks/webmock.rb +25 -36
- data/lib/vcr/middleware/faraday.rb +23 -5
- data/lib/vcr/request_handler.rb +12 -1
- data/lib/vcr/request_ignorer.rb +12 -1
- data/lib/vcr/request_matcher_registry.rb +1 -9
- data/lib/vcr/structs.rb +32 -2
- data/lib/vcr/test_frameworks/rspec.rb +28 -0
- data/lib/vcr/util/hooks.rb +12 -4
- data/lib/vcr/util/version_checker.rb +2 -0
- data/lib/vcr/version.rb +1 -1
- data/spec/fixtures/cassette_spec/example.yml +1 -1
- data/spec/fixtures/{fake_example.com_responses.yml → fake_example_responses.yml} +0 -0
- data/spec/monkey_patches.rb +1 -1
- data/spec/spec_helper.rb +3 -1
- data/spec/support/http_library_adapters.rb +4 -3
- data/spec/support/shared_example_groups/hook_into_http_library.rb +194 -12
- data/spec/support/shared_example_groups/request_hooks.rb +58 -0
- data/spec/support/shared_example_groups/version_checking.rb +5 -0
- data/spec/support/sinatra_app.rb +17 -9
- data/spec/support/vcr_stub_helpers.rb +17 -0
- data/spec/vcr/cassette/http_interaction_list_spec.rb +28 -29
- data/spec/vcr/cassette/migrator_spec.rb +6 -7
- data/spec/vcr/cassette_spec.rb +5 -5
- data/spec/vcr/configuration_spec.rb +51 -32
- data/spec/vcr/deprecations_spec.rb +0 -8
- data/spec/vcr/errors_spec.rb +129 -0
- data/spec/vcr/library_hooks/excon_spec.rb +21 -4
- data/spec/vcr/library_hooks/fakeweb_spec.rb +71 -3
- data/spec/vcr/library_hooks/faraday_spec.rb +45 -0
- data/spec/vcr/library_hooks/typhoeus_spec.rb +31 -1
- data/spec/vcr/library_hooks/webmock_spec.rb +26 -3
- data/spec/vcr/middleware/faraday_spec.rb +84 -1
- data/spec/vcr/request_ignorer_spec.rb +16 -0
- data/spec/vcr/request_matcher_registry_spec.rb +0 -26
- data/spec/vcr/structs_spec.rb +61 -1
- data/spec/vcr/test_frameworks/rspec_spec.rb +32 -0
- data/spec/vcr/util/hooks_spec.rb +73 -63
- data/spec/vcr_spec.rb +2 -2
- data/vcr.gemspec +5 -5
- metadata +51 -31
- data/features/configuration/hooks.feature +0 -270
- data/features/configuration/ignore_hosts.feature +0 -61
- data/features/configuration/ignore_localhost.feature +0 -97
@@ -1,61 +0,0 @@
|
|
1
|
-
Feature: ignore_hosts
|
2
|
-
|
3
|
-
The `ignore_hosts` configuration option can be used to prevent VCR
|
4
|
-
from having any affect on requests to particular hosts.
|
5
|
-
Requests to ignored hosts will not be recorded and will always be
|
6
|
-
allowed, regardless of the record mode, and even outside of a
|
7
|
-
`VCR.use_cassette` block.
|
8
|
-
|
9
|
-
If you only want to ignore localhost (and its various aliases) you
|
10
|
-
may want to use the `ignore_localhost` option instead.
|
11
|
-
|
12
|
-
Background:
|
13
|
-
Given a file named "sinatra_app.rb" with:
|
14
|
-
"""ruby
|
15
|
-
response_count = 0
|
16
|
-
start_sinatra_app(:port => 7777) do
|
17
|
-
get('/') { "Response #{response_count += 1}" }
|
18
|
-
end
|
19
|
-
"""
|
20
|
-
|
21
|
-
Scenario Outline: ignored host requests are not recorded and are always allowed
|
22
|
-
Given a file named "ignore_hosts.rb" with:
|
23
|
-
"""ruby
|
24
|
-
include_http_adapter_for("<http_lib>")
|
25
|
-
require 'sinatra_app.rb'
|
26
|
-
|
27
|
-
require 'vcr'
|
28
|
-
|
29
|
-
VCR.configure do |c|
|
30
|
-
c.ignore_hosts '127.0.0.1', 'localhost'
|
31
|
-
c.cassette_library_dir = 'cassettes'
|
32
|
-
<configuration>
|
33
|
-
end
|
34
|
-
|
35
|
-
VCR.use_cassette('example') do
|
36
|
-
puts response_body_for(:get, "http://localhost:7777/")
|
37
|
-
end
|
38
|
-
|
39
|
-
puts response_body_for(:get, "http://localhost:7777/")
|
40
|
-
"""
|
41
|
-
When I run `ruby ignore_hosts.rb`
|
42
|
-
Then it should pass with:
|
43
|
-
"""
|
44
|
-
Response 1
|
45
|
-
Response 2
|
46
|
-
"""
|
47
|
-
And the file "cassettes/example.yml" should not exist
|
48
|
-
|
49
|
-
Examples:
|
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) |
|
61
|
-
|
@@ -1,97 +0,0 @@
|
|
1
|
-
Feature: ignore_localhost
|
2
|
-
|
3
|
-
The `ignore_localhost` configuration option can be used to prevent VCR
|
4
|
-
from having any affect on localhost requests. If set to true, it will
|
5
|
-
never record them and always allow them, regardless of the record mode,
|
6
|
-
and even outside of a `VCR.use_cassette` block.
|
7
|
-
|
8
|
-
This is particularly useful when you use VCR with Capybara, since
|
9
|
-
Capybara starts a localhost server and pings it when you use one of
|
10
|
-
its javascript drivers.
|
11
|
-
|
12
|
-
Background:
|
13
|
-
Given a file named "sinatra_app.rb" with:
|
14
|
-
"""ruby
|
15
|
-
response_count = 0
|
16
|
-
start_sinatra_app(:port => 7777) do
|
17
|
-
get('/') { "Response #{response_count += 1}" }
|
18
|
-
end
|
19
|
-
"""
|
20
|
-
|
21
|
-
Scenario Outline: localhost requests are not treated differently by default
|
22
|
-
Given a file named "localhost_not_ignored.rb" with:
|
23
|
-
"""ruby
|
24
|
-
include_http_adapter_for("<http_lib>")
|
25
|
-
require 'sinatra_app.rb'
|
26
|
-
|
27
|
-
require 'vcr'
|
28
|
-
|
29
|
-
VCR.configure do |c|
|
30
|
-
c.cassette_library_dir = 'cassettes'
|
31
|
-
<configuration>
|
32
|
-
end
|
33
|
-
|
34
|
-
VCR.use_cassette('localhost') do
|
35
|
-
response_body_for(:get, "http://localhost:7777/")
|
36
|
-
end
|
37
|
-
|
38
|
-
response_body_for(:get, "http://localhost:7777/")
|
39
|
-
"""
|
40
|
-
When I run `ruby localhost_not_ignored.rb`
|
41
|
-
Then it should fail with "Real HTTP connections are disabled"
|
42
|
-
And the file "cassettes/localhost.yml" should contain "body: Response 1"
|
43
|
-
|
44
|
-
Examples:
|
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) |
|
56
|
-
|
57
|
-
Scenario Outline: localhost requests are allowed and not recorded when ignore_localhost = true
|
58
|
-
Given a file named "ignore_localhost_true.rb" with:
|
59
|
-
"""ruby
|
60
|
-
include_http_adapter_for("<http_lib>")
|
61
|
-
require 'sinatra_app.rb'
|
62
|
-
|
63
|
-
require 'vcr'
|
64
|
-
|
65
|
-
VCR.configure do |c|
|
66
|
-
c.ignore_localhost = true
|
67
|
-
c.cassette_library_dir = 'cassettes'
|
68
|
-
<configuration>
|
69
|
-
end
|
70
|
-
|
71
|
-
VCR.use_cassette('localhost') do
|
72
|
-
puts response_body_for(:get, "http://localhost:7777/")
|
73
|
-
end
|
74
|
-
|
75
|
-
puts response_body_for(:get, "http://localhost:7777/")
|
76
|
-
"""
|
77
|
-
When I run `ruby ignore_localhost_true.rb`
|
78
|
-
Then it should pass with:
|
79
|
-
"""
|
80
|
-
Response 1
|
81
|
-
Response 2
|
82
|
-
"""
|
83
|
-
And the file "cassettes/localhost.yml" should not exist
|
84
|
-
|
85
|
-
Examples:
|
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) |
|
97
|
-
|