Reputation: 21564
IN this example: https://github.com/RailsApps/rails3-devise-rspec-cucumber
I get an error because doing visit('/users/sign_out') (in capybara..to ensure a user is logged out) fails. The problem is there's no route for a GET to that path, since devise changed it to DELETE(and capybara doesn't support PUT and DELETE without some js workarounds)
What are your suggestions in doing the "Given I am an unauthenticated user" step? how do you guys usually do it? I am hoping there's an easy way out of this like 1-2 lines of ruby.
at the moment, i just do :
Given "i am an unauthenticated user" do
@user == nil
end
but it sure doesn't look like it's testing anything.
Upvotes: 2
Views: 463
Reputation: 12605
Yeah - this has been a bit of a pain for lotsa folks.
The easiest way to get around it is to throw this in your /config/initializers/devise.rb file:
config.sign_out_via = Rails.env.test? ? :get : :delete
This will use the old get method for your test environment, and delete for all others.
Upvotes: 4