Q:

rails devise testing issue using a fixture (unauthorized access)

I have some issues testing a basic devise login using minitest.
My test: 
 test "user can sign in" do
    @user = users(:someoneelse)
    get new_user_session_path
    assert_select "strong", "log in"
    post user_session_path, user: {  email:       @user.email,
                                   password:    @user.password,
                                   }
   assert_redirected_to root_path
  end

The fixture
someoneelse:
  email: someoneelse@whatever.com
  encrypted_password: <%= Devise::Encryptor.digest(User, 'password') %>
  created_at: <%= Time.zone.now %>

The test result:
 test_user_can_sign_in#UserFlowTest (0.81s)
        Expected response to be a <3XX: redirect>, but was a <200: OK>
        test/integration/user_flow_test.rb:17:in `block in <class:UserFlowTest>'

The log tail
Started POST "/users/sign_in" for 127.0.0.1 at 2017-02-19 14:06:28 -0600
Processing by Devise::SessionsController#create as HTML
  Parameters: {"user"=>{"email"=>"someoneelse@whatever.com", "password"=>"[FILTERED]"}}
Completed **401 Unauthorized in 1ms** (ActiveRecord: 0.0ms)
Processing by Devise::SessionsController#new as HTML

It looks the user is unauthorized. Is there something wrong with the fixture?
Also how can I get minitest to be more verbose?
Thanks.

A:

Use 'password' in your test instead of using @user.password. The model has no idea what password it's stored after it's been saved.

