-
Notifications
You must be signed in to change notification settings - Fork 557
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
including webmock/rspec in any spec file results in all specs having web disabled #895
Comments
Is it intended/expected that |
@thoraxe yes, it's intended that If you take a look at WebMock interecepts the requests on http client level. It doesn't know where the requests came from. Whether they came from a code invoked inside rspec test or from server code that was loaded as well and there is no way to control that. I suggest you invoke |
Hello, I tried putting the line
In all cases the requests to the above url are blocked. |
@cecilian Is the http request made from the code invoked inside the test? If yes, then perhaps there is some code that again disables the connections after the setup and before the request is invoked? The following code works find:
|
Given a file
spec/services/foo_spec.rb
with:if I simply run
bundle exec rspec
to execute all tests, I get the following error from a completely different spec file (spec/controllers/admin/data_source_controller_spec.rb
):I tried moving
require webmock/rspec
to bothspec_helper
andrails_helper
immediately followed by aWebMock.disable!
but that had no effect -- webmock was still enabled everywhere.I'm assuming this is user error but I'm not understanding how I can use webmock only for certain spec files.
Also, moving the
require webmock/rspec
into a specific test block fixed the problem in other specs (they didn't have webmock enabled) but once the require is inside theRSpec.describe
block it doesn't appear that webmock works (it didn't detect the stub I was testing for).The text was updated successfully, but these errors were encountered: