Giter VIP home page Giter VIP logo

pacts-playground's Introduction

This repository provides the basic infrastructure to practice with Consumer Driven Contract testing, especially with the realestate-com-au/pact's ecosystem. There are three different components available in this repository:

  • a simple Ruby consumer
  • a simple Ruby provider
  • a Dockerized version of the Pact Broker service (v. 1.16)

Through these components it is possible to practice with Pact's concepts, starting with the examples described in the realestate-com-au/pact's repo.

Setup

To setup the components simply run:

./bin/simon_says setup

from the project's root. The script will:

  • install the dependencies for the consumer,
  • install the dependencies for the provider, and
  • create the Docker image with the Pact Broker

Start the Pact Broker

After the setup, execute:

./bin/simon_says start_broker

The broker should be now available at http://localhost:8080/.

Create the Consumer's Pact

To create the consumer's pact, run:

./bin/simon_says verify_consumer

which produces an output similar to:

./bin/simon_says:35: warning: Insecure world writable dir /usr/local in PATH, mode 040777
.

Finished in 0.0275 seconds (files took 0.52251 seconds to load)
1 example, 0 failures


>> Publishing spec/pacts/library_app-books_service.json to pact broker at http://localhost:8080
The latest version of this pact can be accessed at the following URL (use this to configure the provider verification):
http://localhost:8080/pacts/provider/Books%20Service/consumer/Library%20App/latest

The pact is now available in the Pact Broker at http://localhost:8080/pacts/provider/Books%20Service/consumer/Library%20App/latest.

Verify the Pact

To verify the pact on the provider's side, run:

./bin/simon_says verify_provider

which will produce an output similar to:

Reading pact at http://localhost:8080/pacts/provider/Books%2520Service/consumer/Library%2520App/latest

Verifying a pact between Library App and Books Service
  Given a book exists
    a request for a book
      with GET /books/1
        returns a response which
          has status code 200
          has a matching body
          includes headers
            "Content-Type" with value "application/json"

1 interaction, 0 failures

Stop the Pact Broker

To stop the running Docker instance, simply run:

./bin/simon_says stop_broker

pacts-playground's People

Contributors

kalimaha avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.