You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Beth Skurrie edited this page Nov 17, 2017
·
4 revisions
Rarely asked questions
Doesn't this break HAL?
Yes. We're working on this with the v4 generators.
How can I run a standalone mock server?
By default, a mock service will be started automatically by the pact gem when running the consumer tests. A standalone mock service can be run locally and is useful for debugging purposes.
Pact.service_consumer"My Service Consumer"dohas_pact_with"My Service Provider"domock_service:my_service_providerdoport <port-num>
standalonetrue#Tell the pact gem not to automatically start the mock serviceendendend
$ bundle exec pact-mock-service -p <port-num>
The service prints messages it recieves to stdout which can be really useful
when diagnosing issues with pacts.
How can I specify hooks to be executed before/after all examples for pact:verify?
Use the set_up and tear_down hooks in the provider state definition:
Pact.provider_states_for"Some Consumer"doset_updo# Set up code here endtear_downdo# tear down code hereendend
How can I specify multiple headers with the same name?
RFC 2616 states that two headers with the same name can interpreted as a single header with two comma-separated values. This is the safest way to specify multiple headers with the same name, as Rack will only pass the last value through when they are defined separately (see https://github.com/rack/rack/issues/436).
my_service_provider..given("it is RFC 2616 compliant").upon_receiving("a request with a header with commas separated values").with(method: :get,path: '/',headers: {'X-Request-Multival'=>"A, B"}).will_respond_with(status: 200,headers: {'X-Response-Multival'=>"C, D"})