Failing to test Devise with Capybara

前端 未结 3 1426
轻奢々
轻奢々 2021-01-02 01:12

I\'m building a Rails 3 app using Devise, with Capybara for UI testing. The following test is failing:

class AuthenticationTest < ActionController::Integ         


        
3条回答
  •  [愿得一人]
    2021-01-02 02:04

    I've run into a similar problem before. Setting the password directly has some weird effects because it's supposed to be encrypted and stored with a salt--sometimes it works for me and other times it doesn't. I have a hard time remembering which specific cases were problematic. I'd recommend the following, in this order (for simplicity)

    • Verify that the password field is getting filled in properly and passed as the right param (not necessary if you're using Devise's autogenerated view and haven't touched it)
      • if your site can run in development mode (i.e. no log in bugs), then just boot it up and log in manually
      • If not, insert debugger as the first line in your sessions_controller. Then check params and make sure the password is correct and in params[:user][:password].

        If you didn't override Devise's sessions_controller, then you can find your Devise path with bundle show devise. Then look for the create action within (devise path)/app/controllers/devise/sessions_controller.rb
    • Change your test setup to create a user through the web interface, to ensure the password gets set properly, then try running your test again

提交回复
热议问题