黄瓜与Capybara / Rack-Test无法使用DELETE路线

时间:2013-10-23 00:13:07

标签: ruby-on-rails cucumber capybara rack-test

我正在尝试运行涉及Devise的黄瓜测试,下面的代码失败了:

When /^I logout$/ do
   page.driver.submit :delete, destroy_user_session_path, {}
end

我收到的错误消息是:

No route matches [GET] "/" (ActionController::RoutingError)
./features/steps/authentication_steps.rb:16:in `/^I logout$/'
./features/steps/authentication_steps.rb:11:in `/^I am not logged in$/
features/authentication_admin.feature:8:in `And I am not logged in'

然而,当我做一个rake路线RAILS_ENV = test

时,路线确实出现在我的路线中
destroy_user_session DELETE /users/sign_out(.:format)    devise/sessions#destroy

有什么想法可以帮助我调试?谢谢!

1 个答案:

答案 0 :(得分:1)

IMO - Devise是一款经过良好测试的宝石。 可能没有必要测试注销方法。

我宁愿使用RSpec测试正确href的注销按钮的存在。

或者在Controller Spec中使用Warden测试模式 - 如果您想测试某些特定行为。