# File lib/webmock/stub_registry.rb, line 12 def global_stubs @global_stubs ||= [] end
# File lib/webmock/stub_registry.rb, line 20 def register_global_stub(&block) # This hash contains the responses returned by the block, # keyed by the exact request (using the object_id). # That way, there's no race condition in case #to_return # doesn't run immediately after stub.with. responses = {} stub = ::WebMock::RequestStub.new(:any, /.*/).with { |request| responses[request.object_id] = block.call(request) }.to_return(lambda { |request| responses.delete(request.object_id) }) global_stubs.push stub end
# File lib/webmock/stub_registry.rb, line 34 def register_request_stub(stub) request_stubs.insert(0, stub) stub end
# File lib/webmock/stub_registry.rb, line 39 def registered_request?(request_signature) request_stub_for(request_signature) end
Generated with the Darkfish Rdoc Generator 2.