vcr 1.3.1 → 1.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. data/CHANGELOG.md +14 -2
  2. data/Gemfile +3 -0
  3. data/Gemfile.lock +20 -2
  4. data/README.md +6 -1
  5. data/Rakefile +6 -44
  6. data/benchmarks/http_stubbing_libraries.rb +4 -4
  7. data/cucumber.yml +14 -0
  8. data/features/README.md +21 -0
  9. data/features/cassettes/automatic_re_recording.feature +68 -0
  10. data/features/cassettes/dynamic_erb.feature +90 -0
  11. data/features/cassettes/format.feature +81 -0
  12. data/features/cassettes/no_cassette.feature +38 -0
  13. data/features/cassettes/record_modes/all.feature +78 -0
  14. data/features/cassettes/record_modes/new_episodes.feature +71 -0
  15. data/features/cassettes/record_modes/none.feature +65 -0
  16. data/features/cassettes/request_matching.feature +379 -0
  17. data/features/configuration/cassette_library_dir.feature +28 -0
  18. data/features/configuration/default_cassette_options.feature +80 -0
  19. data/features/configuration/ignore_localhost.feature +103 -0
  20. data/features/configuration/stub_with.feature +164 -0
  21. data/features/http_libraries/net_http.feature +137 -0
  22. data/features/step_definitions/cli_steps.rb +82 -0
  23. data/features/support/aruba_workaround/aruba_patches.rb +36 -0
  24. data/features/support/aruba_workaround/background_process.rb +4 -0
  25. data/features/support/env.rb +16 -102
  26. data/features/support/http_lib_filters.rb +37 -0
  27. data/features/support/vcr_cucumber_helpers.rb +34 -0
  28. data/features/test_frameworks/cucumber.feature +109 -0
  29. data/features/test_frameworks/rspec.feature +110 -0
  30. data/features/test_frameworks/shoulda.feature +64 -0
  31. data/features/test_frameworks/test_unit.feature +46 -0
  32. data/lib/vcr/cassette.rb +1 -1
  33. data/lib/vcr/structs.rb +64 -13
  34. data/lib/vcr/version.rb +1 -1
  35. data/{FullBuildRakeFile → script/FullBuildRakeFile} +0 -0
  36. data/script/full_build +1 -0
  37. data/spec/extensions/net_http_spec.rb +1 -1
  38. data/spec/spec_helper.rb +1 -1
  39. data/spec/structs_spec.rb +47 -16
  40. data/spec/support/vcr_localhost_server.rb +11 -5
  41. data/vcr.gemspec +2 -1
  42. metadata +82 -77
  43. data/features/fixtures/vcr_cassettes/1.9.1/cucumber_tags/regex_cassette.yml +0 -43
  44. data/features/fixtures/vcr_cassettes/1.9.1/cucumber_tags/replay_cassette1.yml +0 -43
  45. data/features/fixtures/vcr_cassettes/1.9.1/cucumber_tags/replay_cassette2.yml +0 -63
  46. data/features/fixtures/vcr_cassettes/1.9.1/cucumber_tags/replay_cassette3.yml +0 -85
  47. data/features/fixtures/vcr_cassettes/1.9.1/erb_cassette.yml +0 -36
  48. data/features/fixtures/vcr_cassettes/1.9.1/match_requests_on.yml +0 -35
  49. data/features/fixtures/vcr_cassettes/1.9.1/nested_replay_cassette.yml +0 -32
  50. data/features/fixtures/vcr_cassettes/1.9.1/not_the_real_response.yml +0 -43
  51. data/features/fixtures/vcr_cassettes/1.9.1/record_all.yml +0 -62
  52. data/features/fixtures/vcr_cassettes/1.9.1/replay_localhost_cassette.yml +0 -32
  53. data/features/fixtures/vcr_cassettes/not_1.9.1/cucumber_tags/regex_cassette.yml +0 -43
  54. data/features/fixtures/vcr_cassettes/not_1.9.1/cucumber_tags/replay_cassette1.yml +0 -43
  55. data/features/fixtures/vcr_cassettes/not_1.9.1/cucumber_tags/replay_cassette2.yml +0 -47
  56. data/features/fixtures/vcr_cassettes/not_1.9.1/cucumber_tags/replay_cassette3.yml +0 -85
  57. data/features/fixtures/vcr_cassettes/not_1.9.1/erb_cassette.yml +0 -36
  58. data/features/fixtures/vcr_cassettes/not_1.9.1/match_requests_on.yml +0 -35
  59. data/features/fixtures/vcr_cassettes/not_1.9.1/nested_replay_cassette.yml +0 -24
  60. data/features/fixtures/vcr_cassettes/not_1.9.1/not_the_real_response.yml +0 -43
  61. data/features/fixtures/vcr_cassettes/not_1.9.1/record_all.yml +0 -61
  62. data/features/fixtures/vcr_cassettes/not_1.9.1/replay_localhost_cassette.yml +0 -32
  63. data/features/http_client.feature +0 -16
  64. data/features/net_http.feature +0 -38
  65. data/features/record_response.feature +0 -95
  66. data/features/replay_recorded_response.feature +0 -96
  67. data/features/rspec.feature +0 -100
  68. data/features/step_definitions/http_client_steps.rb +0 -7
  69. data/features/step_definitions/net_http_steps.rb +0 -49
  70. data/features/step_definitions/vcr_steps.rb +0 -252
  71. data/features/webmock.feature +0 -26
  72. data/full_build +0 -1
@@ -0,0 +1,28 @@
1
+ Feature: cassette_library_dir configuration option
2
+
3
+ The `cassette_library_dir` configuration option sets a directory
4
+ where VCR saves each cassette.
5
+
6
+ Scenario: cassette_library_dir
7
+ Given a file named "cassette_library_dir.rb" with:
8
+ """
9
+ require 'vcr_cucumber_helpers'
10
+
11
+ start_sinatra_app(:port => 7777) do
12
+ get('/') { "Hello" }
13
+ end
14
+
15
+ require 'vcr'
16
+
17
+ VCR.config do |c|
18
+ c.cassette_library_dir = 'vcr/cassettes'
19
+ c.stub_with :fakeweb
20
+ end
21
+
22
+ VCR.use_cassette('localhost', :record => :new_episodes) do
23
+ Net::HTTP.get_response('localhost', '/', 7777)
24
+ end
25
+ """
26
+ And the directory "vcr/cassettes" does not exist
27
+ When I run "ruby cassette_library_dir.rb"
28
+ Then the file "vcr/cassettes/localhost.yml" should exist
@@ -0,0 +1,80 @@
1
+ Feature: default_cassette_options configuration option
2
+
3
+ The `default_cassette_options` configuration option takes a hash
4
+ that provides defaults for each cassette you use. Any cassette
5
+ can override the defaults as well as set additional options.
6
+
7
+ The `:match_requests_on` option defaults to [:method, :uri] when
8
+ it has not been set.
9
+
10
+ Background:
11
+ Given a file named "vcr_setup.rb" with:
12
+ """
13
+ require 'vcr'
14
+
15
+ VCR.config do |c|
16
+ c.default_cassette_options = { :record => :new_episodes, :erb => true }
17
+
18
+ # not important for this example, but must be set to something
19
+ c.stub_with :webmock
20
+ c.cassette_library_dir = 'cassettes'
21
+ end
22
+ """
23
+
24
+ Scenario: cassettes get default values from configured default_cassette_options
25
+ Given a file named "default_cassette_options.rb" with:
26
+ """
27
+ require 'vcr_setup.rb'
28
+
29
+ VCR.use_cassette('example') do
30
+ puts "Record Mode: #{VCR.current_cassette.record_mode}"
31
+ puts "ERB: #{VCR.current_cassette.erb}"
32
+ end
33
+ """
34
+ When I run "ruby default_cassette_options.rb"
35
+ Then the output should contain:
36
+ """
37
+ Record Mode: new_episodes
38
+ ERB: true
39
+ """
40
+
41
+ Scenario: :match_requests_on defaults to [:method, :uri] when it has not been set
42
+ Given a file named "default_cassette_options.rb" with:
43
+ """
44
+ require 'vcr_setup.rb'
45
+
46
+ VCR.use_cassette('example') do
47
+ puts "Match Requests On: #{VCR.current_cassette.match_requests_on.inspect}"
48
+ end
49
+ """
50
+ When I run "ruby default_cassette_options.rb"
51
+ Then the output should contain "Match Requests On: [:method, :uri]"
52
+
53
+ Scenario: cassettes can set their own options
54
+ Given a file named "default_cassette_options.rb" with:
55
+ """
56
+ require 'vcr_setup.rb'
57
+
58
+ VCR.use_cassette('example', :re_record_interval => 10000) do
59
+ puts "Re-record Interval: #{VCR.current_cassette.re_record_interval}"
60
+ end
61
+ """
62
+ When I run "ruby default_cassette_options.rb"
63
+ Then the output should contain "Re-record Interval: 10000"
64
+
65
+ Scenario: cassettes can override default options
66
+ Given a file named "default_cassette_options.rb" with:
67
+ """
68
+ require 'vcr_setup.rb'
69
+
70
+ VCR.use_cassette('example', :record => :none, :erb => false) do
71
+ puts "Record Mode: #{VCR.current_cassette.record_mode}"
72
+ puts "ERB: #{VCR.current_cassette.erb}"
73
+ end
74
+ """
75
+ When I run "ruby default_cassette_options.rb"
76
+ Then the output should contain:
77
+ """
78
+ Record Mode: none
79
+ ERB: false
80
+ """
@@ -0,0 +1,103 @@
1
+ Feature: ignore_localhost configuration option
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
+ """
15
+ require 'vcr_cucumber_helpers'
16
+
17
+ response_count = 0
18
+ start_sinatra_app(:port => 7777) do
19
+ get('/') { "Response #{response_count += 1}" }
20
+ end
21
+ """
22
+
23
+ Scenario Outline: localhost requests are not treated differently by default and when the setting is false
24
+ Given a file named "localhost_not_ignored.rb" with:
25
+ """
26
+ require 'vcr_cucumber_helpers'
27
+ include_http_adapter_for("<http_lib>")
28
+ require 'sinatra_app.rb'
29
+
30
+ require 'vcr'
31
+
32
+ VCR.config do |c|
33
+ c.cassette_library_dir = 'cassettes'
34
+ c.stub_with <stub_with>
35
+ <additional_config>
36
+ end
37
+
38
+ VCR.use_cassette('localhost', :record => :new_episodes) do
39
+ response_body_for(:get, "http://localhost:7777/")
40
+ end
41
+
42
+ response_body_for(:get, "http://localhost:7777/")
43
+ """
44
+ When I run "ruby localhost_not_ignored.rb"
45
+ Then it should fail with "<error>"
46
+ And the file "cassettes/localhost.yml" should contain "body: Response 1"
47
+
48
+ Examples:
49
+ | stub_with | http_lib | error | additional_config |
50
+ | :fakeweb | net/http | Real HTTP connections are disabled | |
51
+ | :fakeweb | net/http | Real HTTP connections are disabled | c.ignore_localhost = false |
52
+ | :webmock | net/http | Real HTTP connections are disabled | |
53
+ | :webmock | net/http | Real HTTP connections are disabled | c.ignore_localhost = false |
54
+ | :webmock | httpclient | Real HTTP connections are disabled | |
55
+ | :webmock | httpclient | Real HTTP connections are disabled | c.ignore_localhost = false |
56
+ | :webmock | curb | Real HTTP connections are disabled | |
57
+ | :webmock | curb | Real HTTP connections are disabled | c.ignore_localhost = false |
58
+ | :webmock | patron | Real HTTP connections are disabled | |
59
+ | :webmock | patron | Real HTTP connections are disabled | c.ignore_localhost = false |
60
+ | :webmock | em-http-request | Real HTTP connections are disabled | |
61
+ | :webmock | em-http-request | Real HTTP connections are disabled | c.ignore_localhost = false |
62
+ | :typhoeus | typhoeus | Real HTTP requests are not allowed | |
63
+ | :typhoeus | typhoeus | Real HTTP requests are not allowed | c.ignore_localhost = false |
64
+
65
+ Scenario Outline: localhost requests are allowed and not recorded when ignore_localhost = true
66
+ Given a file named "ignore_localhost_true.rb" with:
67
+ """
68
+ require 'vcr_cucumber_helpers'
69
+ include_http_adapter_for("<http_lib>")
70
+ require 'sinatra_app.rb'
71
+
72
+ require 'vcr'
73
+
74
+ VCR.config do |c|
75
+ c.cassette_library_dir = 'cassettes'
76
+ c.stub_with <stub_with>
77
+ c.ignore_localhost = true
78
+ end
79
+
80
+ VCR.use_cassette('localhost', :record => :new_episodes) do
81
+ puts response_body_for(:get, "http://localhost:7777/")
82
+ end
83
+
84
+ puts response_body_for(:get, "http://localhost:7777/")
85
+ """
86
+ When I run "ruby ignore_localhost_true.rb"
87
+ Then it should pass with:
88
+ """
89
+ Response 1
90
+ Response 2
91
+ """
92
+ And the file "cassettes/localhost.yml" should not exist
93
+
94
+ Examples:
95
+ | stub_with | http_lib |
96
+ | :fakeweb | net/http |
97
+ | :webmock | net/http |
98
+ | :webmock | httpclient |
99
+ | :webmock | patron |
100
+ | :webmock | curb |
101
+ | :webmock | em-http-request |
102
+ | :typhoeus | typhoeus |
103
+
@@ -0,0 +1,164 @@
1
+ Feature: stub_with configuration option
2
+
3
+ The `stub_with` configuration option determines which HTTP stubbing library
4
+ VCR will use. There are currently 3 supported stubbing libraries which
5
+ support 6 different HTTP libraries:
6
+
7
+ * FakeWeb can be used to stub Net::HTTP.
8
+ * WebMock can be used to stub:
9
+ * Net::HTTP
10
+ * HTTPClient
11
+ * Patron
12
+ * Curb
13
+ * EM HTTP Request
14
+ * Typhoeus can be used to stub itself.
15
+
16
+ There are some addiitonal trade offs to consider when deciding which
17
+ stubbing library to use:
18
+
19
+ * FakeWeb does not allow you to stub a request based on the headers or body.
20
+ Therefore, the `:match_requests_on` option does not support `:body` or
21
+ `:headers` when you use FakeWeb. Typhoeus and WebMock both support
22
+ matching on `:body` and `:headers`.
23
+ * FakeWeb is currently about 4 times faster than WebMock for stubbing
24
+ Net::HTTP (see benchmarks/http_stubbing_libraries.rb for details).
25
+ * FakeWeb and WebMock both use extensive monkey patching to stub their
26
+ supported HTTP libraries. Typhoeus provides all the necessary
27
+ stubbing and recording integration points, and no monkey patching
28
+ is required at all.
29
+ * Typhoeus can be used together with either FakeWeb or WebMock.
30
+ * FakeWeb and WebMock cannot both be used.
31
+
32
+ Regardless of which library you use, VCR takes care of all of the configuration
33
+ 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 libraries
35
+ (i.e. if you initially use FakeWeb because it's faster but later need the
36
+ additional features of WebMock) you can change the `stub_with` configuration
37
+ option and it'll work with no other changes required.
38
+
39
+ Scenario Outline: stub_with loads the given HTTP stubbing library
40
+ Given a file named "vcr_stub_with.rb" with:
41
+ """
42
+ require 'vcr'
43
+
44
+ VCR.config do |c|
45
+ c.stub_with <stub_with>
46
+ end
47
+
48
+ puts "FakeWeb Loaded: #{!!defined?(FakeWeb)}"
49
+ puts "WebMock Loaded: #{!!defined?(WebMock)}"
50
+ puts "Typhoeus Loaded: #{!!defined?(Typhoeus)}"
51
+ """
52
+ When I run "ruby vcr_stub_with.rb"
53
+ Then the output should contain:
54
+ """
55
+ FakeWeb Loaded: <fakeweb_loaded>
56
+ WebMock Loaded: <webmock_loaded>
57
+ Typhoeus Loaded: <typhoeus_loaded>
58
+ """
59
+
60
+ Examples:
61
+ | stub_with | fakeweb_loaded | webmock_loaded | typhoeus_loaded |
62
+ | :fakeweb | true | false | false |
63
+ | :webmock | false | true | false |
64
+ | :typhoeus | false | false | true |
65
+
66
+ Scenario Outline: Record and replay a request using each supported stubbing/http library combination
67
+ Given a file named "stubbing_http_lib_combo.rb" with:
68
+ """
69
+ require 'vcr_cucumber_helpers'
70
+ include_http_adapter_for("<http_lib>")
71
+
72
+ start_sinatra_app(:port => 7777) do
73
+ get('/') { ARGV[0] }
74
+ end
75
+
76
+ puts "The response for request 1 was: #{response_body_for(:get, "http://localhost:7777/")}"
77
+
78
+ require 'vcr'
79
+
80
+ VCR.config do |c|
81
+ c.stub_with <stub_with>
82
+ c.cassette_library_dir = 'vcr_cassettes'
83
+ end
84
+
85
+ VCR.use_cassette('example', :record => :new_episodes) do
86
+ puts "The response for request 2 was: #{response_body_for(:get, "http://localhost:7777/")}"
87
+ end
88
+ """
89
+ When I run "ruby stubbing_http_lib_combo.rb 'Hello World'"
90
+ Then the output should contain each of the following:
91
+ | The response for request 1 was: Hello World |
92
+ | The response for request 2 was: Hello World |
93
+ And the file "vcr_cassettes/example.yml" should contain "body: Hello World"
94
+
95
+ When I run "ruby stubbing_http_lib_combo.rb 'Goodbye World'"
96
+ Then the output should contain each of the following:
97
+ | The response for request 1 was: Goodbye World |
98
+ | The response for request 2 was: Hello World |
99
+ And the file "vcr_cassettes/example.yml" should contain "body: Hello World"
100
+
101
+ Examples:
102
+ | stub_with | http_lib |
103
+ | :fakeweb | net/http |
104
+ | :webmock | net/http |
105
+ | :webmock | httpclient |
106
+ | :webmock | patron |
107
+ | :webmock | curb |
108
+ | :webmock | em-http-request |
109
+ | :typhoeus | typhoeus |
110
+
111
+ @exclude-jruby
112
+ Scenario Outline: Use Typhoeus in combination with FakeWeb or WebMock
113
+ Given a file named "stub_with_multiple.rb" with:
114
+ """
115
+ require 'vcr_cucumber_helpers'
116
+ require 'typhoeus'
117
+
118
+ start_sinatra_app(:port => 7777) do
119
+ get('/:path') { "#{ARGV[0]} #{params[:path]}" }
120
+ end
121
+
122
+ def net_http_response
123
+ Net::HTTP.get_response('localhost', '/net_http', 7777).body
124
+ end
125
+
126
+ def typhoeus_response
127
+ Typhoeus::Request.get("http://localhost:7777/typhoeus").body
128
+ end
129
+
130
+ puts "Net::HTTP 1: #{net_http_response}"
131
+ puts "Typhoeus 1: #{typhoeus_response}"
132
+
133
+ require 'vcr'
134
+
135
+ VCR.config do |c|
136
+ c.stub_with <stub_with>, :typhoeus
137
+ c.cassette_library_dir = 'vcr_cassettes'
138
+ end
139
+
140
+ VCR.use_cassette('example', :record => :new_episodes) do
141
+ puts "Net::HTTP 2: #{net_http_response}"
142
+ puts "Typhoeus 2: #{typhoeus_response}"
143
+ end
144
+ """
145
+ When I run "ruby stub_with_multiple.rb 'Hello'"
146
+ Then the output should contain each of the following:
147
+ | Net::HTTP 1: Hello net_http |
148
+ | Typhoeus 1: Hello typhoeus |
149
+ | Net::HTTP 2: Hello net_http |
150
+ | Typhoeus 2: Hello typhoeus |
151
+ And the file "vcr_cassettes/example.yml" should contain "body: Hello net_http"
152
+ And the file "vcr_cassettes/example.yml" should contain "body: Hello typhoeus"
153
+
154
+ When I run "ruby stub_with_multiple.rb 'Goodbye'"
155
+ Then the output should contain each of the following:
156
+ | Net::HTTP 1: Goodbye net_http |
157
+ | Typhoeus 1: Goodbye typhoeus |
158
+ | Net::HTTP 2: Hello net_http |
159
+ | Typhoeus 2: Hello typhoeus |
160
+
161
+ Examples:
162
+ | stub_with |
163
+ | :fakeweb |
164
+ | :webmock |
@@ -0,0 +1,137 @@
1
+ Feature: Net::HTTP
2
+
3
+ There are many ways to use Net::HTTP. The scenarios below provide regression
4
+ tests for some Net::HTTP APIs that have not worked properly with VCR and
5
+ FakeWeb or WebMock in the past (but have since been fixed).
6
+
7
+ Background:
8
+ Given a file named "vcr_setup.rb" with:
9
+ """
10
+ require 'vcr_cucumber_helpers'
11
+
12
+ if ARGV[0] == '--with-server'
13
+ start_sinatra_app(:port => 7777) do
14
+ get('/') { 'VCR works with Net::HTTP gets!' }
15
+ post('/') { 'VCR works with Net::HTTP posts!' }
16
+ end
17
+ end
18
+
19
+ require 'vcr'
20
+ """
21
+
22
+ Scenario Outline: Calling #post on new Net::HTTP instance
23
+ Given a file named "vcr_net_http.rb" with:
24
+ """
25
+ require 'vcr_setup.rb'
26
+
27
+ VCR.config do |c|
28
+ c.stub_with <stub_with>
29
+ c.cassette_library_dir = 'cassettes'
30
+ end
31
+
32
+ VCR.use_cassette('net_http', :record => :new_episodes) do
33
+ puts Net::HTTP.new('localhost', 7777).post('/', '').body
34
+ end
35
+ """
36
+ When I run "ruby vcr_net_http.rb --with-server"
37
+ Then the output should contain "VCR works with Net::HTTP posts!"
38
+ And the file "cassettes/net_http.yml" should contain "body: VCR works with Net::HTTP posts!"
39
+
40
+ When I run "ruby vcr_net_http.rb"
41
+ Then the output should contain "VCR works with Net::HTTP posts!"
42
+
43
+ Examples:
44
+ | stub_with |
45
+ | :fakeweb |
46
+ | :webmock |
47
+
48
+ Scenario Outline: Return from yielded block
49
+ Given a file named "vcr_net_http.rb" with:
50
+ """
51
+ require 'vcr_setup.rb'
52
+
53
+ VCR.config do |c|
54
+ c.stub_with <stub_with>
55
+ c.cassette_library_dir = 'cassettes'
56
+ end
57
+
58
+ def perform_request
59
+ Net::HTTP.new('localhost', 7777).request(Net::HTTP::Get.new('/', {})) do |response|
60
+ return response
61
+ end
62
+ end
63
+
64
+ VCR.use_cassette('net_http', :record => :new_episodes) do
65
+ puts perform_request.body
66
+ end
67
+ """
68
+ When I run "ruby vcr_net_http.rb --with-server"
69
+ Then the output should contain "VCR works with Net::HTTP gets!"
70
+ And the file "cassettes/net_http.yml" should contain "body: VCR works with Net::HTTP gets!"
71
+
72
+ When I run "ruby vcr_net_http.rb"
73
+ Then the output should contain "VCR works with Net::HTTP gets!"
74
+
75
+ Examples:
76
+ | stub_with |
77
+ | :fakeweb |
78
+ | :webmock |
79
+
80
+ Scenario Outline: Use Net::ReadAdapter to read body in fragments
81
+ Given a file named "vcr_net_http.rb" with:
82
+ """
83
+ require 'vcr_setup.rb'
84
+
85
+ VCR.config do |c|
86
+ c.stub_with <stub_with>
87
+ c.cassette_library_dir = 'cassettes'
88
+ end
89
+
90
+ VCR.use_cassette('net_http', :record => :new_episodes) do
91
+ body = ''
92
+
93
+ Net::HTTP.new('localhost', 7777).request_get('/') do |response|
94
+ response.read_body { |frag| body << frag }
95
+ end
96
+
97
+ puts body
98
+ end
99
+ """
100
+ When I run "ruby vcr_net_http.rb --with-server"
101
+ Then the output should contain "VCR works with Net::HTTP gets!"
102
+ And the file "cassettes/net_http.yml" should contain "body: VCR works with Net::HTTP gets!"
103
+
104
+ When I run "ruby vcr_net_http.rb"
105
+ Then the output should contain "VCR works with Net::HTTP gets!"
106
+
107
+ Examples:
108
+ | stub_with |
109
+ | :fakeweb |
110
+ | :webmock |
111
+
112
+ Scenario Outline: Use open-uri (which is built on top of Net::HTTP and uses a seldom-used Net::HTTP API)
113
+ Given a file named "vcr_net_http.rb" with:
114
+ """
115
+ require 'open-uri'
116
+ require 'vcr_setup.rb'
117
+
118
+ VCR.config do |c|
119
+ c.stub_with <stub_with>
120
+ c.cassette_library_dir = 'cassettes'
121
+ end
122
+
123
+ VCR.use_cassette('net_http', :record => :new_episodes) do
124
+ puts open('http://localhost:7777/').read
125
+ end
126
+ """
127
+ When I run "ruby vcr_net_http.rb --with-server"
128
+ Then the output should contain "VCR works with Net::HTTP gets!"
129
+ And the file "cassettes/net_http.yml" should contain "body: VCR works with Net::HTTP gets!"
130
+
131
+ When I run "ruby vcr_net_http.rb"
132
+ Then the output should contain "VCR works with Net::HTTP gets!"
133
+
134
+ Examples:
135
+ | stub_with |
136
+ | :fakeweb |
137
+ | :webmock |