0

I have this in my test:

let!(:user) { create(:user) }

When I run test without :js

def create
   11:     byebug
=> 12:     if @user = login(params[:email], params[:password])
   13:       logger.info "--------------"
   14:       logger.info "found user"
   15:       redirect_back_or_to root_path, notice: t(:log_in_is_successful_notice)
   16:     else
(byebug) User.all
#<ActiveRecord::Relation [#<User id: 291, email: "[email protected]", crypted_password: "$2a$10$rOKscDDidaf93p/e9IOceOCGozns5AJ2zSLMO68jRZO...", created_at: "2016-06-22 20:15:55", updated_at: "2016-06-22 20:15:55", salt: "qpSR5US81thfoTn8pphQ", remember_me_token: nil, remember_me_token_expires_at: nil, reset_password_token: nil, reset_password_token_expires_at: nil, reset_password_email_sent_at: nil, current_block_id: nil, locale: "ru">]>

But when I run this test with :js, I got this:

 11:     byebug
=> 12:     if @user = login(params[:email], params[:password])
   13:       logger.info "--------------"
   14:       logger.info "found user"
   15:       redirect_back_or_to root_path, notice: t(:log_in_is_successful_notice)
   16:     else
(byebug) User.all
#<ActiveRecord::Relation []>
(byebug) User.all.take
nil

I'm using webkit as js driver:

Capybara.javascript_driver = :webkit
1
  • What is your question? Commented Jun 22, 2016 at 22:50

1 Answer 1

1

You have not disabled transactional testing so objects created in your test thread are not visible in your apps thread. You need to read the Transactions and Database Setup section of the Capybara README, and then configure something like database_cleaner to handle switching database strategies for you

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.