Turning off VCR when stubbing with Webmock

Posted . Visible to the public.

Sometimes when working with VCR you still want to use webmock. Since VCR hooks into webmock and fails when an unknown request is happening, you have to turn it off in order to use webmock like you are used to. Here is how to do this in rspec.

RSpec.configure do |config|
  config.around do | example |
    if example.metadata[:turn_off_vcr]
      VCR.turn_off!
      example.run
      VCR.turn_on!
    else
      example.run
    end
  end
end
Last edit
Andreas Robecke
License
Source code in this card is licensed under the MIT License.
Posted to makandra dev (2017-10-11 12:51)