assert_redirected_to category_path(assigns(:category)) this line for example..when i use it in my code def test_should_create_category login_as :admin assert_difference Category, :count, 1 do post :create, :category => { } end assert_redirected_to category_path(assigns(:category)) end i get an error sayin undefined method category_path where is this defined?? where should i define it? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
> assert_redirected_to category_path(assigns(:category)) > > this line for example..when i use it in my code > > def test_should_create_category > login_as :admin > assert_difference Category, :count, 1 do > post :create, :category => { } > end > assert_redirected_to category_path(assigns(:category)) > end > > i get an error sayin > undefined method category_path > > where is this defined?? > > where should i define it? >category_path and category_url is two methods that will be created by ActionController::Routing if you have defined a named route category like: map.category ''category'', :controller => ''category'', :action => ''index'' -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Dec 8, 12:39 am, Kristian Hellquist <kristian.hellqu...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > assert_redirected_to category_path(assigns(:category)) > > > this line for example..when i use it in my code > > > def test_should_create_category > > login_as :admin > > assert_difference Category, :count, 1 do > > post :create, :category => { } > > end > > assert_redirected_to category_path(assigns(:category)) > > end > > > i get an error sayin > > undefined method category_path > > > where is this defined?? > > > where should i define it? > > category_path and category_url is two methods that will be created by > ActionController::Routing if you have defined a named route category > like: > > map.category ''category'', :controller => ''category'', :action => ''index''thanks for the suggestion.. but now i m getting a new error sayin 5) Error: test_should_create_category(CategoriesControllerTest): TypeError: can''t convert Fixnum into String test/functional/Categories_controller_test.rb:47:in `test_should_create_category'' my test case is def test_should_create_category1 assert_difference Category.count, 1 do post :create, :category => {:name => sss,:num_books => 5, :buyin =>5 } end assert_redirected_to category_path(assigns(:categories)) end -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Dec 11, 9:11 pm, sanjanad <d_sanja...-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> wrote:> On Dec 8, 12:39 am, Kristian Hellquist <kristian.hellqu...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > def test_should_create_category1 > assert_difference Category.count, 1 do > post :create, :category => {:name => sss,:num_books => 5, :buyin > =>5 }Check the docs for assert_difference - the first argument should be a string Fred -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.