Class: Booth::Testing::Support::AssertLoggedOut

Inherits:
Object
  • Object
show all
Includes:
Logging, Calls, Capybara::DSL
Defined in:
lib/booth/testing/support/assert_logged_out.rb

Instance Method Summary collapse

Instance Method Details

#callObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/booth/testing/support/assert_logged_out.rb', line 13

def call
  browser_session_id = nil

  begin
    ::Timeout.timeout(Capybara.default_max_wait_time) do
      loop do
        log { 'Polling to see if logged out...' }
        browser_session_id = ::Booth::Testing::Support::CookieDataFromBrowser.call["warden.user.#{scope}.key"]

        # If no session cookie or it's empty, user is logged out
        return true unless browser_session_id

        sleep 0.1
      end
    end
  rescue ::Timeout::Error
    # Timed out
  end

  raise 'Expected nobody to be logged out, but a session cookie exists.'
end