views:

478

answers:

1

In my Rails app, I have a form which redirects through a foreign service, Amazon FPS. The form POSTs to an action in my app which redirects to Amazon, who collect information and then redirect back to my app.

I'm testing this workflow with Webrat. Obviously I can't test Amazon, so I want to check that the redirection to Amazon happens and then simulate Amazon's redirection back into my app, effectively mocking out Amazon from the test.

However, when Webrat submits the form, it calls ActionController::Integration::Session#request_via_redirect, which follows all redirections until it gets a response which is not a redirect. This includes the redirect to Amazon. Rails ignores the domain and requests the path from the local app, which fails.

What I'm looking for is a way to stop Webrat/Rails from making requests for URLs on other domains and allowing me to verify the redirection.

+1  A: 

Solution: make my own way.

Peeja