Forum: RSpec route_for()

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
4d6cd907dcbed99b2c472a5e652dce6b?d=identicon&s=25 Anita Anita (anita)
on 2008-10-08 23:41
Hello,

Can I test in the spec the route taken by the redirect_to from the
controller? The URL is not controller/action.
I tried:
route_for(:controller => "signup", :action => "confirmation").should ==
"/my/set/URL" but no it absolutely wants: ...should ==
"signup/confirmation"
So how can I test my real URL?

Thank you,
Anita.
F86901feca747abbb5c6c020362ef2e7?d=identicon&s=25 Zach Dennis (zdennis)
on 2008-10-08 23:47
(Received via mailing list)
Look at the below, I think it entails what you want:

describe YourController do
   it "redirects to the home page" do
        get :index
        response.should redirect_to("your_path_here")
   end
end

Zach

On Wed, Oct 8, 2008 at 5:41 PM, Anita Anita <lists@ruby-forum.com>
wrote:
> Thank you,
> Anita.
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> rspec-users mailing list
> rspec-users@rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>



--
Zach Dennis
http://www.continuousthinking.com
http://www.mutuallyhuman.com
944f769c99deff7aa8bc3b5b93830b7a?d=identicon&s=25 Scott Taylor (Guest)
on 2008-10-08 23:47
(Received via mailing list)
On Oct 8, 2008, at 5:41 PM, Anita Anita wrote:

> Hello,
>
> Can I test in the spec the route taken by the redirect_to from the
> controller? The URL is not controller/action.
> I tried:
> route_for(:controller => "signup", :action => "confirmation").should
> ==
> "/my/set/URL" but no it absolutely wants: ...should ==
> "signup/confirmation"
> So how can I test my real URL?

There may be a more straightforward way, but params_from may help:

http://rspec.info/rdoc-rails/classes/Spec/Rails/Ex...

Scott
This topic is locked and can not be replied to.