You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So I have a setup using RSpec. Webmock is required in our spec helper and we recently tried using webmock/rspec as well. After doing a require for webmock/rspec though our test suite is broken for several tests that use webmock to rack requests to a fake object representing an api. It seems they go out and make requests to the actual api instead of our fake. This is very strange behavior since we have a before block that sets net connections to be disabled.
Examples of what I mean
before :all do
WebMock.disable_net_connect!(allow_localhost: true)
WebMock.stub_request(:any, /rest.developer.service.com/).to_rack(Fakes::ServiceFake)
Service::Base.new.login_app # our call to the service
end
Works fine when in our rails_helper we just have
require 'webmock'
breaks when we do
require 'webmock'
require 'webmock/rspec'
The text was updated successfully, but these errors were encountered:
Ok, that makes sense. Is this not documented anywhere that doing the normal require vs the require rspec does that reset? It was a bit jarring having the library work as expected one way and suddenly different under another. Though I do appreciate what's happening under the hood and understand why it's there. I may just have a selective memory if it is documented. The problem we had was just wanting to use all the great RSpec matchers from Webmock; not that we wanted to use the config or setup.
So I have a setup using RSpec. Webmock is required in our spec helper and we recently tried using webmock/rspec as well. After doing a require for webmock/rspec though our test suite is broken for several tests that use webmock to rack requests to a fake object representing an api. It seems they go out and make requests to the actual api instead of our fake. This is very strange behavior since we have a before block that sets net connections to be disabled.
Examples of what I mean
Works fine when in our rails_helper we just have
breaks when we do
The text was updated successfully, but these errors were encountered: