artifice

Replaces Net::HTTP with a subclass that routes all requests to a Rack application

MIT License

Stars
214
Committers
6

Artifice allows you to replace the Net::HTTP subsystem of Ruby with an equivalent that routes all requests to a Rack application.

You can use Sinatra, raw Rack, or even Rails as your application, allowing you to build up an equivalent to the remote service you are mocking out using familiar and convenient tools to route requests and build up responses.

h1. Usage

First, require artifice.

Next, activate artifice using a Rack endpoint.

You're done!

You can also pass a block to @activate_with@:

This will replace Net::HTTP for the duration of the block only.

You can deactivate Artifice by calling @deactivate@