Does your web application have an ActiveResource-based API, or are you thinking of creating one?
Testing your API’s client library can be a pain - it has to hit a real, running version of your application. ActiveResource gives us a way to mock its HTTP calls, via HttpMock but it’s a bit of a pain to use … you have to manually mock out the responses for any and every call you want to make!
If you already have a Rails (or Sinatra or any other Rack-based framework) application that you want to test, why can’t you just tell ActiveResource to hit your application when it makes requests? And do it in such a way that doesn’t require running over a network.
Introducing ActiveRacksource
http://github.com/openrain/active_racksource
ActiveRacksource solves this problem. It allows you to give ActiveResource any Rack application which it’ll use as a backend.
Short version:
1 require 'my_active_resource_based_client_API' 2 3 MyAPI::Dog.find :all # this will run over HTTP normally 4 5 require 'active_racksource' 6 ActiveResource::Base.app = @my_rack_app 7 8 MyAPI::Dog.find :all # this will run against the Rack app now!
Long version: watch the screencast!