[rspec-users] Testing a nested controller
rubyphunk at googlemail.com
Fri Sep 14 05:15:22 EDT 2007
Ok. this was stupid :) I found the answer two minutes later:
You cannot use the url helper here, but if you provide the writers id
in the request everything works fine:
testing the route:
route_for(:controller => "notes", :action => "show", :id => 1, :writer_id => 1)
testing the request by:
get :show, :id => 1, :writer_id => 1
On 9/14/07, Andreas Wolff <rubyphunk 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
> In my notes_controller_spec.rb
> def do_get
> writer_id = 1
> note_id = 1
> get note_path(writer_id, note_id)
> it "should show a note" do
> response.should be_success
> 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??
> Andreas Wolff
http://rubyblog.de | http://activerails.de
More information about the rspec-users