开发者

How do you test namespace post :post routes?

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜