Rack::Test and request / response objects
March 26, 2010
Rack::Test uses last_response
and last_request
objects instead of Rack's typical request
and response
objects. This is probably normally fine, but when you are testing functionality that requires accessing the Rack's normal objects, they aren't there. I found (in the comments section of this post) that you can fix this by overriding them in your test_helper.rb:
module Test::Unit
class TestCase
include Rack::Test::Methods
...
def request(*args)
args.empty? ? last_request : rack_test_session.request(*args)
end
...
end
end