stubify

Twitter: @carlostify License Gem

stubify allows you to stub real environments without really doing anything. It runs a Sinatra application locally and, given a host, it forwards all the calls received caching the real responses, that way, next time the local environment receives a request the cached response is returned.

Example

By running the gem with the following command:

stubify server --host https://easy-peasy.io --directory fixtures

It will create a local environment with address http://localhost:4567. Every request received will be recreated against the host provided, therefore a request to http://localhost:4567/rest_api/user/32325 will return whatever https://easy-peasy.io/rest_api/user/32325 returns and, in addition, that response will be cached in the directory fixtures.

Next time a request to http://localhost:4567/rest_api/user/32325 is made the cached payload will be returned.

Features

  • Accepts GET, POST, PUT and DELETE requests.
  • HTTP headers, query parameters and request bodies are taken into account.

Installation

sudo gem install stubify

Usage

stubify server --host https://real-host.com --directory path_to_cached_response

ACTIONS:

    server [options]

OPTIONS:

  --host STRING
      Host the requests will be redirected to. i.e. https://easy-peasy.io

  --directory DIR
      Path where fixtures will be stored. i.e. fixtures/

  --port STRING
      Port the local environment will listen to. Default is 4567

  --verbose
      Increases the amount of information logged

Contributors

nakiostudio

License

This project is licensed under the terms of the MIT license. See the LICENSE file.