ruby on rails - Authlogic session in Capybara doesn't exist immediately -
my spec:
let(:user) { factorygirl.create(:user) } context 'when user logged in' scenario 'log in' visit login_path within '.new_user_session' fill_in 'username', with: user.email fill_in 'password', with: user.password click_on 'log in' end visit new_search_path expect(page).to have_text "welcome #{user.name}!" end end the issue when visiting new_search_path, though login in successful, page behaves if there no user logged in. if add sleep(1) call right before visit new_search_path, works fine.
anyone know why happening?
i'm using authlogic, capybara, , selenium.
the action triggered.by click_on can occur asynchronously. therefore, if visit after can cause login request abort , session cookies never set. solve need check page text/content indicates login has succeeded. like
expect(page).to have_text 'you logged in'
Comments
Post a Comment