class Balboa::Interactor::CapybaraInteractor

Constants

CommandNotFound
LoginCommandNotFound

Attributes

options[R]
signed_in[RW]

Public Class Methods

new(options = {}) click to toggle source
# File lib/balboa/interactor/capybara_interactor.rb, line 12
def initialize(options = {})
  @options = options
  @commands = Hash.new { raise CommandNotFound }
  @signed_in = false
end

Public Instance Methods

add_command(key, command) click to toggle source
# File lib/balboa/interactor/capybara_interactor.rb, line 18
def add_command(key, command)
  @commands[key.to_s] = command
end
last() click to toggle source
# File lib/balboa/interactor/capybara_interactor.rb, line 22
def last
  login unless signed_in?
  @commands['last'].execute
end
punch(date) click to toggle source
# File lib/balboa/interactor/capybara_interactor.rb, line 27
def punch(date)
  login unless signed_in?
  @commands['punch'].execute(date)
end

Private Instance Methods

login() click to toggle source
# File lib/balboa/interactor/capybara_interactor.rb, line 40
def login
  @commands['login'].execute

  @signed_in = true
rescue CommandNotFound
  raise LoginCommandNotFound
end
signed_in?() click to toggle source
# File lib/balboa/interactor/capybara_interactor.rb, line 36
def signed_in?
  signed_in
end