Today, when I try to run my plugin test, I needed the answer to this question. And I found, here is the answer:
# start console rails c # if you want to start with another env, you can use this command: RAILS_ENV=test rails c
# find your user by login name user = User.where(login: 'admin').first
# set new password like this example user.password = '123456789' user.password_confirmation = '123456789'
# and save the user in last step with this command user.save!