In a functional test of my Rails app, I want to test where I am redirected to. The expected URL points to an external resource (that means it's not part of my application).
The URL looks like this:
The http request commands like
get etc. create an instance variable called
@response when they are called*.
@response itself contains a method called
redirect_url which stores the URL you have been redirected to (in case you have really been redirected).
Therefor, I can just use a normal
assert_match to compare a regular expression to
post :my_action_to_test assert_response :redirect assert_match /https:\/\/my.url.com\/foo/, @response.redirect_url
*(actually, these http methods just use the private method
process, which creates the