Demo repo for Consumer Driven Contract Tests using Pact
A proof of concept of Consumer Driven Contract Testing for a message based (non-HTTP) producer and consumer relationship using the pact-message-ruby
gem.
Pact already supports non-HTTP interactions and contracts in most languages. An official pact-message-ruby gem has existed for several years.
This POC focuses on a hypothetical situation where a potential breaking change has been introduced to a message schema.
The consumer is expecting a message containing a last_name
field, however this field has been renamed. The producer is now sending messages with a surname
field.
Running consumer side tests and generating a contract
- Execute the consumer side test for the
TestMessageConsumer
.
bundle exec rspec
- The consumer side test should pass.
- A contract file will be created representing the consumers expectations of the message format.
Running provider side verification of the contract
- Execute the Pact verification Rake task.
bundle exec rake pact:verify
- The RSpec tests generated by the Pact provider side verification task should fail.