Sha256: 0b86c3dacf3931cdf2fa6bdb43ae3526fdd1008e3785d0b3b4f304898f5e21dd
Contents?: true
Size: 885 Bytes
Versions: 17
Compression:
Stored size: 885 Bytes
Contents
# frozen_string_literal: true def stubs_and_times @stubs_and_times ||= [] end def stubs_and_times_reset @stubs_and_times = [] end module WebMock module API # Overwrite the original stub_request method to enforce we explicitly say # how many times we expect a request to be called def stub_request(*args, times: 1) ret = WebMock::StubRegistry.instance .register_request_stub(WebMock::RequestStub.new(*args)) stubs_and_times << [ret, times] unless times.nil? ret end end end RSpec.configure do |config| config.before { WebMock.reset! } config.around(qa: true) do |example| WebMock.disable! example.run ensure WebMock.enable! end config.after do stubs_and_times.each do |stub, times| expect(stub).to have_been_requested.times(times) end stubs_and_times_reset end end
Version data entries
17 entries across 17 versions & 1 rubygems