다음과 같은 스펙이 있습니다.Rails Capybara 로그인 할 수 없습니다.
it 'should login with correct user/password',
js: true, driver: :selenium do
visit new_user_session_path
fill_in 'user_email', with: user.email
fill_in 'user_password', with: user.password
click_on 'loginButton'
expect_current_path(home_path)
end
driver: :selenium
을 제거하면 작동합니다. 나는 그것이 거래를위한 RSpec Configuration 때문이라고 생각했다. 따라서 Database Cleaner를 추가하고 config.use_transactional_fixtures = false
을 비활성화했습니다. 그러나 여전히 실패했다. 나는 다음과 같이 Devise (devise-4.2.1/l ib/devise/strategies/database_authenticatable.rb)를 디버깅했다.
def authenticate!
resource = password.present? && mapping.to.find_for_database_authentication(authentication_hash)
hashed = false
debugger
if validate(resource){ hashed = true; resource.valid_password?(password) }
remember_me(resource)
resource.after_database_authentication
success!(resource)
end
mapping.to.new.password = password if !hashed && Devise.paranoid
fail(:not_found_in_database) unless resource
end
확인한 결과 mapping.to.find_for_database_authentication(authentication_hash)
은 원하는대로 사용자를 반환합니다. 그러나 validate(resource)
은 (는) 셀렌 ON이 실패했습니다. 나는 그것에 더 많은 것을 조사했고, def self.compare(klass, hashed_password, password)
이 근본 원인 (devise-4.2.1/l ib/devise/encryptor.rb에서)이라는 것을 알았다.
그래서 주된 이유는 암호를 비교할 수 없었기 때문입니다. 암호화와 관련이 있다고 생각합니다. 누군가 도울 수 있습니까?