Sha256: c77f309f0812b4db2c21f1491e641f7ec2d11edd653f5af610cf3b26e1481ab2

Contents?: true

Size: 842 Bytes

Versions: 2

Compression:

Stored size: 842 Bytes

Contents

# frozen_string_literal: true

require 'capybara/dsl'

module Balboa
  module Interactor
    module Command
      class LoginCommand
        include Capybara::DSL

        SUCCESS_MESSAGE = 'Login efetuado com sucesso!'.freeze

        LoginFailure = Class.new(RuntimeError)

        def initialize(options)
          @options = options
        end

        def execute
          visit_sign_in_path

          fill_form

          confirm
        end

        private

        def visit_sign_in_path
          visit('/users/sign_in')
        end

        def fill_form
          fill_in 'E-mail', with: @options['email']
          fill_in 'Password', with: @options['password']
        end

        def confirm
          click_button 'Log in'

          raise LoginFailure unless body[SUCCESS_MESSAGE]
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
balboa-0.1.6 lib/balboa/interactor/command/login_command.rb
balboa-0.1.5 lib/balboa/interactor/command/login_command.rb