Search code examples
ruby-on-railscucumbercapybararack-test

Cucumber with Capybara/Rack-Test not working with DELETE route


I'm trying to run a cucumber test involving Devise and the code below is failing:

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

The error message I receive is:

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'

However, the route does appear in my routes when I do a rake routes RAILS_ENV=test

destroy_user_session DELETE /users/sign_out(.:format)    devise/sessions#destroy

Any ideas to help me debug? Thanks!


Solution

  • IMO - Devise is a well-tested gem. Probably no point to test logout method.

    I'd rather test presence of logout button with correct href using RSpec.

    Or use Warden test mode in Controller Spec - in case you want to test some specific behavior.