ruby on rails - Can't sign in with FactoryGirl's user/data -


i have sign in user before doing tests use js. sign in page work (except on test).

require 'spec_helper' require 'capybara/poltergeist' include capybara::dsl capybara.javascript_driver = :poltergeist      describe "application", js: true    describe "when logged in", js: true     let(:user) { factorygirl.create(:user) }     before       visit signin_path       fill_in "email", with: user.email       fill_in "password", with: user.password       click_button "sign in"     end     "can authenticate user"       user.all.first.authenticate(user.password).email.should == user.email     end   end end 

the problem clicking "sign in" button returns page "invalid user/password" combination (as if user not in db). thing apparently use in database , password right (the test "can authenticate user" passes).

i took screenshot before clicking "sign in" button , fields populated correctly. tried create user inside before block didn't work either.

the sign in page doesn't have special, no javascript or anything. normal form post server.

any ideas?

this happening me while ago while using rspec , poltergeist. problem phantomjs thread wasn't able see record created factorygirl in db. solve problem, have configure db connection shared in spec_helper.rb adding code below.

class activerecord::base   mattr_accessor :shared_connection   @@shared_connection = nil    def self.connection     @@shared_connection || retrieve_connection   end end  # forces threads share same connection. works on # capybara because starts web server in thread. activerecord::base.shared_connection = activerecord::base.connection 

you can find more explanation here in point number 3.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -