Module: MockServer::RSpec
- Defined in:
- lib/mockserver/rspec.rb
Overview
RSpec integration helpers for MockServer.
Require this file from your spec_helper.rb to get a shared context that
provides a fresh Client per example and automatically resets
the server between examples, so recorded requests, expectations and logs
never leak from one example to the next:
require 'mockserver/rspec'
RSpec.describe 'my integration', :mockserver do
it 'records the request' do
# `mockserver` is the shared, reset client
mockserver.when(MockServer::HttpRequest.request(path: '/hello'))
.respond(MockServer::HttpResponse.response(body: 'world'))
end
end
The host and port default to 127.0.0.1:1080 and can be overridden with the
MOCKSERVER_HOST / MOCKSERVER_PORT environment variables, or by defining a
mockserver_host / mockserver_port let in your example group.
Constant Summary collapse
- SHARED_CONTEXT_NAME =
'mockserver client'