I have a third party API that I'd like to mock with FakeWeb, but I was
hoping FakeWeb could generate the mocked responses for me the first
time around. What I want would be something like this:
# Setup some type of caching for the request responses, for
CACHE = ActiveSupport::Cache::FileStore.new "test/fixtures/api/"
# If passed a block, yields the method, normalized uri, and
# Net::Http request object
FakeWeb.register_uri(:all, /.*/) do |method, uri, request|
# Forces a real request through by temporarily allowing a net
This way I could easily generate the right mock responses for the
requests I make, and then manually tweak them in the "fixture" or
Has anyone done something like this already? I'd like to implement
this but want a second opinion since I'm new to this gem.