[rspec-users] How to spec a controller method that involves an rjs redirect

Stephen Eley sfeley at gmail.com
Sat Jan 3 23:15:50 EST 2009


On Fri, Jan 2, 2009 at 11:01 AM, Nasir Jamal <nas35_in at yahoo.com> wrote:
>
> What is the best way to spec a controller method that involves an rjs
> redirect? Something like this

Consider:

response.should =~ /window\.location\.href = '(whatever your expected
path is)';/

I didn't confirm that regex, obviously.  But the concept is pretty
simple: if you know how the RJS redirect works and what Javascript is
supposed to be generated, then test for its presence in the response.
If it's there, your controller logic worked.



-- 
Have Fun,
   Steve Eley (sfeley at gmail.com)
   ESCAPE POD - The Science Fiction Podcast Magazine
   http://www.escapepod.org


More information about the rspec-users mailing list