vcr 1.1.2 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. data/.gitignore +1 -1
  2. data/.gitmodules +3 -0
  3. data/CHANGELOG.md +58 -1
  4. data/Gemfile +2 -4
  5. data/Gemfile.lock +26 -49
  6. data/README.md +92 -23
  7. data/Rakefile +6 -3
  8. data/features/fixtures/vcr_cassettes/1.9.1/record_all.yml +62 -0
  9. data/features/fixtures/vcr_cassettes/not_1.9.1/record_all.yml +61 -0
  10. data/features/http_client.feature +2 -2
  11. data/features/net_http.feature +15 -4
  12. data/features/record_response.feature +36 -7
  13. data/features/replay_recorded_response.feature +8 -8
  14. data/features/rspec.feature +100 -0
  15. data/features/step_definitions/net_http_steps.rb +13 -1
  16. data/features/step_definitions/vcr_steps.rb +26 -16
  17. data/features/support/env.rb +13 -5
  18. data/features/webmock.feature +4 -4
  19. data/lib/vcr.rb +5 -5
  20. data/lib/vcr/cassette.rb +55 -19
  21. data/lib/vcr/extensions/net_http.rb +2 -4
  22. data/lib/vcr/http_stubbing_adapters/fakeweb.rb +0 -4
  23. data/lib/vcr/http_stubbing_adapters/webmock.rb +2 -9
  24. data/lib/vcr/internet_connection.rb +13 -0
  25. data/lib/vcr/ping.rb +26 -0
  26. data/lib/vcr/rspec.rb +39 -0
  27. data/lib/vcr/version.rb +1 -1
  28. data/spec/cassette_spec.rb +160 -69
  29. data/spec/config_spec.rb +1 -1
  30. data/spec/cucumber_tags_spec.rb +3 -2
  31. data/spec/deprecations_spec.rb +1 -1
  32. data/spec/extensions/net_http_response_spec.rb +2 -4
  33. data/spec/extensions/net_http_spec.rb +3 -1
  34. data/spec/fixtures/1.9.1/cassette_spec/with_localhost_requests.yml +23 -0
  35. data/spec/fixtures/not_1.9.1/cassette_spec/with_localhost_requests.yml +23 -0
  36. data/spec/http_stubbing_adapters/fakeweb_spec.rb +3 -9
  37. data/spec/http_stubbing_adapters/webmock_spec.rb +7 -18
  38. data/spec/internet_connection_spec.rb +19 -0
  39. data/spec/monkey_patches.rb +45 -6
  40. data/spec/request_matcher_spec.rb +1 -1
  41. data/spec/rspec_spec.rb +46 -0
  42. data/spec/spec_helper.rb +6 -11
  43. data/spec/structs_spec.rb +1 -1
  44. data/spec/support/fixnum_extension.rb +10 -0
  45. data/spec/support/http_library_adapters.rb +31 -2
  46. data/spec/support/ruby_interpreter.rb +7 -0
  47. data/spec/support/vcr_localhost_server.rb +86 -44
  48. data/spec/support/webmock_macros.rb +14 -0
  49. data/spec/vcr_spec.rb +1 -1
  50. data/spec/version_spec.rb +1 -1
  51. data/vcr.gemspec +10 -6
  52. metadata +155 -39
@@ -1,3 +1,5 @@
1
+ require 'open-uri'
2
+
1
3
  module NetHTTPHelpers
2
4
  def perform_net_http_get_with_returning_block(uri, path)
3
5
  Net::HTTP.new(uri.host, uri.port).request(Net::HTTP::Get.new(path, {})) do |response|
@@ -34,4 +36,14 @@ When /^I make a returning block Net::HTTP get request to "([^\"]*)"$/ do |url|
34
36
  capture_response(url) do |uri, path|
35
37
  perform_net_http_get_with_returning_block(uri, path)
36
38
  end
37
- end
39
+ end
40
+
41
+ When /^I make an open uri Net::HTTP get request to "([^"]*)"$/ do |url|
42
+ capture_response(url) do |uri, path|
43
+ result = open(url)
44
+ # #open returns a StringIO rather than a Net::HTTPResponse, so we add #body to make it conform to the same interface
45
+ def result.body; read; end
46
+ result
47
+ end
48
+ end
49
+
@@ -74,9 +74,11 @@ module VCRHelpers
74
74
  end
75
75
 
76
76
  def recorded_interactions_for(cassette_name)
77
- yaml_file = File.join(VCR::Config.cassette_library_dir, "#{cassette_name}.yml")
78
- yaml = File.open(yaml_file, 'r') { |f| f.read }
79
- interactions = YAML.load(yaml)
77
+ interactions = YAML.load(File.read(file_name(cassette_name)))
78
+ end
79
+
80
+ def file_name(cassette_name)
81
+ File.join(VCR::Config.cassette_library_dir, "#{cassette_name}.yml")
80
82
  end
81
83
 
82
84
  def capture_response(url)
@@ -95,12 +97,11 @@ end
95
97
  World(VCRHelpers)
96
98
 
97
99
  Given /^we do not have a "([^\"]*)" cassette$/ do |cassette_name|
98
- fixture_file = File.join(VCR::Config.cassette_library_dir, "#{cassette_name}.yml")
99
- File.exist?(fixture_file).should be_false
100
+ File.exist?(file_name(cassette_name)).should be_false
100
101
  end
101
102
 
102
- Given /^we have a "([^\"]*)" library file with (a|no) previously recorded response for "([^\"]*)"$/ do |file_name, a_or_no, url|
103
- fixture_file = File.join(VCR::Config.cassette_library_dir, "#{file_name}.yml")
103
+ Given /^we have a "([^\"]*)" library file with (a|no) previously recorded response for "([^\"]*)"$/ do |cassette_name, a_or_no, url|
104
+ fixture_file = file_name(cassette_name)
104
105
  File.exist?(fixture_file).should be_true
105
106
  responses = File.open(fixture_file, 'r') { |f| YAML.load(f.read) }
106
107
  should_method = a_or_no == 'a' ? :should : :should_not
@@ -154,7 +155,7 @@ When /^I make an HTTP post request to "([^"]*)" with request header "([^"]*)=([^
154
155
  end
155
156
  end
156
157
 
157
- When /^I make (.*) requests? to "([^\"]*)"(?: and "([^\"]*)")? within the "([^\"]*)" cassette(?: using cassette options: (.*))?$/ do |http_request_type, url1, url2, cassette_name, options|
158
+ When /^I make (.*) requests? to "([^\"]*)"(?: and "([^\"]*)")? while using the "([^\"]*)" cassette(?: using cassette options: (.*))?$/ do |http_request_type, url1, url2, cassette_name, options|
158
159
  options = options.to_s == '' ? { :record => :new_episodes } : eval(options)
159
160
  urls = [url1, url2].select { |u| u.to_s.size > 0 }
160
161
  VCR.use_cassette(cassette_name, options) do
@@ -164,23 +165,24 @@ When /^I make (.*) requests? to "([^\"]*)"(?: and "([^\"]*)")? within the "([^\"
164
165
  end
165
166
  end
166
167
 
167
- When /^I make an HTTP post request to "([^"]*)" with request body "([^"]*)" within the "([^"]*)" cassette(?: using cassette options: (.*))?$/ do |url, request_body, cassette_name, options|
168
+ When /^I make an HTTP post request to "([^"]*)" with request body "([^"]*)" while using the "([^"]*)" cassette(?: using cassette options: (.*))?$/ do |url, request_body, cassette_name, options|
168
169
  options = options.to_s == '' ? { :record => :new_episodes } : eval(options)
169
170
  VCR.use_cassette(cassette_name, options) do
170
171
  When %{I make an HTTP post request to "#{url}" with request body "#{request_body}"}
171
172
  end
172
173
  end
173
174
 
174
- When /^I make an HTTP post request to "([^"]*)" with request header "([^"]*)=([^"]*)" within the "([^"]*)" cassette(?: using cassette options: (.*))?$/ do |url, header_key, header_value, cassette_name, options|
175
+ When /^I make an HTTP post request to "([^"]*)" with request header "([^"]*)=([^"]*)" while using the "([^"]*)" cassette(?: using cassette options: (.*))?$/ do |url, header_key, header_value, cassette_name, options|
175
176
  options = options.to_s == '' ? { :record => :new_episodes } : eval(options)
176
177
  VCR.use_cassette(cassette_name, options) do
177
178
  When %{I make an HTTP post request to "#{url}" with request header "#{header_key}=#{header_value}"}
178
179
  end
179
180
  end
180
181
 
181
- Then /^the "([^\"]*)" library file should have a response for "([^\"]*)" that matches \/(.+)\/$/ do |cassette_name, url, regex_str|
182
+ Then /^the "([^\"]*)" library file (should(?: not)?) have a response for "([^\"]*)" that matches \/(.+)\/$/ do |cassette_name, expectation, url, regex_str|
183
+ expectation = expectation.gsub(' ', '_')
182
184
  interactions = recorded_interactions_for(cassette_name)
183
- interactions.should have_expected_response(regex_str, :url => url)
185
+ interactions.send(expectation, have_expected_response(regex_str, :url => url))
184
186
  end
185
187
 
186
188
  Then /^the "([^\"]*)" library file should have exactly (\d+) response$/ do |cassette_name, response_count|
@@ -216,8 +218,7 @@ Then /^(?:the )?response(?: (\d+))? for "([^\"]*)" should match \/(.+)\/$/ do |r
216
218
  end
217
219
 
218
220
  Then /^there should not be a "([^\"]*)" library file$/ do |cassette_name|
219
- yaml_file = File.join(VCR::Config.cassette_library_dir, "#{cassette_name}.yml")
220
- File.exist?(yaml_file).should be_false
221
+ File.exist?(file_name(cassette_name)).should be_false
221
222
  end
222
223
 
223
224
  Given /^the ignore_localhost config setting is set to (true|false)$/ do |value|
@@ -228,8 +229,8 @@ Given /^a rack app is running on localhost that returns "([^"]+)" for all reques
228
229
  @rack_server = static_rack_server(response_string)
229
230
  end
230
231
 
231
- When /^I make an HTTP get request to the localhost rack app within the "([^\"]*)" cassette$/ do |cassette|
232
- When %{I make an HTTP get request to "http://localhost:#{@rack_server.port}/" within the "#{cassette}" cassette}
232
+ When /^I make an HTTP get request to the localhost rack app while using the "([^\"]*)" cassette$/ do |cassette|
233
+ When %{I make an HTTP get request to "http://localhost:#{@rack_server.port}/" while using the "#{cassette}" cassette}
233
234
  end
234
235
 
235
236
  Then /^the response for the localhost rack app should match \/(.*)\/$/ do |regex|
@@ -240,3 +241,12 @@ Given /^the "([^\"]*)" library file has a response for localhost that matches \/
240
241
  port = static_rack_server('localhost response').port
241
242
  Given %{the "#{cassette}" library file has a response for "http://localhost:#{port}/" that matches /#{regex}/}
242
243
  end
244
+
245
+ Given /^(\d+) days have passed since the "([^"]*)" library file last changed$/ do |day_count, file|
246
+ last_changed_at = File.new(file_name(file)).mtime
247
+ Timecop.travel(last_changed_at + day_count.to_i.days)
248
+ end
249
+
250
+ Given /the following files do not exist:/ do |files|
251
+ check_file_presence(files.raw.map{|file_row| file_row[0]}, false)
252
+ end
@@ -19,12 +19,17 @@ World(HTTP_LIBRARY_ADAPTERS[ENV['HTTP_LIB']])
19
19
  puts "\n\n---------------- Running features using #{ENV['HTTP_STUBBING_ADAPTER']} and #{ENV['HTTP_LIB']} -----------------\n"
20
20
 
21
21
  require 'vcr'
22
+ require 'ruby_interpreter'
22
23
  require 'vcr_localhost_server'
24
+ require 'fixnum_extension'
23
25
 
24
26
  require 'rubygems'
25
27
  require 'bundler'
26
28
  Bundler.setup
27
29
 
30
+ require 'aruba'
31
+ require 'timecop'
32
+
28
33
  begin
29
34
  require 'ruby-debug'
30
35
  Debugger.start
@@ -52,6 +57,7 @@ VCR.module_eval do
52
57
  end
53
58
 
54
59
  After do |scenario|
60
+ Timecop.return
55
61
  if raised_error = (@http_requests || {}).values.flatten.detect { |result| result.is_a?(Exception) && result.message !~ /VCR/ }
56
62
  raise raised_error
57
63
  end
@@ -66,11 +72,13 @@ Before do |scenario|
66
72
  FileUtils.rm_rf(temp_dir) if File.exist?(temp_dir)
67
73
  end
68
74
 
69
- Before('@copy_not_the_real_response_to_temp') do
70
- orig_file = File.join(VCR::Config.cassette_library_dir, 'not_the_real_response.yml')
71
- temp_file = File.join(VCR::Config.cassette_library_dir, 'temp', 'not_the_real_response.yml')
72
- FileUtils.mkdir_p(File.join(VCR::Config.cassette_library_dir, 'temp'))
73
- FileUtils.cp orig_file, temp_file
75
+ %w[not_the_real_response record_all].each do |cassette|
76
+ Before("@copy_#{cassette}_to_temp") do
77
+ orig_file = File.join(VCR::Config.cassette_library_dir, "#{cassette}.yml")
78
+ temp_file = File.join(VCR::Config.cassette_library_dir, 'temp', "#{cassette}.yml")
79
+ FileUtils.mkdir_p(File.join(VCR::Config.cassette_library_dir, 'temp'))
80
+ FileUtils.cp orig_file, temp_file
81
+ end
74
82
  end
75
83
 
76
84
  Before('@create_replay_localhost_cassette') do
@@ -6,21 +6,21 @@ Feature: Replay recorded response
6
6
 
7
7
  Scenario: Use the :match_requests_on option to differentiate requests by request body (for "foo=bar")
8
8
  Given the "match_requests_on" library file has a response for "http://example.com/" with the request body "foo=bar" that matches /foo=bar response/
9
- When I make an HTTP post request to "http://example.com/" with request body "foo=bar" within the "match_requests_on" cassette using cassette options: { :match_requests_on => [:uri, :body], :record => :none }
9
+ When I make an HTTP post request to "http://example.com/" with request body "foo=bar" while using the "match_requests_on" cassette using cassette options: { :match_requests_on => [:uri, :body], :record => :none }
10
10
  Then the response for "http://example.com/" should match /foo=bar response/
11
11
 
12
12
  Scenario: Use the :match_requests_on option to differentiate requests by request body (for "bar=bazz")
13
13
  Given the "match_requests_on" library file has a response for "http://example.com/" with the request body "bar=bazz" that matches /bar=bazz response/
14
- When I make an HTTP post request to "http://example.com/" with request body "bar=bazz" within the "match_requests_on" cassette using cassette options: { :match_requests_on => [:uri, :body], :record => :none }
14
+ When I make an HTTP post request to "http://example.com/" with request body "bar=bazz" while using the "match_requests_on" cassette using cassette options: { :match_requests_on => [:uri, :body], :record => :none }
15
15
  Then the response for "http://example.com/" should match /bar=bazz response/
16
16
 
17
17
  Scenario: Use the :match_requests_on option to differentiate requests by request header (for "X-HTTP-USER=joe")
18
18
  Given the "match_requests_on" library file has a response for "http://example.com/" with the request header "X-HTTP-USER=joe" that matches /joe response/
19
- When I make an HTTP post request to "http://example.com/" with request header "X-HTTP-USER=joe" within the "match_requests_on" cassette using cassette options: { :match_requests_on => [:uri, :headers], :record => :none }
19
+ When I make an HTTP post request to "http://example.com/" with request header "X-HTTP-USER=joe" while using the "match_requests_on" cassette using cassette options: { :match_requests_on => [:uri, :headers], :record => :none }
20
20
  Then the response for "http://example.com/" should match /joe response/
21
21
 
22
22
  Scenario: Use the :match_requests_on option to differentiate requests by request header (for "X-HTTP-USER=bob")
23
23
  Given the "match_requests_on" library file has a response for "http://example.com/" with the request header "X-HTTP-USER=bob" that matches /bob response/
24
- When I make an HTTP post request to "http://example.com/" with request header "X-HTTP-USER=bob" within the "match_requests_on" cassette using cassette options: { :match_requests_on => [:uri, :headers], :record => :none }
24
+ When I make an HTTP post request to "http://example.com/" with request header "X-HTTP-USER=bob" while using the "match_requests_on" cassette using cassette options: { :match_requests_on => [:uri, :headers], :record => :none }
25
25
  Then the response for "http://example.com/" should match /bob response/
26
26
 
data/lib/vcr.rb CHANGED
@@ -1,19 +1,19 @@
1
1
  require 'vcr/cassette'
2
2
  require 'vcr/config'
3
- require 'vcr/cucumber_tags'
4
3
  require 'vcr/deprecations'
5
4
  require 'vcr/request_matcher'
6
5
  require 'vcr/structs'
7
6
  require 'vcr/version'
8
-
9
- require 'vcr/extensions/net_http_response'
10
-
11
7
  require 'vcr/http_stubbing_adapters/common'
12
8
 
13
9
  module VCR
14
10
  extend self
15
11
 
16
- LOCALHOST_ALIASES = %w( localhost 127.0.0.1 )
12
+ autoload :CucumberTags, 'vcr/cucumber_tags'
13
+ autoload :InternetConnection, 'vcr/internet_connection'
14
+ autoload :RSpec, 'vcr/rspec'
15
+
16
+ LOCALHOST_ALIASES = %w( localhost 127.0.0.1 0.0.0.0 )
17
17
 
18
18
  def current_cassette
19
19
  cassettes.last
data/lib/vcr/cassette.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'fileutils'
2
2
  require 'yaml'
3
3
  require 'erb'
4
+ require 'set'
4
5
 
5
6
  module VCR
6
7
  class Cassette
@@ -12,13 +13,18 @@ module VCR
12
13
 
13
14
  def initialize(name, options = {})
14
15
  options = VCR::Config.default_cassette_options.merge(options)
15
- invalid_options = options.keys - [:record, :erb, :allow_real_http, :match_requests_on]
16
+ invalid_options = options.keys - [:record, :erb, :allow_real_http, :match_requests_on, :re_record_interval]
16
17
 
17
18
  if invalid_options.size > 0
18
19
  raise ArgumentError.new("You passed the following invalid options to VCR::Cassette.new: #{invalid_options.inspect}.")
19
20
  end
20
21
 
21
- @name, @record_mode, @erb, @match_requests_on = name, options[:record], options[:erb], options[:match_requests_on]
22
+ @name = name
23
+ @record_mode = options[:record]
24
+ @erb = options[:erb]
25
+ @match_requests_on = options[:match_requests_on]
26
+ @re_record_interval = options[:re_record_interval]
27
+ @record_mode = :all if should_re_record?
22
28
 
23
29
  deprecate_old_cassette_options(options)
24
30
  raise_error_unless_valid_record_mode(record_mode)
@@ -39,7 +45,11 @@ module VCR
39
45
  end
40
46
 
41
47
  def record_http_interaction(interaction)
42
- recorded_interactions << interaction
48
+ new_recorded_interactions << interaction
49
+ end
50
+
51
+ def new_recorded_interactions
52
+ @new_recorded_interactions ||= []
43
53
  end
44
54
 
45
55
  def file
@@ -58,12 +68,23 @@ module VCR
58
68
  end
59
69
  end
60
70
 
61
- def new_recorded_interactions
62
- recorded_interactions - @original_recorded_interactions
71
+ def should_re_record?
72
+ @re_record_interval &&
73
+ File.exist?(file) &&
74
+ File.stat(file).mtime + @re_record_interval < Time.now &&
75
+ InternetConnection.available?
63
76
  end
64
77
 
65
78
  def should_allow_http_connections?
66
- [:new_episodes, :all].include?(record_mode)
79
+ record_mode != :none
80
+ end
81
+
82
+ def should_stub_requests?
83
+ record_mode != :all
84
+ end
85
+
86
+ def should_remove_matching_existing_interactions?
87
+ record_mode == :all
67
88
  end
68
89
 
69
90
  def set_http_connections_allowed
@@ -77,11 +98,9 @@ module VCR
77
98
 
78
99
  def load_recorded_interactions
79
100
  VCR.http_stubbing_adapter.create_stubs_checkpoint(name)
80
- @original_recorded_interactions = []
81
- return if record_mode == :all
82
101
 
83
- if file
84
- @original_recorded_interactions = begin
102
+ if file && File.exist?(file)
103
+ begin
85
104
  interactions = YAML.load(raw_yaml_content)
86
105
 
87
106
  if VCR.http_stubbing_adapter.ignore_localhost?
@@ -90,16 +109,16 @@ module VCR
90
109
  end
91
110
  end
92
111
 
93
- interactions
112
+ recorded_interactions.replace(interactions)
94
113
  rescue TypeError
95
114
  raise unless raw_yaml_content =~ /VCR::RecordedResponse/
96
115
  raise "The VCR cassette #{sanitized_name}.yml uses an old format that is now deprecated. VCR provides a rake task to migrate your old cassettes to the new format. See http://github.com/myronmarston/vcr/blob/master/CHANGELOG.md for more info."
97
- end if File.exist?(file)
98
-
99
- recorded_interactions.replace(@original_recorded_interactions)
116
+ end
100
117
  end
101
118
 
102
- VCR.http_stubbing_adapter.stub_requests(recorded_interactions, match_requests_on)
119
+ if should_stub_requests?
120
+ VCR.http_stubbing_adapter.stub_requests(recorded_interactions, match_requests_on)
121
+ end
103
122
  end
104
123
 
105
124
  @@struct_cache = Hash.new do |hash, attributes|
@@ -121,21 +140,38 @@ module VCR
121
140
  # instance_eval seems to be the only way to get the binding for ruby 1.9: http://redmine.ruby-lang.org/issues/show/2161
122
141
  template.result(local_variables.instance_eval { binding })
123
142
  rescue NameError => e
124
- var_name = e.message[/undefined local variable or method `(.*)' for/, 1].to_sym
125
- example_hash = (@erb.is_a?(Hash) ? @erb : {}).merge(var_name => 'some value')
143
+ example_hash = (@erb.is_a?(Hash) ? @erb : {}).merge(e.name => 'some value')
126
144
 
127
145
  raise MissingERBVariableError.new(
128
- "The ERB in the #{sanitized_name}.yml cassette file references undefined variable #{var_name}. " +
146
+ "The ERB in the #{sanitized_name}.yml cassette file references undefined variable #{e.name}. " +
129
147
  "Pass it to the cassette using :erb => #{ example_hash.inspect }."
130
148
  )
131
149
  end
132
150
  end
133
151
 
152
+ def merged_interactions
153
+ old_interactions = recorded_interactions
154
+
155
+ if should_remove_matching_existing_interactions?
156
+ match_attributes = match_requests_on
157
+
158
+ new_request_matchers = Set.new new_recorded_interactions.map do |i|
159
+ i.request.matcher(match_attributes)
160
+ end
161
+
162
+ old_interactions = old_interactions.reject do |i|
163
+ new_request_matchers.include?(i.request.matcher(match_attributes))
164
+ end
165
+ end
166
+
167
+ old_interactions + new_recorded_interactions
168
+ end
169
+
134
170
  def write_recorded_interactions_to_disk
135
171
  if VCR::Config.cassette_library_dir && new_recorded_interactions.size > 0
136
172
  directory = File.dirname(file)
137
173
  FileUtils.mkdir_p directory unless File.exist?(directory)
138
- File.open(file, 'w') { |f| f.write recorded_interactions.to_yaml }
174
+ File.open(file, 'w') { |f| f.write merged_interactions.to_yaml }
139
175
  end
140
176
  end
141
177
  end
@@ -1,4 +1,5 @@
1
1
  require 'net/http'
2
+ require 'vcr/extensions/net_http_response'
2
3
 
3
4
  module Net
4
5
  class HTTP
@@ -9,10 +10,7 @@ module Net
9
10
  match_attributes = (cass = VCR.current_cassette) ? cass.match_requests_on : VCR::RequestMatcher::DEFAULT_MATCH_ATTRIBUTES
10
11
  if started? && !VCR.http_stubbing_adapter.request_stubbed?(vcr_request, match_attributes)
11
12
  VCR.record_http_interaction VCR::HTTPInteraction.new(vcr_request, VCR::Response.from_net_http_response(response))
12
-
13
- if VCR.http_stubbing_adapter.should_unwind_response?(response)
14
- response.extend VCR::Net::HTTPResponse # "unwind" the response
15
- end
13
+ response.extend VCR::Net::HTTPResponse # "unwind" the response
16
14
  end
17
15
 
18
16
  yield response if block_given?
@@ -64,10 +64,6 @@ module VCR
64
64
  @ignore_localhost
65
65
  end
66
66
 
67
- def should_unwind_response?(response)
68
- true
69
- end
70
-
71
67
  private
72
68
 
73
69
  def version
@@ -1,5 +1,4 @@
1
1
  require 'webmock'
2
- require 'vcr/extensions/net_http'
3
2
 
4
3
  module VCR
5
4
  module HttpStubbingAdapters
@@ -7,7 +6,7 @@ module VCR
7
6
  include VCR::HttpStubbingAdapters::Common
8
7
  extend self
9
8
 
10
- VERSION_REQUIREMENT = '1.3.3'
9
+ VERSION_REQUIREMENT = '1.4.0'
11
10
 
12
11
  def http_connections_allowed?
13
12
  ::WebMock::Config.instance.allow_net_connect
@@ -59,12 +58,6 @@ module VCR
59
58
  ::WebMock::Config.instance.allow_localhost
60
59
  end
61
60
 
62
- def should_unwind_response?(response)
63
- class << response
64
- !ancestors.include?(::WebMock::Net::HTTPResponse)
65
- end
66
- end
67
-
68
61
  private
69
62
 
70
63
  def version
@@ -93,7 +86,7 @@ module VCR
93
86
  end
94
87
  end
95
88
 
96
- WebMock.after_request(:except => [:net_http], :real_requests_only => true) do |request, response|
89
+ WebMock.after_request(:real_requests_only => true) do |request, response|
97
90
  http_interaction = VCR::HTTPInteraction.new(
98
91
  VCR::Request.new(
99
92
  request.method,
@@ -0,0 +1,13 @@
1
+ require 'vcr/ping'
2
+
3
+ module VCR
4
+ module InternetConnection
5
+ extend self
6
+
7
+ EXAMPLE_HOST = "example.com"
8
+
9
+ def available?
10
+ @available ||= Ping.pingecho(EXAMPLE_HOST, 1, 80)
11
+ end
12
+ end
13
+ end