Replaces Net::HTTP with a subclass that routes all requests to a Rack application
Ruby
Latest commit ef3f0d4 Aug 25, 2016 @indirect indirect committed on GitHub Merge pull request #14 from segiddins/seg-modernize
Infrastructure improvements
Permalink
Failed to load latest commit information.
lib handle streaming requests Dec 31, 2011
spec handle streaming requests Dec 31, 2011
.gitignore Some infrastructure updates Mar 25, 2010
Gemfile Add Rake to the Gemfile Aug 24, 2016
Gemfile.lock Add Rake to the Gemfile Aug 24, 2016
LICENSE Initial commit of artifice with some tests. Mar 25, 2010
README.textile Initial commit of artifice with some tests. Mar 25, 2010
Rakefile Use pre-made rake tasks Aug 24, 2016
artifice.gemspec

README.textile

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.

Usage

First, require artifice.

require "artifice"

Next, activate artifice using a Rack endpoint.

Artifice.activate_with(rack_endpoint)

You’re done!

You can also pass a block to activate_with:

Artifice.activate_with(rack_endpoint) do
  # make some requests using Net::HTTP
end

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

You can deactivate Artifice by calling deactivate

Artifice.deactivate