<?xml version="1.0" encoding="UTF-8"?>
<post>
  <body>I could not just use the standard __response.should redirect  to()__ because the response was actually rendering html that was outputting a javascript redirect.

In the end it turned out that it was quite simple.  Here is the code:

bc(ruby).. it "should redirect to cropping controller" do
    do_put # (not shown)
    response.body.should =~ /#{my_account_cropping_url(@traveller)}/
end

p. Basically the *do_put* is a method call that I have defined which issues a __put__ request.  The _response_ has a body element that issues a javascript redirect.  We then check to see if the expected url is included in the body.  If it is we can assume that the redirect is working.

Let me know if there is a better way of doing this.  I don't have any issues with the above implementation though.

Picture taken from "getdown":http://www.flickr.com/photos/getdown/2107792115/ </body>
  <category-id type="integer">1</category-id>
  <comments-count type="integer">48</comments-count>
  <created-at type="datetime">2009-01-26T00:00:00Z</created-at>
  <id type="integer">28</id>
  <live type="boolean">true</live>
  <slug>rspec-rjs-redirect</slug>
  <summary>!http://hamza.khan-cheema.com/images/diversion.jpg!

Recently I wanted to use RSpec to test if a javascript request to my controller was being redirect to the correct place.  I was using _page.redirect_ like so:

&lt;br clear="all"/&gt;

bc(ruby).. render :update do |page|
    page.redirect_to edit_my_account_cropping_url(resource.id)
end</summary>
  <title>RSpec - RJS redirect (page.redirect_to)</title>
  <updated-at type="datetime">2009-01-26T19:46:58Z</updated-at>
  <user-id type="integer">1</user-id>
</post>
