[rspec-users] Testing nested controller

sinclair bain rspec.user at gmail.com
Wed Sep 26 16:19:44 EDT 2007


    get :show, :writer_id => "1", :note_id => "1"

This may also

    get :show, :writer_id => "1", :id => "1"

On 9/22/07, David Chelimsky <dchelimsky at gmail.com> wrote:
>
> Controller specs are similar to Rails functional tests, except that
> they don't render views (unless you tell them to). So rather than
> saying:
>
> get notes_path(1,1)
>
> you want to say:
>
> get :show, :writer_id => "1", :note_id => "1"
>
> Give that a shot and let us know if it works out.
>
> Cheers,
> David
>
> On 9/14/07, Andreas Wolff <thinkdiv at googlemail.com> wrote:
> > Hey everyone.
> > I really stuck on testing a nested controller. I'm trying to make a
> > request using get and afterwards checking the response by
> > response.should ...
> >
> > My routes.rb looks like this:
> >
> > map.resources :writers do |writers|
> >   writers.resources :notes
> > end
> >
> >
> > In my notes_controller_spec.rb
> >
> > def do_get
> >   writer_id = 1
> >   note_id = 1
> >   get note_path(writer_id, note_id)
> > end
> >
> > it "should show a note" do
> >   do_get
> >   response.should be_success
> > end
> >
> >
> > But this always ends in an error message:
> > You have a nil object when you didn't expect it!
> > The error occurred while evaluating nil.rewrite
> >
> > Can anybody help here??
> >
> > --
> > by(e)
> > Andreas Wolff
> > _______________________________________________
> > rspec-users mailing list
> > rspec-users at rubyforge.org
> > http://rubyforge.org/mailman/listinfo/rspec-users
> >
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070926/07229ae2/attachment.html 


More information about the rspec-users mailing list