Testing: Fix bug in VCR helper from a5d4cd8

In our test suite config, we have a helper
to enable HTTP caching ("VCR cassettes")
via RSpec metadata tags (from 1ebddff).

This helper can potentially lead to confusing test failures,
so we added an error message,
hooking into RSpec::Support.notify_failure (from a5d4cd8).

This error message logic did not take the same exact arguments
that RSpec::Support.notify_failure does,
which led to errors like the one below:

    ArgumentError:
      wrong number of arguments (given 2, expected 1)
    # ./spec/support/vcr.rb:78:in `inject_advisory'
    # ./spec/support/vcr.rb:60:in `inject_advisory'
    # ./spec/support/vcr.rb:36:in `block in auto_record'
    # ./spec/support/vcr.rb:35:in `auto_record'

This commit fixes the above error.
This commit is contained in:
Ryan Lue 2020-02-19 19:21:52 +08:00 committed by Thorsten Eckel
parent f69d7a0962
commit 5ffad2a7e7

View file

@ -53,8 +53,8 @@ module RSpec
module VCRHelper
def self.inject_advisory(example)
# block argument is an #<RSpec::Expectations::ExpectationNotMetError>
define_method(:notify_failure) do |e|
super(e.exception(VCR_ADVISORY + e.message))
define_method(:notify_failure) do |e, options = {}|
super(e.exception(VCR_ADVISORY + e.message), options)
end
example.run