Sha256: 1f40f3fe3a4225cb94562e625bf3f003c7c9e365a143c2dc2c1f747ff7990902

Contents?: true

Size: 685 Bytes

Versions: 8

Compression:

Stored size: 685 Bytes

Contents

# frozen_string_literal: true

require 'eac_ruby_utils/core_ext'

module EhbrsRubyUtils
  module Bga
    class Session < ::SimpleDelegator
      module User
        # @return [Boolean]
        def logged?
          navigate.to(build_url('/player'))
          logged_username == username
        end

        # @return [String]
        def logged_username
          find_or_not_element(xpath: '//*[@id = "connected_username"]').attribute('innerHTML').strip
        end

        def on_logged(&block)
          unless logged?
            raise "Login failed for BoardGameUser user \"#{username}\"" unless login
          end

          block.call
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
ehbrs_ruby_utils-0.33.0 lib/ehbrs_ruby_utils/bga/session/user.rb
ehbrs_ruby_utils-0.32.0 lib/ehbrs_ruby_utils/bga/session/user.rb
ehbrs_ruby_utils-0.31.0 lib/ehbrs_ruby_utils/bga/session/user.rb
ehbrs_ruby_utils-0.30.0 lib/ehbrs_ruby_utils/bga/session/user.rb
ehbrs_ruby_utils-0.29.0 lib/ehbrs_ruby_utils/bga/session/user.rb
ehbrs_ruby_utils-0.28.0 lib/ehbrs_ruby_utils/bga/session/user.rb
ehbrs_ruby_utils-0.27.1 lib/ehbrs_ruby_utils/bga/session/user.rb
ehbrs_ruby_utils-0.27.0 lib/ehbrs_ruby_utils/bga/session/user.rb