title: How do I easily parse a URL with parameters in a Rails test?
body: <p>I have a some code that embeds a <code>return_to</code> URL into a redirect (like OpenID) that I want to test:</p>
  
  <pre><code>def test_uses_referrer_for_return_to
    expected_return_to = 'http://test.com/foo'
    @request.env['HTTP_REFERER'] = expected_return_to
    get :fazbot
    # @response.redirected_to looks like http://service.com?...&amp;return_to=[URI-encoded version of URL above]&amp;...
    encoded_return_to = (something_here)[:return_to]
    assert_equal expected_return_to, URI.unencode(encoded_return_to)
  end
  </code></pre>
  
  <p>It's a Rails <code>ActionController::TestCase</code>, so I have access to all sorts of helper methods; I just can't find the right one.</p>
  
  <p>Of course I could use <code>URI.parse</code> to get the params part of the URL, then split it on <code>/&amp;|?/</code> and then split again on <code>'='</code>, but I'm hoping this is already done for me.  Plus, what if I miss some obscure rule in URL escaping or parameter parsing?  There <em>has</em> to be something in <code>ActionPack</code> or <code>ActiveSupport</code> to do this, but I can't find it.</p>
  
  <p>Thanks :)</p>