I have these route
# routes.rb
name开发者_JAVA百科space :admin do
resources :departments
end
And following code in controller test. It fails because post :create is not heading to admin_departments_path. What is the correct way to write this?
# test/functional/admin/departments_controller_test.rb
# ActionController::RoutingError: No route matches (FAIL)
post :create, :department => @new_department.attributes
Controller tests are needlessly painful and too closely coupled to implementation. Don't use them.
The correct way to do this is to write a Cucumber scenario that posts something to the form, then checks that you ended up on the page you wanted to.
精彩评论