Pact Ruby End to End Example
Code base to use for demonstrating features or recreating issues in the ruby implementation of pact. Please fork it and modify to demonstrate or recreate your own code.
This code base is not intended as an example of a best practice pact implementation. Its purpose is to create a running example with the simplest code possible. If you want to see an example of how you would use pact in a Ruby consumer or provider project, see the example dir in the pact repository.
Usage
Fork and clone the codebase
# Fork the repository using the 'Fork' button on the repository home page, then:
git clone git@github.com:YOUR_USERNAME/pact-ruby-e2e-example.git
cd pact-ruby-e2e-example
Set the gem versions you are using
-
Open up the
Gemfileand set the exact gem versions you are using. eggem "pact", "1.12.1" -
Run
bundle update
Set up consumer and provider
- Modify the code in
consumer/spec/bar_spec.rbto recreate your consumer expectations and actual requests. - Modify the code in
provider/bar_app.rbto recreate the response that your provider will return. - Run
bundle exec raketo run the consumer specs, generate the pact file, and verify the pact file. - You will find the pact file in
consumer/spec/pacts/foo-bar.json - To run just the consumer specs and generate the pact:
bundle exec rake spec - To run just the provider verification:
bundle exec rake pact:verify:foobar
To recreate issues with a local pact broker
-
Set the exact gem versions in
pact_broker/Gemfileand runbundle update. -
In another terminal, cd into the
pact_brokerdirectory and runbundle exec rackup. -
Follow the above instructions for setting up the consumer and provider code.
-
In the root directory of this project, run
bundle exec rake pact:verify:foobar_using_local_broker
To recreate issues with a remote pact broker
-
In the
Rakefileset theREMOTE_PACT_BROKER_BASE_URLto the value of your pact broker. -
Follow the above instructions for setting up the consumer and provider code.
-
Set the
PACT_BROKER_USERNAMEandPACT_BROKER_PASSWORDenvironment variables if you are using a broker with basic auth.export PACT_BROKER_USERNAME=your_username export PACT_BROKER_PASSWORD=your_password -
In the root directory of this project, run
bundle exec rake pact:verify:foobar_using_remote_broker
Reporting an issue
-
Commit your code on a branch (so you can reuse it for other issues cleanly) and push it to your fork
git checkout -b "foo-issue" git add . git commit -m "Modifying code to recreate my issue" git push --set-upstream origin foo-issue -
Open an issue in the appropriate codebase (see pact-foundation for most of the repositories) and include a link to your branch.

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.
