Sha256: 4b0cd4c7de84f0e6a30b547f4ac89dd66b4202ce0e8492664a84684139ab6c38
Contents?: true
Size: 1.38 KB
Versions: 2
Compression:
Stored size: 1.38 KB
Contents
# frozen_string_literal: true require 'capybara/dsl' module Balboa module Interactor module Command class FillPunchCommand include Capybara::DSL TIME_TEMPLATE = '%02d:00'.freeze SUCCESS_MESSAGE = 'Punch foi criado com sucesso.'.freeze PunchCreationError = Class.new(RuntimeError) def initialize(options) @options = options end def execute(date) visit_new_punch_path fill_first_shift(date) visit_new_punch_path fill_second_shift(date) end private def visit_new_punch_path visit('/punches/new') end def fill_first_shift(date) fill_form(date, @options['start_at'], @options['lunch_at']) end def fill_second_shift(date) fill_form(date, @options['restart_at'], @options['leave_at']) end def fill_form(date, start_time, finish_time) fill_in 'punch[from_time]', with: TIME_TEMPLATE % start_time fill_in 'punch[to_time]', with: TIME_TEMPLATE % finish_time fill_in 'punch[when_day]', with: date.to_s select @options['project'], from: 'punch[project_id]' confirm end def confirm click_button 'Criar Punch' fail PunchCreationError unless body[SUCCESS_MESSAGE] end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
balboa-0.1.4 | lib/balboa/interactor/command/fill_punch_command.rb |
balboa-0.1.3 | lib/balboa/interactor/command/fill_punch_command.rb |