[rspec-users] Can't access actions of a singular nested resource

aslak hellesoy aslak.hellesoy at gmail.com
Fri Aug 1 06:39:52 EDT 2008

On Fri, Aug 1, 2008 at 10:41 AM, Bastien <bastien.vaucher at gmail.com> wrote:
> Thanks for your help Aslak, but I still didn't manage to make it pass
>>> get :show, :id=>"34"
> it sends me this error then : No route matches
> {:action=>"show", :controller=>"surveys/report", :id=>"34"}
>>> Try rake routes, and also try to spec the routing in the associated
>>> routing_spec.rb.
> and this test passes :
>  it "should map { :controller => 'report', :action =>
> 'show', :survey_id => 1} to /survey/1/report" do
>      route_for(:controller => "surveys/report", :action =>
> "show", :survey_id => 1).should == "/surveys/1/report"
> end
> also if I try to remove my condition the test passes so the routes
> must be correct
> it "should return the survey corresponding to the report" do
>    #Survey.should_receive(:find)
>    get :show, :survey_id=>"34", :controller =>"surveys/report"
>  end

Actually, that's a sign that you're *not* hitting the desired #show
method. Survey.find("34") will fail with RecordNotFound unless you
have a survey with id=34 in your test db (unlikely).

> Any other idea ?

Maybe you have a filter in your controller that prevents show from
being called? I'd resort to some good old puts debugging..

BTW, I just committed some specs based on your code, and they pass:


> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users

More information about the rspec-users mailing list