-
Notifications
You must be signed in to change notification settings - Fork 556
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
Allow global stubbing (e.g. before :suite) #484
Comments
Because it calls |
+1 |
@VincentZhao do you know why is necessary to reset the mocks after every test (as the source code does)? |
@giovannibenussi because we want to have a clean state when entering a new example. |
There should be an option to stub globally by disabling |
@Epigene Do you have any suggestion how that option to disable reset conditionally could work? btw. you don't have to include |
Now that I think about it, the functionality could work like this:
5th point would be a quick-and-dirty way to skip reset entirely. If last call of # in rails_helper.rb
after do
WebMock.reset!
end
# in some spec file
describe "long setup" do
after do
WebMock.reset!(except: :all)
end
end |
some news right here? Is this possible? Thanks |
yeah, we need this. for sure! i don't wanna stub the same and same request over and over again? |
Has anybody found a workaround and be able to stub things once? |
Thanks! Not the ideal scenario (I don't want to stub on every example) but this is what works so far. RSpec.configure do |config|
config.before :each do
WebMock.globally_stub_request { |request|
if request.uri.to_s =~ /my_url/
{ status: 200, body: '{}', headers: {} }
end
}
end
end |
In Rspec this works:
However this doesn't work:
I think it would be useful to stub something globally only once in a
before :suite
.The text was updated successfully, but these errors were encountered: