开发者

How do I test the Devise registration process?

开发者 https://www.devze.com 2023-02-14 09:10 出处:网络
I recently added the Devise engine 开发者_运维技巧to a project with an existing authentication system (from the Rails Tutorial).

I recently added the Devise engine 开发者_运维技巧to a project with an existing authentication system (from the Rails Tutorial).

Before I added Devise, my UsersController handled all user registration facilities new, create, edit, destroy and I had a lot of rspec tests written for them. Of course now that registration is handled by Devise, I've had to remove those tests from users_controller_spec.rb.

Where can I put those tests to ensure that the Devise registration process is working correctly?

EDIT:

Ok I believe I've made some progress with this since I posted the question.

First I overrided the Devise registrations controller by making my own RegistrationsController in /app/controllers/registrations_controller.rb.

class RegistrationsController < Devise::RegistrationsController

end

Then I tell Devise to use this controller for registrations in my /config/routes.rb file:

devise_for :users, :controllers => { :registrations => "registrations" }

Now all I need to do it make my tests in /spec/controllers/registrations_controller_spec.rb work.

Am I on the right track?


That would be a good solution if you planned on overriding some of the controller methods. Typically, you don't test other frameworks like this that already have their own suite of tests. You are just duplicating the tests. That said, if you are more comfortable having your own, go for it.

0

精彩评论

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