http://robots.thoughtbot.com/post/34761570235/using-capybara-to-test-javascript-that-makes-http
Check out the set_configuration call below: https://github.com/thoughtbot/fake_braintree/blob/master/lib/fake_braintree.rb
http://www.sinatrarb.com/intro#Rack%20Middleware