vcr 3.0.0 → 3.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4220b7228aef7b898a3c0caaac694cde250bf8c2
4
- data.tar.gz: 1dc6b739ec86f670219754076cd749edb295c47b
3
+ metadata.gz: 1c6e5ef325a46f12137b6d559a35e1664c684a7f
4
+ data.tar.gz: c2bcdd8e42555694ec5cf081eccb74bb01ebd89f
5
5
  SHA512:
6
- metadata.gz: 758f773b6832d30b190aaaba9c24ed7d345c1d31a1216cc8b9ff4bac4175e17f01d9355be38ba2e7bb752c6ab10e8f98c2fa31ddfcac8dbfbe7649d27c279768
7
- data.tar.gz: a29dff72f5ed9facdda4038866b2c761905e42ae3c51756406ab965bae03e9b398d3219ebea0963ae85235f84e90492a66e44a61def80412d298ecac56e73c5d
6
+ metadata.gz: 687d5591fedaf5c58051814b07f7b5eb9e2a42d6179ddb946d9124ebbf07d58c2edf4bb90a16b80553e36ab93f91036fb25e51f2324bcb49ec1fd90795e7edba
7
+ data.tar.gz: 85865a69856a58f4ad35f2fad7d8231071ad2e8c4bfc34b5d308a7bb90fdd31bec403e58a1df8bf7d77076eadec0351aa25593ab7b29aabdbfb602a56b3759df
@@ -85,7 +85,7 @@ Feature: hook_into
85
85
  | c.hook_into :faraday | faraday (w/ net_http) |
86
86
  | c.hook_into :faraday | faraday (w/ typhoeus) |
87
87
 
88
- @exclude-jruby @exclude-18
88
+ @exclude-jruby @exclude-rbx @exclude-18
89
89
  Scenario Outline: Use Typhoeus, Excon and Faraday in combination with FakeWeb or WebMock
90
90
  Given a file named "hook_into_multiple.rb" with:
91
91
  """ruby
@@ -143,7 +143,7 @@ end
143
143
 
144
144
  Then(/^the file "([^"]*)" should contain YAML like:$/) do |file_name, expected_content|
145
145
  actual_content = in_current_dir { File.read(file_name) }
146
- expect(normalize_cassette_hash(YAML.load(actual_content))).to eq(normalize_cassette_hash(YAML.load(expected_content)))
146
+ expect(normalize_cassette_hash(YAML.load(actual_content))).to eq(normalize_cassette_hash(YAML.load(expected_content.to_s)))
147
147
  end
148
148
 
149
149
  Then(/^the file "([^"]*)" should contain JSON like:$/) do |file_name, expected_content|
@@ -155,8 +155,8 @@ end
155
155
 
156
156
  Then(/^the file "([^"]*)" should contain compressed YAML like:$/) do |file_name, expected_content|
157
157
  actual_content = in_current_dir { File.read(file_name) }
158
- unzipped_content = Zlib.inflate(actual_content)
159
- expect(normalize_cassette_hash(YAML.load(unzipped_content))).to eq(normalize_cassette_hash(YAML.load(expected_content)))
158
+ unzipped_content = Zlib::Inflate.inflate(actual_content)
159
+ expect(normalize_cassette_hash(YAML.load(unzipped_content))).to eq(normalize_cassette_hash(YAML.load(expected_content.to_s)))
160
160
  end
161
161
 
162
162
  Then(/^the file "([^"]*)" should contain ruby like:$/) do |file_name, expected_content|
@@ -20,7 +20,7 @@ rubyopt = "-rsupport/cucumber_helpers"
20
20
 
21
21
  if RUBY_VERSION > '1.9'
22
22
  load_paths.unshift(".")
23
- rubyopt = "--disable-gems #{rubyopt}" if "ruby" == ruby_engine
23
+ rubyopt = "--disable-gems #{rubyopt}" unless "rbx" == ruby_engine
24
24
  end
25
25
 
26
26
  Before do
@@ -35,6 +35,8 @@ end
35
35
  Before("~@with-bundler") do
36
36
  set_env("RUBYLIB", load_paths.join(":"))
37
37
  set_env("RUBYOPT", rubyopt)
38
+ set_env("RBXOPT", "--disable-gems #{ENV["RBXOPT"]}") if "rbx" == ruby_engine
39
+ set_env("GEM_HOME", nil)
38
40
  end
39
41
 
40
42
  Before("@with-bundler") do
@@ -11,9 +11,9 @@ elsif defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx'
11
11
 
12
12
  # I'm getting errors in the curb C extension in rbx.
13
13
 
14
- # Faraday and Typhoeus should be buildable on rbx, but the travis build times out,
14
+ # Typhoeus should be buildable on rbx, but the travis build times out,
15
15
  # so we skip them to speed up the build on travis.
16
- UNSUPPORTED_HTTP_LIBS = %w[ patron em-http-request curb faraday typhoeus ]
16
+ UNSUPPORTED_HTTP_LIBS = %w[ patron em-http-request curb typhoeus ]
17
17
  elsif RUBY_PLATFORM == 'java'
18
18
  # These gems have C extensions and can't install on JRuby.
19
19
  c_dependent_libs = %w[ typhoeus patron curb em-http-request ]
@@ -28,9 +28,9 @@ if defined?(UNSUPPORTED_HTTP_LIBS)
28
28
  UNSUPPORTED_HTTP_LIB_REGEX = Regexp.union(*UNSUPPORTED_HTTP_LIBS)
29
29
 
30
30
  # Filter out example rows that use libraries that are not supported on the current ruby interpreter
31
- Around do |scenario, block|
32
- unless scenario.respond_to?(:cell_values) && scenario.cell_values.any? { |v| v =~ UNSUPPORTED_HTTP_LIB_REGEX }
33
- block.call
31
+ Before do |scenario|
32
+ if scenario.respond_to?(:cell_values) && scenario.cell_values.any? { |v| v =~ UNSUPPORTED_HTTP_LIB_REGEX }
33
+ scenario.skip_invoke!
34
34
  end
35
35
  end
36
36
  end
data/lib/vcr.rb CHANGED
@@ -4,6 +4,7 @@ require 'vcr/util/variable_args_block_caller'
4
4
  require 'vcr/cassette'
5
5
  require 'vcr/cassette/serializers'
6
6
  require 'vcr/cassette/persisters'
7
+ require 'vcr/linked_cassette'
7
8
  require 'vcr/configuration'
8
9
  require 'vcr/deprecations'
9
10
  require 'vcr/errors'
@@ -130,7 +131,7 @@ module VCR
130
131
  end
131
132
 
132
133
  cassette = Cassette.new(name, options)
133
- cassettes.push(cassette)
134
+ context_cassettes.push(cassette)
134
135
  cassette
135
136
  elsif !ignore_cassettes?
136
137
  message = "VCR is turned off. You must turn it on before you can insert a cassette. " +
@@ -155,7 +156,7 @@ module VCR
155
156
  cassette.eject(options) if cassette
156
157
  cassette
157
158
  ensure
158
- cassettes.pop
159
+ context_cassettes.delete(cassette)
159
160
  end
160
161
 
161
162
  # Inserts a cassette using the given name and options, runs the given
@@ -262,7 +263,7 @@ module VCR
262
263
  "You must eject it before you can turn VCR off."
263
264
  end
264
265
 
265
- set_context_value(:ignore_cassettes, options[:ignore_cassettes])
266
+ set_context_value(:ignore_cassettes, options.fetch(:ignore_cassettes, false))
266
267
  invalid_options = options.keys - [:ignore_cassettes]
267
268
  if invalid_options.any?
268
269
  raise ArgumentError.new("You passed some invalid options: #{invalid_options.inspect}")
@@ -307,6 +308,14 @@ module VCR
307
308
  @request_matchers
308
309
  end
309
310
 
311
+ # @return [Enumerable] list of all cassettes currently being used
312
+ def cassettes(context = current_context)
313
+ linked_context = context[:linked_context]
314
+ linked_cassettes = cassettes(linked_context) if linked_context
315
+
316
+ LinkedCassette.list(context[:cassettes], Array(linked_cassettes))
317
+ end
318
+
310
319
  # @private
311
320
  def request_ignorer
312
321
  @request_ignorer
@@ -376,8 +385,9 @@ private
376
385
  def dup_context(context)
377
386
  {
378
387
  :turned_off => context[:turned_off],
379
- :ignore_cassettes => context[:ignore_cassettes].dup,
380
- :cassettes => context[:cassettes].dup
388
+ :ignore_cassettes => context[:ignore_cassettes],
389
+ :cassettes => [],
390
+ :linked_context => context
381
391
  }
382
392
  end
383
393
 
@@ -385,7 +395,7 @@ private
385
395
  context_value(:ignore_cassettes)
386
396
  end
387
397
 
388
- def cassettes
398
+ def context_cassettes
389
399
  context_value(:cassettes)
390
400
  end
391
401
 
@@ -403,8 +413,9 @@ private
403
413
  @context = {
404
414
  MainThread => {
405
415
  :turned_off => false,
406
- :ignore_cassettes => [],
407
- :cassettes => []
416
+ :ignore_cassettes => false,
417
+ :cassettes => [],
418
+ :linked_context => nil
408
419
  }
409
420
  }
410
421
  @configuration = Configuration.new
data/lib/vcr/cassette.rb CHANGED
@@ -134,6 +134,11 @@ module VCR
134
134
  @originally_recorded_at ||= previously_recorded_interactions.map(&:recorded_at).min
135
135
  end
136
136
 
137
+ # @return [Boolean] false unless wrapped with LinkedCassette
138
+ def linked?
139
+ false
140
+ end
141
+
137
142
  private
138
143
 
139
144
  def assert_valid_options!
@@ -23,7 +23,7 @@ module VCR
23
23
  def [](file_name)
24
24
  path = absolute_path_to_file(file_name)
25
25
  return nil unless File.exist?(path)
26
- File.read(path)
26
+ File.binread(path)
27
27
  end
28
28
 
29
29
  # Sets the cassette for the given storage key (file name).
@@ -34,7 +34,7 @@ module VCR
34
34
  path = absolute_path_to_file(file_name)
35
35
  directory = File.dirname(path)
36
36
  FileUtils.mkdir_p(directory) unless File.exist?(directory)
37
- File.open(path, 'w') { |f| f.write(content) }
37
+ File.binwrite(path, content)
38
38
  end
39
39
 
40
40
  # @private
@@ -44,7 +44,6 @@ module VCR
44
44
  end
45
45
 
46
46
  private
47
-
48
47
  def absolute_path_for(path)
49
48
  Dir.chdir(path) { Dir.pwd }
50
49
  end
data/lib/vcr/errors.rb CHANGED
@@ -51,6 +51,10 @@ module VCR
51
51
  # @see VCR::HTTPInteractionList#assert_no_unused_interactions!
52
52
  class UnusedHTTPInteractionError < Error; end
53
53
 
54
+ # Error raised when you attempt to eject a cassette inserted by another
55
+ # thread.
56
+ class EjectLinkedCassetteError < Error; end
57
+
54
58
  # Error raised when an HTTP request is made that VCR is unable to handle.
55
59
  # @note VCR will raise this to force you to do something about the
56
60
  # HTTP request. The idea is that you want to handle _every_ HTTP
@@ -78,11 +82,26 @@ module VCR
78
82
  ["", "", "=" * 80,
79
83
  "An HTTP request has been made that VCR does not know how to handle:",
80
84
  "#{request_description}\n",
81
- cassette_description,
85
+ cassettes_description,
82
86
  formatted_suggestions,
83
87
  "=" * 80, "", ""].join("\n")
84
88
  end
85
89
 
90
+ def current_cassettes
91
+ @cassettes ||= begin
92
+ cassettes = VCR.cassettes.to_a.reverse
93
+
94
+ begin
95
+ loop do
96
+ break unless VCR.eject_cassette
97
+ end
98
+ rescue EjectLinkedCassetteError
99
+ end
100
+
101
+ cassettes
102
+ end
103
+ end
104
+
86
105
  def request_description
87
106
  lines = []
88
107
 
@@ -100,19 +119,18 @@ module VCR
100
119
  end
101
120
 
102
121
  def current_matchers
103
- if VCR.current_cassette
104
- VCR.current_cassette.match_requests_on
122
+ if current_cassettes.size > 0
123
+ current_cassettes.inject([]) do |memo, cassette|
124
+ memo | cassette.match_requests_on
125
+ end
105
126
  else
106
127
  VCR.configuration.default_cassette_options[:match_requests_on]
107
128
  end
108
129
  end
109
130
 
110
- def cassette_description
111
- if cassette = VCR.current_cassette
112
- ["VCR is currently using the following cassette:",
113
- " - #{cassette.file}",
114
- " - :record => #{cassette.record_mode.inspect}",
115
- " - :match_requests_on => #{cassette.match_requests_on.inspect}\n",
131
+ def cassettes_description
132
+ if current_cassettes.size > 0
133
+ [cassettes_list << "\n",
116
134
  "Under the current configuration VCR can not find a suitable HTTP interaction",
117
135
  "to replay and is prevented from recording new requests. There are a few ways",
118
136
  "you can deal with this:\n"].join("\n")
@@ -122,6 +140,26 @@ module VCR
122
140
  end
123
141
  end
124
142
 
143
+ def cassettes_list
144
+ lines = []
145
+
146
+ lines << if current_cassettes.size == 1
147
+ "VCR is currently using the following cassette:"
148
+ else
149
+ "VCR are currently using the following cassettes:"
150
+ end
151
+
152
+ lines = current_cassettes.inject(lines) do |memo, cassette|
153
+ memo.concat([
154
+ " - #{cassette.file}",
155
+ " - :record => #{cassette.record_mode.inspect}",
156
+ " - :match_requests_on => #{cassette.match_requests_on.inspect}"
157
+ ])
158
+ end
159
+
160
+ lines.join("\n")
161
+ end
162
+
125
163
  def formatted_suggestions
126
164
  formatted_points, formatted_foot_notes = [], []
127
165
 
@@ -221,11 +259,11 @@ module VCR
221
259
  end
222
260
 
223
261
  def suggestions
224
- return no_cassette_suggestions unless cassette = VCR.current_cassette
262
+ return no_cassette_suggestions if current_cassettes.size == 0
225
263
 
226
264
  [:try_debug_logger, :use_new_episodes, :ignore_request].tap do |suggestions|
227
265
  suggestions.push(*record_mode_suggestion)
228
- suggestions << :allow_playback_repeats if cassette.http_interactions.has_used_interaction_matching?(request)
266
+ suggestions << :allow_playback_repeats if has_used_interaction_matching?
229
267
  suggestions.map! { |k| suggestion_for(k) }
230
268
  suggestions.push(*match_requests_on_suggestion)
231
269
  end
@@ -238,15 +276,26 @@ module VCR
238
276
  end
239
277
 
240
278
  def record_mode_suggestion
241
- case VCR.current_cassette.record_mode
242
- when :none then [:deal_with_none]
243
- when :once then [:delete_cassette_for_once]
244
- else []
279
+ record_modes = current_cassettes.map(&:record_mode)
280
+
281
+ if record_modes.all?{|r| r == :none }
282
+ [:deal_with_none]
283
+ elsif record_modes.all?{|r| r == :once }
284
+ [:delete_cassette_for_once]
285
+ else
286
+ []
245
287
  end
246
288
  end
247
289
 
290
+ def has_used_interaction_matching?
291
+ current_cassettes.any?{|c| c.http_interactions.has_used_interaction_matching?(request) }
292
+ end
293
+
248
294
  def match_requests_on_suggestion
249
- num_remaining_interactions = VCR.current_cassette.http_interactions.remaining_unused_interaction_count
295
+ num_remaining_interactions = current_cassettes.inject(0) { |sum, c|
296
+ sum + c.http_interactions.remaining_unused_interaction_count
297
+ }
298
+
250
299
  return [] if num_remaining_interactions.zero?
251
300
 
252
301
  interaction_description = if num_remaining_interactions == 1
@@ -192,6 +192,6 @@ VCR.configuration.after_library_hooks_loaded do
192
192
  if defined?(WebMock)
193
193
  raise ArgumentError.new("You have configured VCR to hook into both :fakeweb and :webmock. You cannot use both.")
194
194
  end
195
- ::Kernel.warn "WARNING: VCR's FakeWeb integration is deprecated and will be removed in VCR 3.0."
195
+ ::Kernel.warn "WARNING: VCR's FakeWeb integration is deprecated and will be removed in VCR 4.0."
196
196
  end
197
197
 
@@ -0,0 +1,72 @@
1
+ require 'delegate'
2
+ require 'vcr/errors'
3
+
4
+ module VCR
5
+ # A Cassette wrapper for linking cassettes from another thread
6
+ class LinkedCassette < SimpleDelegator
7
+ # An enumerable lazily wrapping a list of cassettes that a context is using
8
+ class CassetteList
9
+ include Enumerable
10
+
11
+ # Creates a new list of context-owned cassettes and linked cassettes
12
+ # @param [Array] context-owned cassettes
13
+ # @param [Array] context-unowned (linked) cassettes
14
+ def initialize(cassettes, linked_cassettes)
15
+ @cassettes = cassettes
16
+ @linked_cassettes = linked_cassettes
17
+ end
18
+
19
+ # Yields linked cassettes first, and then context-owned cassettes
20
+ def each
21
+ @linked_cassettes.each do |cassette|
22
+ yield wrap(cassette)
23
+ end
24
+
25
+ @cassettes.each do |cassette|
26
+ yield cassette
27
+ end
28
+ end
29
+
30
+ # Provide last implementation, which is not provided by Enumerable
31
+ def last
32
+ cassette = @cassettes.last
33
+ return cassette if cassette
34
+
35
+ cassette = @linked_cassettes.last
36
+ wrap(cassette) if cassette
37
+ end
38
+
39
+ # Provide size implementation, which is not provided by Enumerable
40
+ def size
41
+ @cassettes.size + @linked_cassettes.size
42
+ end
43
+
44
+ protected
45
+ def wrap(cassette)
46
+ if cassette.linked?
47
+ cassette
48
+ else
49
+ LinkedCassette.new(cassette)
50
+ end
51
+ end
52
+ end
53
+
54
+ # Create a new CassetteList
55
+ # @param [Array] context-owned cassettes
56
+ # @param [Array] context-unowned (linked) cassettes
57
+ def self.list(cassettes, linked_cassettes)
58
+ CassetteList.new(cassettes, linked_cassettes)
59
+ end
60
+
61
+ # Prevents cassette ejection by raising EjectLinkedCassetteError
62
+ def eject(*args)
63
+ raise Errors::EjectLinkedCassetteError,
64
+ "cannot eject a cassette inserted by a parent thread"
65
+ end
66
+
67
+ # @return [Boolean] true
68
+ def linked?
69
+ true
70
+ end
71
+ end
72
+ end
@@ -8,7 +8,12 @@ module VCR
8
8
  def configure!
9
9
  ::RSpec.configure do |config|
10
10
  vcr_cassette_name_for = lambda do |metadata|
11
- description = metadata[:description]
11
+ description = if metadata[:description].empty?
12
+ # we have an "it { is_expected.to be something }" block
13
+ metadata[:scoped_id]
14
+ else
15
+ metadata[:description]
16
+ end
12
17
  example_group = if metadata.key?(:example_group)
13
18
  metadata[:example_group]
14
19
  else
data/lib/vcr/version.rb CHANGED
@@ -10,7 +10,7 @@ module VCR
10
10
  # * `parts` [Array<Integer>] List of the version parts.
11
11
  def version
12
12
  @version ||= begin
13
- string = '3.0.0'
13
+ string = '3.0.1'
14
14
 
15
15
  def string.parts
16
16
  split('.').map { |p| p.to_i }
@@ -25,10 +25,16 @@ module VCR
25
25
  end
26
26
 
27
27
  describe "#[]=" do
28
- it 'writes the given file contents to the given file name' do
29
- expect(File.exist?(FileSystem.storage_location + '/foo.txt')).to be false
30
- FileSystem["foo.txt"] = "bar"
31
- expect(File.read(FileSystem.storage_location + '/foo.txt')).to eq("bar")
28
+ context 'with a simple file_name and binary content' do
29
+ let(:file_name) { 'foo.txt' }
30
+ let(:content) { SecureRandom.random_bytes(20) }
31
+ let(:location) { FileSystem.storage_location + '/' + file_name }
32
+
33
+ it 'writes the given file contents to the given file name' do
34
+ expect(File.exist?(location)).to be false
35
+ FileSystem[file_name] = content
36
+ expect(File.binread(location)).to eq(content)
37
+ end
32
38
  end
33
39
 
34
40
  it 'creates any needed intermediary directories' do
@@ -273,7 +273,7 @@ describe VCR::Cassette do
273
273
 
274
274
  allow(::File).to receive(:exist?).with(file_name).and_return(true)
275
275
  allow(::File).to receive(:size?).with(file_name).and_return(true)
276
- allow(::File).to receive(:read).with(file_name).and_return(yaml)
276
+ allow(::File).to receive(:binread).with(file_name).and_return(yaml)
277
277
  end
278
278
 
279
279
  context 'and the earliest recorded interaction was recorded less than 7 days ago' do
@@ -22,7 +22,7 @@ module VCR
22
22
  )
23
23
  end
24
24
 
25
- context 'when there is no current cassette' do
25
+ context 'when there is no cassette' do
26
26
  it 'identifies the request by its body when the default_cassette_options include the body in the match_requests_on option' do
27
27
  VCR.configuration.default_cassette_options[:match_requests_on] = [:body]
28
28
 
@@ -31,7 +31,7 @@ module VCR
31
31
  )
32
32
  end
33
33
 
34
- it 'mentions that there is no current cassette' do
34
+ it 'mentions that there is no cassette' do
35
35
  expect(message).to include('There is currently no cassette in use.')
36
36
  end
37
37
 
@@ -56,7 +56,7 @@ module VCR
56
56
  end
57
57
  end
58
58
 
59
- context 'when there is a current cassette' do
59
+ context 'when there are cassettes' do
60
60
  it 'identifies the request by its body when the match_requests_on option includes the body' do
61
61
  VCR.use_cassette('example', :match_requests_on => [:body]) do
62
62
  expect(message_for(:body => 'param=val1')).to include(
@@ -72,12 +72,20 @@ module VCR
72
72
  end
73
73
  end
74
74
 
75
- it 'mentions the details about the current casette' do
75
+ it 'mentions the details about the single cassette when there is one cassette' do
76
76
  VCR.use_cassette('example') do
77
77
  expect(message).to match(/VCR is currently using the following cassette:.+example.yml/m)
78
78
  end
79
79
  end
80
80
 
81
+ it 'mentions the details about all cassettes when there are a few cassettes' do
82
+ VCR.use_cassette('example') do
83
+ VCR.use_cassette('sample') do
84
+ expect(message).to match(/VCR are currently using the following cassettes:.+sample.yml.+example.yml/m)
85
+ end
86
+ end
87
+ end
88
+
81
89
  it 'mentions that :new_episodes can be used to record the request' do
82
90
  VCR.use_cassette('example') do
83
91
  expect(message).to include('use the :new_episodes record mode')
@@ -102,7 +110,15 @@ module VCR
102
110
  end
103
111
  end
104
112
 
105
- it 'mentions :allow_playback_repeats if the current cassette has a used matching interaction' do
113
+ it 'does not mention the :once or :none record modes if using the :new_episodes record mode at least in one cassette' do
114
+ VCR.use_cassette('example', :record => :new_episodes) do
115
+ VCR.use_cassette('sample') do
116
+ expect(message).not_to include('current record mode (:once)', 'current record mode (:none)')
117
+ end
118
+ end
119
+ end
120
+
121
+ it 'mentions :allow_playback_repeats if the cassette has a used matching interaction' do
106
122
  VCR.use_cassette('example') do |cassette|
107
123
  expect(cassette.http_interactions).to respond_to(:has_used_interaction_matching?)
108
124
  allow(cassette.http_interactions).to receive(:has_used_interaction_matching?).and_return(true)
@@ -110,7 +126,7 @@ module VCR
110
126
  end
111
127
  end
112
128
 
113
- it 'does not mention :allow_playback_repeats if the current cassette does not have a used matching interaction' do
129
+ it 'does not mention :allow_playback_repeats if the cassette does not have a used matching interaction' do
114
130
  VCR.use_cassette('example') do |cassette|
115
131
  expect(cassette.http_interactions).to respond_to(:has_used_interaction_matching?)
116
132
  allow(cassette.http_interactions).to receive(:has_used_interaction_matching?).and_return(false)
@@ -129,7 +129,7 @@ describe "FakeWeb hook", :with_monkey_patches => :fakeweb do
129
129
  end
130
130
 
131
131
  it "warns about FakeWeb deprecation" do
132
- expect(::Kernel).to receive(:warn).with("WARNING: VCR's FakeWeb integration is deprecated and will be removed in VCR 3.0.")
132
+ expect(::Kernel).to receive(:warn).with("WARNING: VCR's FakeWeb integration is deprecated and will be removed in VCR 4.0.")
133
133
  run_hook
134
134
  end
135
135
  end
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe "Typhoeus hook", :with_monkey_patches => :typhoeus do
3
+ describe "Typhoeus hook", :with_monkey_patches => :typhoeus, :if => (RUBY_INTERPRETER == :mri) do
4
4
  after(:each) do
5
5
  ::Typhoeus::Expectation.clear
6
6
  end
@@ -17,6 +17,17 @@ describe VCR::RSpec::Metadata, :skip_vcr_reset do
17
17
  ])
18
18
  end
19
19
  end
20
+
21
+ context 'when the spec has no description' do
22
+ it do
23
+ expect(VCR.current_cassette.name.split('/')).to eq([
24
+ 'VCR::RSpec::Metadata',
25
+ 'an example group',
26
+ 'when the spec has no description',
27
+ '1:1:2:1'
28
+ ])
29
+ end
30
+ end
20
31
  end
21
32
 
22
33
  context 'with the cassette name overridden at the example group level', :vcr => { :cassette_name => 'foo' } do
data/spec/lib/vcr_spec.rb CHANGED
@@ -291,6 +291,11 @@ describe VCR do
291
291
  }.to raise_error(ArgumentError)
292
292
  end
293
293
 
294
+ it 'sets ignore_cassettes to false' do
295
+ VCR.turn_off!
296
+ expect(VCR.send(:ignore_cassettes?)).to equal(false)
297
+ end
298
+
294
299
  context 'when `:ignore_cassettes => true` is passed' do
295
300
  before(:each) { VCR.turn_off!(:ignore_cassettes => true) }
296
301
 
@@ -1,5 +1,3 @@
1
- require 'typhoeus'
2
-
3
1
  module MonkeyPatches
4
2
  extend self
5
3
 
@@ -134,10 +132,16 @@ end
134
132
  # for WebMock to work with them.
135
133
  require 'httpclient'
136
134
 
137
- unless RUBY_INTERPRETER == :jruby
138
- require 'patron'
139
- require 'em-http-request'
140
- require 'curb'
135
+ if RUBY_INTERPRETER == :mri
136
+ require 'typhoeus'
137
+ begin
138
+ require 'patron'
139
+ require 'em-http-request'
140
+ require 'curb'
141
+ rescue LoadError
142
+ # these are not always available, depending on the Gemfile used
143
+ warn $!.message
144
+ end
141
145
  end
142
146
 
143
147
  if defined?(::Typhoeus.before)
@@ -28,7 +28,7 @@ module VCR
28
28
  @port = port || find_available_port
29
29
  @rack_app = rack_app
30
30
  concurrently { boot }
31
- wait_until(10, "Boot failed.") { booted? }
31
+ wait_until(30, "Boot failed.") { booted? }
32
32
  end
33
33
 
34
34
  private
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vcr
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Myron Marston
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-01 00:00:00.000000000 Z
11
+ date: 2015-12-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -276,76 +276,6 @@ dependencies:
276
276
  - - ">="
277
277
  - !ruby/object:Gem::Version
278
278
  version: '0'
279
- - !ruby/object:Gem::Dependency
280
- name: typhoeus
281
- requirement: !ruby/object:Gem::Requirement
282
- requirements:
283
- - - ">="
284
- - !ruby/object:Gem::Version
285
- version: '0'
286
- type: :development
287
- prerelease: false
288
- version_requirements: !ruby/object:Gem::Requirement
289
- requirements:
290
- - - ">="
291
- - !ruby/object:Gem::Version
292
- version: '0'
293
- - !ruby/object:Gem::Dependency
294
- name: patron
295
- requirement: !ruby/object:Gem::Requirement
296
- requirements:
297
- - - ">="
298
- - !ruby/object:Gem::Version
299
- version: '0'
300
- type: :development
301
- prerelease: false
302
- version_requirements: !ruby/object:Gem::Requirement
303
- requirements:
304
- - - ">="
305
- - !ruby/object:Gem::Version
306
- version: '0'
307
- - !ruby/object:Gem::Dependency
308
- name: em-http-request
309
- requirement: !ruby/object:Gem::Requirement
310
- requirements:
311
- - - ">="
312
- - !ruby/object:Gem::Version
313
- version: '0'
314
- type: :development
315
- prerelease: false
316
- version_requirements: !ruby/object:Gem::Requirement
317
- requirements:
318
- - - ">="
319
- - !ruby/object:Gem::Version
320
- version: '0'
321
- - !ruby/object:Gem::Dependency
322
- name: curb
323
- requirement: !ruby/object:Gem::Requirement
324
- requirements:
325
- - - ">="
326
- - !ruby/object:Gem::Version
327
- version: '0'
328
- type: :development
329
- prerelease: false
330
- version_requirements: !ruby/object:Gem::Requirement
331
- requirements:
332
- - - ">="
333
- - !ruby/object:Gem::Version
334
- version: '0'
335
- - !ruby/object:Gem::Dependency
336
- name: yajl-ruby
337
- requirement: !ruby/object:Gem::Requirement
338
- requirements:
339
- - - ">="
340
- - !ruby/object:Gem::Version
341
- version: '0'
342
- type: :development
343
- prerelease: false
344
- version_requirements: !ruby/object:Gem::Requirement
345
- requirements:
346
- - - ">="
347
- - !ruby/object:Gem::Version
348
- version: '0'
349
279
  - !ruby/object:Gem::Dependency
350
280
  name: relish
351
281
  requirement: !ruby/object:Gem::Requirement
@@ -475,6 +405,7 @@ files:
475
405
  - lib/vcr/library_hooks/typhoeus.rb
476
406
  - lib/vcr/library_hooks/typhoeus_0.4.rb
477
407
  - lib/vcr/library_hooks/webmock.rb
408
+ - lib/vcr/linked_cassette.rb
478
409
  - lib/vcr/middleware/excon.rb
479
410
  - lib/vcr/middleware/excon/legacy_methods.rb
480
411
  - lib/vcr/middleware/faraday.rb
@@ -564,7 +495,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
564
495
  version: '0'
565
496
  requirements: []
566
497
  rubyforge_project:
567
- rubygems_version: 2.4.8
498
+ rubygems_version: 2.4.3
568
499
  signing_key:
569
500
  specification_version: 4
570
501
  summary: Record your test suite's HTTP interactions and replay them during future