Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mock error handling should be delegated to mocking framework #945

Open
davidgm0 opened this issue Aug 24, 2022 · 1 comment
Open

Mock error handling should be delegated to mocking framework #945

davidgm0 opened this issue Aug 24, 2022 · 1 comment

Comments

@davidgm0
Copy link

davidgm0 commented Aug 24, 2022

I use both Webmock and VCR. In some cases, I don't use VCR and I just use Webmock.

When I do something like this:

stub_request(:post, 'https://api.github.com')

but my request does

POST 'https://api.github.comm' #note extra 'm'

I get a VCR error:

       An HTTP request has been made that VCR does not know how to handle:
         POST https://api.github.comm
       There is currently no cassette in use. There are a few ways
       you can configure VCR to handle this request:
      ...

I would expect that in such cases, Webmock would be the one handling the error. The reason for this is that Webmock gives much more details of what are the registered stubs and what was the request that has been made.
I have been searching how to configure this behaviour, but I don't find the exact configuration values. Am I missing something or is it a bug?

Config

require 'vcr'
require 'webmock/rspec'

VCR.configure do |config|
  config.cassette_library_dir = 'fixtures/vcr_cassettes'
  config.hook_into :webmock
  config.ignore_localhost = true
  config.configure_rspec_metadata!
  config.allow_http_connections_when_no_cassette = false
end

Ruby 2.7.6
Gem 3.1.6
Webmock 3.18.1
Rails 5.2.8.1
Rspec 3.11

@jarosan
Copy link

jarosan commented Feb 8, 2023

This was already discussed here #146

@davidgm0 davidgm0 changed the title Mock error handling with allow_http_connections_when_no_cassette = true should be delegated to mocking framework Mock error handling should be delegated to mocking framework Mar 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants