vcr 1.3.3 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.rspec +2 -0
- data/CHANGELOG.md +16 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +23 -4
- data/Guardfile +6 -0
- data/README.md +5 -4
- data/Rakefile +1 -3
- data/TODO.md +3 -0
- data/cucumber.yml +3 -3
- data/features/cassettes/no_cassette.feature +67 -0
- data/features/configuration/allow_http_connections_when_no_cassette.feature +54 -0
- data/features/configuration/ignore_localhost.feature +2 -2
- data/features/configuration/stub_with.feature +40 -16
- data/features/http_libraries/em_http_request.feature +217 -0
- data/features/middleware/faraday.feature +89 -0
- data/features/middleware/rack.feature +95 -0
- data/features/step_definitions/cli_steps.rb +7 -0
- data/lib/vcr.rb +48 -4
- data/lib/vcr/config.rb +11 -2
- data/lib/vcr/extensions/net_http.rb +4 -0
- data/lib/vcr/http_stubbing_adapters/common.rb +35 -4
- data/lib/vcr/http_stubbing_adapters/faraday.rb +80 -0
- data/lib/vcr/http_stubbing_adapters/typhoeus.rb +1 -1
- data/lib/vcr/http_stubbing_adapters/webmock.rb +18 -16
- data/lib/vcr/middleware/cassette_arguments.rb +18 -0
- data/lib/vcr/middleware/common.rb +22 -0
- data/lib/vcr/middleware/faraday.rb +79 -0
- data/lib/vcr/middleware/rack.rb +13 -0
- data/lib/vcr/request_matcher.rb +16 -1
- data/lib/vcr/version.rb +1 -1
- data/spec/config_spec.rb +27 -2
- data/spec/fixtures/1.9.1/fake_example.com_responses.yml +0 -29
- data/spec/fixtures/1.9.1/match_requests_on.yml +2 -2
- data/spec/fixtures/not_1.9.1/fake_example.com_responses.yml +0 -29
- data/spec/http_stubbing_adapters/faraday_spec.rb +84 -0
- data/spec/middleware/cassette_arguments_spec.rb +32 -0
- data/spec/middleware/faraday_spec.rb +52 -0
- data/spec/middleware/rack_spec.rb +54 -0
- data/spec/monkey_patches.rb +1 -0
- data/spec/request_matcher_spec.rb +36 -0
- data/spec/spec_helper.rb +10 -0
- data/spec/support/http_library_adapters.rb +113 -25
- data/spec/support/http_stubbing_adapter.rb +55 -16
- data/spec/vcr_spec.rb +92 -4
- data/vcr.gemspec +1 -0
- metadata +72 -34
data/.rspec
ADDED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,21 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 1.4.0 (December 3, 2010)
|
4
|
+
|
5
|
+
[Full Changelog](http://github.com/myronmarston/vcr/compare/v1.3.3...v1.4.0)
|
6
|
+
|
7
|
+
* Added support for making HTTP requests without a cassette (i.e. if you don't
|
8
|
+
want to use VCR for all of your test suite). There are a few ways to
|
9
|
+
enable this:
|
10
|
+
* In your `VCR.config` block, set `allow_http_connections_when_no_cassette`
|
11
|
+
to true to allow HTTP requests without a cassette.
|
12
|
+
* You can temporarily turn off VCR using `VCR.turned_off { ... }`.
|
13
|
+
* You can toggle VCR off and on with `VCR.turn_off!` and `VCR.turn_on!`.
|
14
|
+
* Fixed bug with `ignore_localhost` config option. Previously, an error would
|
15
|
+
be raised if it was set before the `stub_with` option.
|
16
|
+
* Added VCR::Middleware::Rack (see features/middleware/rack.feature for usage).
|
17
|
+
* Added support for Faraday (see features/middleware/faraday.feature for usage).
|
18
|
+
|
3
19
|
## 1.3.3 (November 21, 2010)
|
4
20
|
|
5
21
|
[Full Changelog](http://github.com/myronmarston/vcr/compare/v1.3.2...v1.3.3)
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
vcr (1.
|
4
|
+
vcr (1.4.0)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: http://rubygems.org/
|
@@ -15,7 +15,7 @@ GEM
|
|
15
15
|
bouncy-castle-java (1.5.0145.2)
|
16
16
|
builder (2.1.2)
|
17
17
|
columnize (0.3.1)
|
18
|
-
configuration (1.
|
18
|
+
configuration (1.2.0)
|
19
19
|
crack (0.1.8)
|
20
20
|
cucumber (0.9.4)
|
21
21
|
builder (~> 2.1.2)
|
@@ -30,16 +30,28 @@ GEM
|
|
30
30
|
eventmachine (>= 0.12.9)
|
31
31
|
eventmachine (0.12.10)
|
32
32
|
fakeweb (1.3.0)
|
33
|
+
faraday (0.5.3)
|
34
|
+
addressable (~> 2.2.2)
|
35
|
+
multipart-post (~> 1.0.1)
|
36
|
+
rack (>= 1.1.0, < 2)
|
37
|
+
fuubar (0.0.2)
|
38
|
+
rspec (~> 2.0)
|
39
|
+
rspec-instafail (~> 0.1.4)
|
40
|
+
ruby-progressbar (~> 0.0.9)
|
33
41
|
gherkin (2.2.9)
|
34
42
|
json (~> 1.4.6)
|
35
43
|
term-ansicolor (~> 1.0.5)
|
36
44
|
gherkin (2.2.9-java)
|
37
45
|
json (~> 1.4.6)
|
38
46
|
term-ansicolor (~> 1.0.5)
|
47
|
+
growl (1.0.3)
|
39
48
|
guard (0.2.2)
|
40
49
|
open_gem (~> 1.4.2)
|
41
50
|
thor (~> 0.14.3)
|
42
|
-
guard-
|
51
|
+
guard-cucumber (0.2.1)
|
52
|
+
cucumber (~> 0.9.4)
|
53
|
+
guard (~> 0.2.2)
|
54
|
+
guard-rspec (0.1.8)
|
43
55
|
guard (>= 0.2.0)
|
44
56
|
httpclient (2.1.5.2)
|
45
57
|
jruby-openssl (0.7.2)
|
@@ -53,6 +65,7 @@ GEM
|
|
53
65
|
linecache19 (0.5.11)
|
54
66
|
ruby_core_source (>= 0.1.4)
|
55
67
|
mime-types (1.16)
|
68
|
+
multipart-post (1.0.1)
|
56
69
|
open_gem (1.4.2)
|
57
70
|
launchy (~> 0.3.5)
|
58
71
|
patron (0.4.9)
|
@@ -73,6 +86,7 @@ GEM
|
|
73
86
|
rspec-core (2.1.0)
|
74
87
|
rspec-expectations (2.1.0)
|
75
88
|
diff-lcs (~> 1.1.2)
|
89
|
+
rspec-instafail (0.1.4)
|
76
90
|
rspec-mocks (2.1.0)
|
77
91
|
ruby-debug (0.10.3)
|
78
92
|
columnize (>= 0.1)
|
@@ -87,6 +101,7 @@ GEM
|
|
87
101
|
columnize (>= 0.3.1)
|
88
102
|
linecache19 (>= 0.5.11)
|
89
103
|
ruby-debug-base19 (>= 0.11.19)
|
104
|
+
ruby-progressbar (0.0.9)
|
90
105
|
ruby_core_source (0.1.4)
|
91
106
|
archive-tar-minitar (>= 0.5.2)
|
92
107
|
shoulda (2.9.2)
|
@@ -94,7 +109,7 @@ GEM
|
|
94
109
|
rack (~> 1.1)
|
95
110
|
tilt (~> 1.1)
|
96
111
|
term-ansicolor (1.0.5)
|
97
|
-
thor (0.14.
|
112
|
+
thor (0.14.6)
|
98
113
|
tilt (1.1)
|
99
114
|
timecop (0.3.5)
|
100
115
|
typhoeus (0.2.0)
|
@@ -113,6 +128,10 @@ DEPENDENCIES
|
|
113
128
|
curb (~> 0.7.8)
|
114
129
|
em-http-request (~> 0.2.7)
|
115
130
|
fakeweb (~> 1.3.0)
|
131
|
+
faraday (~> 0.5.3)
|
132
|
+
fuubar
|
133
|
+
growl
|
134
|
+
guard-cucumber
|
116
135
|
guard-rspec
|
117
136
|
httpclient (~> 2.1.5.2)
|
118
137
|
jruby-openssl
|
data/Guardfile
CHANGED
@@ -7,3 +7,9 @@ guard 'rspec', :version => 2 do
|
|
7
7
|
watch('^lib/vcr/(.*)\.rb') { |m| "spec/#{m[1]}_spec.rb" }
|
8
8
|
watch('^spec/spec_helper.rb') { "spec" }
|
9
9
|
end
|
10
|
+
|
11
|
+
guard 'cucumber' do
|
12
|
+
watch('^features/(.*).feature')
|
13
|
+
watch('^features/support') { 'features' }
|
14
|
+
watch('^features/step_definitions') { 'features' }
|
15
|
+
end
|
data/README.md
CHANGED
@@ -29,15 +29,15 @@ maintenance) and accurate (the response from example.com will contain the same h
|
|
29
29
|
## Features
|
30
30
|
|
31
31
|
* Automatically records and replays your HTTP interactions with minimal setup/configuration code.
|
32
|
-
* Supports multiple HTTP stubbing libraries. Currently FakeWeb
|
33
|
-
|
32
|
+
* Supports multiple HTTP stubbing libraries. Currently FakeWeb, WebMock, Typhoeus and Faraday
|
33
|
+
are supported.
|
34
34
|
* Supports multiple HTTP libraries:
|
35
35
|
* [Patron](http://github.com/toland/patron) (WebMock)
|
36
|
-
* [Curb](http://github.com/taf2/curb) (WebMock)
|
36
|
+
* [Curb](http://github.com/taf2/curb) (WebMock -- only supports Curb::Easy at the moment)
|
37
37
|
* [HTTPClient](http://github.com/nahi/httpclient) (WebMock)
|
38
38
|
* [em-http-request](http://github.com/igrigorik/em-http-request) (WebMock)
|
39
39
|
* [Net::HTTP](http://www.ruby-doc.org/stdlib/libdoc/net/http/rdoc/index.html) (FakeWeb and WebMock)
|
40
|
-
* [Typhoeus](https://github.com/pauldix/typhoeus)
|
40
|
+
* [Typhoeus](https://github.com/pauldix/typhoeus) (Typhoeus::Hydra, but not Typhoeus::Easy or Typhoeus::Multi)
|
41
41
|
* And of course any library built on Net::HTTP, such as [Mechanize](http://github.com/tenderlove/mechanize),
|
42
42
|
[HTTParty](http://github.com/jnunemaker/httparty) or [Rest Client](http://github.com/archiloque/rest-client).
|
43
43
|
* Request matching is configurable based on HTTP method, URI, host, path, body and headers.
|
@@ -50,6 +50,7 @@ maintenance) and accurate (the response from example.com will contain the same h
|
|
50
50
|
* Known to work well with many popular ruby libraries including RSpec 1 & 2, Cucumber, Test::Unit,
|
51
51
|
Capybara, Mechanize, Rest-Client and HTTParty.
|
52
52
|
* Extensively tested on 7 different ruby interpretters.
|
53
|
+
* Includes Rack and Faraday middleware.
|
53
54
|
|
54
55
|
## Usage
|
55
56
|
|
data/Rakefile
CHANGED
@@ -5,9 +5,7 @@ Bundler::GemHelper.install_tasks
|
|
5
5
|
require 'rake'
|
6
6
|
require "rspec/core/rake_task"
|
7
7
|
|
8
|
-
RSpec::Core::RakeTask.new(:spec)
|
9
|
-
#t.rspec_opts = %w[--format documentation]
|
10
|
-
end
|
8
|
+
RSpec::Core::RakeTask.new(:spec)
|
11
9
|
|
12
10
|
desc "Run all examples using rcov"
|
13
11
|
RSpec::Core::RakeTask.new :rcov => :cleanup_rcov_files do |t|
|
data/TODO.md
CHANGED
data/cucumber.yml
CHANGED
@@ -2,13 +2,13 @@
|
|
2
2
|
rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
|
3
3
|
rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
|
4
4
|
std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} --strict --tags ~@wip"
|
5
|
-
interp_opts = if
|
6
|
-
|
5
|
+
interp_opts = if defined?(RUBY_ENGINE)
|
6
|
+
" --tags ~@exclude-#{RUBY_ENGINE}"
|
7
7
|
else
|
8
8
|
''
|
9
9
|
end
|
10
10
|
%>
|
11
11
|
default: <%= std_opts %><%= interp_opts %> features
|
12
|
-
wip: --tags @wip:30 --wip features
|
12
|
+
wip: --tags @wip:30 --wip features<%= interp_opts %>
|
13
13
|
rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip<%= interp_opts %>
|
14
14
|
|
@@ -6,6 +6,16 @@ Feature: Error for HTTP request made when no cassette is in use
|
|
6
6
|
use. The error is helpful to pinpoint where HTTP requests are
|
7
7
|
made so you can use a VCR cassette at that point in your code.
|
8
8
|
|
9
|
+
If you want to allow an HTTP request to proceed as normal, you can
|
10
|
+
set the `allow_http_connections_when_no_cassette` configuration option
|
11
|
+
(see configuration/allow_http_connections_when_no_cassette.feature) or
|
12
|
+
you can temporarily turn VCR off:
|
13
|
+
|
14
|
+
* VCR.turn_off! => turn VCR off so HTTP requests are allowed
|
15
|
+
* VCR.turn_on! => turn VCR back on
|
16
|
+
* VCR.turned_off { ... } => turn VCR off for the duration of the
|
17
|
+
provided block.
|
18
|
+
|
9
19
|
Scenario Outline: Error for request when no cassette is in use
|
10
20
|
Given a file named "no_cassette_error.rb" with:
|
11
21
|
"""
|
@@ -36,3 +46,60 @@ Feature: Error for HTTP request made when no cassette is in use
|
|
36
46
|
| :webmock | patron | Real HTTP connections are disabled |
|
37
47
|
| :webmock | em-http-request | Real HTTP connections are disabled |
|
38
48
|
| :typhoeus | typhoeus | Real HTTP requests are not allowed |
|
49
|
+
|
50
|
+
Scenario: Temporarily turn VCR off to allow HTTP requests to procede as normal
|
51
|
+
Given a file named "turn_off_vcr.rb" with:
|
52
|
+
"""
|
53
|
+
require 'vcr_cucumber_helpers'
|
54
|
+
|
55
|
+
start_sinatra_app(:port => 7777) do
|
56
|
+
get('/') { 'Hello' }
|
57
|
+
end
|
58
|
+
|
59
|
+
require 'vcr'
|
60
|
+
|
61
|
+
VCR.config do |c|
|
62
|
+
c.stub_with :fakeweb
|
63
|
+
end
|
64
|
+
|
65
|
+
def make_request(context)
|
66
|
+
puts context
|
67
|
+
puts Net::HTTP.get_response('localhost', '/', 7777).body
|
68
|
+
rescue => e
|
69
|
+
puts "Error: #{e.message}"
|
70
|
+
end
|
71
|
+
|
72
|
+
VCR.turned_off do
|
73
|
+
make_request "In VCR.turned_off block"
|
74
|
+
end
|
75
|
+
|
76
|
+
make_request "Outside of VCR.turned_off block"
|
77
|
+
|
78
|
+
VCR.turn_off!
|
79
|
+
make_request "After calling VCR.turn_off!"
|
80
|
+
|
81
|
+
VCR.turn_on!
|
82
|
+
make_request "After calling VCR.turn_on!"
|
83
|
+
"""
|
84
|
+
When I run "ruby turn_off_vcr.rb"
|
85
|
+
Then the output should contain:
|
86
|
+
"""
|
87
|
+
In VCR.turned_off block
|
88
|
+
Hello
|
89
|
+
"""
|
90
|
+
And the output should contain:
|
91
|
+
"""
|
92
|
+
Outside of VCR.turned_off block
|
93
|
+
Error: Real HTTP connections are disabled.
|
94
|
+
"""
|
95
|
+
And the output should contain:
|
96
|
+
"""
|
97
|
+
After calling VCR.turn_off!
|
98
|
+
Hello
|
99
|
+
"""
|
100
|
+
And the output should contain:
|
101
|
+
"""
|
102
|
+
After calling VCR.turn_on!
|
103
|
+
Error: Real HTTP connections are disabled.
|
104
|
+
"""
|
105
|
+
|
@@ -0,0 +1,54 @@
|
|
1
|
+
Feature: allow_http_connections_when_no_cassette configuration option
|
2
|
+
|
3
|
+
Usually, HTTP requests made when no cassette is inserted will result
|
4
|
+
in an error (see cassettes/no_cassette.feature). You can set the
|
5
|
+
`allow_http_connections_when_no_cassette` configuration option to
|
6
|
+
true to allow requests, if you do not want to use VCR for everything.
|
7
|
+
|
8
|
+
Background:
|
9
|
+
Given a file named "vcr_setup.rb" with:
|
10
|
+
"""
|
11
|
+
require 'vcr_cucumber_helpers'
|
12
|
+
|
13
|
+
if ARGV.include?('--with-server')
|
14
|
+
start_sinatra_app(:port => 7777) do
|
15
|
+
get('/') { "Hello" }
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
require 'vcr'
|
20
|
+
|
21
|
+
VCR.config do |c|
|
22
|
+
c.allow_http_connections_when_no_cassette = true
|
23
|
+
c.stub_with :fakeweb
|
24
|
+
c.cassette_library_dir = 'cassettes'
|
25
|
+
end
|
26
|
+
"""
|
27
|
+
And the directory "vcr/cassettes" does not exist
|
28
|
+
|
29
|
+
Scenario: Allow HTTP connections when no cassette
|
30
|
+
Given a file named "no_cassette.rb" with:
|
31
|
+
"""
|
32
|
+
require 'vcr_setup.rb'
|
33
|
+
|
34
|
+
puts "Response: " + Net::HTTP.get_response('localhost', '/', 7777).body
|
35
|
+
"""
|
36
|
+
When I run "ruby no_cassette.rb --with-server"
|
37
|
+
Then the output should contain "Response: Hello"
|
38
|
+
|
39
|
+
Scenario: Cassettes record and replay as normal
|
40
|
+
Given a file named "record_replay_cassette.rb" with:
|
41
|
+
"""
|
42
|
+
require 'vcr_setup.rb'
|
43
|
+
|
44
|
+
VCR.use_cassette('localhost', :record => :new_episodes) do
|
45
|
+
puts "Response: " + Net::HTTP.get_response('localhost', '/', 7777).body
|
46
|
+
end
|
47
|
+
"""
|
48
|
+
When I run "ruby record_replay_cassette.rb --with-server"
|
49
|
+
Then the output should contain "Response: Hello"
|
50
|
+
And the file "cassettes/localhost.yml" should contain "body: Hello"
|
51
|
+
|
52
|
+
When I run "ruby record_replay_cassette.rb"
|
53
|
+
Then the output should contain "Response: Hello"
|
54
|
+
|
@@ -30,9 +30,9 @@ Feature: ignore_localhost configuration option
|
|
30
30
|
require 'vcr'
|
31
31
|
|
32
32
|
VCR.config do |c|
|
33
|
+
<additional_config>
|
33
34
|
c.cassette_library_dir = 'cassettes'
|
34
35
|
c.stub_with <stub_with>
|
35
|
-
<additional_config>
|
36
36
|
end
|
37
37
|
|
38
38
|
VCR.use_cassette('localhost', :record => :new_episodes) do
|
@@ -72,9 +72,9 @@ Feature: ignore_localhost configuration option
|
|
72
72
|
require 'vcr'
|
73
73
|
|
74
74
|
VCR.config do |c|
|
75
|
+
c.ignore_localhost = true
|
75
76
|
c.cassette_library_dir = 'cassettes'
|
76
77
|
c.stub_with <stub_with>
|
77
|
-
c.ignore_localhost = true
|
78
78
|
end
|
79
79
|
|
80
80
|
VCR.use_cassette('localhost', :record => :new_episodes) do
|
@@ -1,17 +1,21 @@
|
|
1
1
|
Feature: stub_with configuration option
|
2
2
|
|
3
3
|
The `stub_with` configuration option determines which HTTP stubbing library
|
4
|
-
VCR will use. There are currently
|
5
|
-
support
|
4
|
+
VCR will use. There are currently 4 supported stubbing libraries which
|
5
|
+
support many different HTTP libraries:
|
6
6
|
|
7
7
|
* FakeWeb can be used to stub Net::HTTP.
|
8
8
|
* WebMock can be used to stub:
|
9
9
|
* Net::HTTP
|
10
10
|
* HTTPClient
|
11
11
|
* Patron
|
12
|
-
* Curb
|
12
|
+
* Curb (Curb::Easy, but not Curb::Multi)
|
13
13
|
* EM HTTP Request
|
14
|
-
* Typhoeus can be used to stub itself
|
14
|
+
* Typhoeus can be used to stub itself (as long as you use Typhoeus::Hydra,
|
15
|
+
but not Typhoeus::Easy or Typhoeus::Multi).
|
16
|
+
* Faraday can be used (in combination with the provided Faraday middleware)
|
17
|
+
to stub requests made through Faraday (regardless of which Faraday HTTP
|
18
|
+
adapter is used).
|
15
19
|
|
16
20
|
There are some addiitonal trade offs to consider when deciding which
|
17
21
|
stubbing library to use:
|
@@ -26,13 +30,14 @@ Feature: stub_with configuration option
|
|
26
30
|
supported HTTP libraries. Typhoeus provides all the necessary
|
27
31
|
stubbing and recording integration points, and no monkey patching
|
28
32
|
is required at all.
|
29
|
-
*
|
30
|
-
*
|
33
|
+
* FakeWeb and WebMock cannot both be used at the same time.
|
34
|
+
* Typhoeus and Faraday can be used together, and with either
|
35
|
+
FakeWeb or WebMock.
|
31
36
|
|
32
37
|
Regardless of which library you use, VCR takes care of all of the configuration
|
33
38
|
for you. You should not need to interact directly with FakeWeb, WebMock or the
|
34
|
-
stubbing facilities of Typhoeus. If/when you decide to change stubbing
|
35
|
-
(i.e. if you initially use FakeWeb because it's faster but later need the
|
39
|
+
stubbing facilities of Typhoeus or Faraday. If/when you decide to change stubbing
|
40
|
+
libraries (i.e. if you initially use FakeWeb because it's faster but later need the
|
36
41
|
additional features of WebMock) you can change the `stub_with` configuration
|
37
42
|
option and it'll work with no other changes required.
|
38
43
|
|
@@ -109,7 +114,7 @@ Feature: stub_with configuration option
|
|
109
114
|
| :typhoeus | typhoeus |
|
110
115
|
|
111
116
|
@exclude-jruby
|
112
|
-
Scenario Outline: Use Typhoeus in combination with FakeWeb or WebMock
|
117
|
+
Scenario Outline: Use Typhoeus and Faraday in combination with FakeWeb or WebMock
|
113
118
|
Given a file named "stub_with_multiple.rb" with:
|
114
119
|
"""
|
115
120
|
require 'vcr_cucumber_helpers'
|
@@ -127,13 +132,24 @@ Feature: stub_with configuration option
|
|
127
132
|
Typhoeus::Request.get("http://localhost:7777/typhoeus").body
|
128
133
|
end
|
129
134
|
|
135
|
+
def faraday_response
|
136
|
+
Faraday::Connection.new(:url => 'http://localhost:7777') do |builder|
|
137
|
+
builder.use VCR::Middleware::Faraday do |cassette|
|
138
|
+
cassette.name 'example'
|
139
|
+
cassette.options :record => :new_episodes
|
140
|
+
end
|
141
|
+
|
142
|
+
builder.adapter :<faraday_adapter>
|
143
|
+
end.get('/faraday').body
|
144
|
+
end
|
145
|
+
|
130
146
|
puts "Net::HTTP 1: #{net_http_response}"
|
131
147
|
puts "Typhoeus 1: #{typhoeus_response}"
|
132
148
|
|
133
149
|
require 'vcr'
|
134
150
|
|
135
151
|
VCR.config do |c|
|
136
|
-
c.stub_with <stub_with>, :typhoeus
|
152
|
+
c.stub_with <stub_with>, :typhoeus, :faraday
|
137
153
|
c.cassette_library_dir = 'vcr_cassettes'
|
138
154
|
end
|
139
155
|
|
@@ -141,6 +157,8 @@ Feature: stub_with configuration option
|
|
141
157
|
puts "Net::HTTP 2: #{net_http_response}"
|
142
158
|
puts "Typhoeus 2: #{typhoeus_response}"
|
143
159
|
end
|
160
|
+
|
161
|
+
puts "Faraday: #{faraday_response}"
|
144
162
|
"""
|
145
163
|
When I run "ruby stub_with_multiple.rb 'Hello'"
|
146
164
|
Then the output should contain each of the following:
|
@@ -148,8 +166,11 @@ Feature: stub_with configuration option
|
|
148
166
|
| Typhoeus 1: Hello typhoeus |
|
149
167
|
| Net::HTTP 2: Hello net_http |
|
150
168
|
| Typhoeus 2: Hello typhoeus |
|
151
|
-
|
152
|
-
And the
|
169
|
+
| Faraday: Hello faraday |
|
170
|
+
And the cassette "vcr_cassettes/example.yml" should have the following response bodies:
|
171
|
+
| Hello net_http |
|
172
|
+
| Hello typhoeus |
|
173
|
+
| Hello faraday |
|
153
174
|
|
154
175
|
When I run "ruby stub_with_multiple.rb 'Goodbye'"
|
155
176
|
Then the output should contain each of the following:
|
@@ -157,8 +178,11 @@ Feature: stub_with configuration option
|
|
157
178
|
| Typhoeus 1: Goodbye typhoeus |
|
158
179
|
| Net::HTTP 2: Hello net_http |
|
159
180
|
| Typhoeus 2: Hello typhoeus |
|
181
|
+
| Faraday: Hello faraday |
|
160
182
|
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
183
|
+
Examples:
|
184
|
+
| stub_with | faraday_adapter |
|
185
|
+
| :fakeweb | net_http |
|
186
|
+
| :webmock | net_http |
|
187
|
+
| :fakeweb | typhoeus |
|
188
|
+
| :webmock | typhoeus |
|