Class: Booth::Testing::Support::AssertLoggedIn
- Inherits:
-
Object
- Object
- Booth::Testing::Support::AssertLoggedIn
- Includes:
- Logging, Calls, Capybara::DSL
- Defined in:
- lib/booth/testing/support/assert_logged_in.rb
Defined Under Namespace
Classes: AssertionFailedError
Instance Method Summary collapse
Instance Method Details
#call ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/booth/testing/support/assert_logged_in.rb', line 16 def call # tries ||= 0 ::::Lockstep.synchronize browser_session_id = nil active_sessions.each do |session| browser_session_id = ::Booth::Testing::Support::GetSessionValue.call(key:) return true if browser_session_id == session.id.to_s end attributes = { expected_username: credential.username, expected_credential_id: credential.id, expected_session_ids: active_sessions.map(&:id), actual_session_id: browser_session_id, } raise AssertionFailedError, "Expected to be logged in. #{attributes}" # "Expected Credential `#{credential.id}` to be logged in with a session of: #{active_sessions.map(&:id)}" # With the Webauth pingpong it sometimes takes a little longer. # And Capybara Lockstep doesn't seem to be able to detect that. # rescue AssertionFailedError # if (tries += 1) < 3 # log { 'Trying again...' } # sleep 1 # retry # end # raise end |