Sha256: 2f76c59bae09cde14aa00941248a3fa84e3139a44ad05c3ffad316c9d1d73d55

Contents?: true

Size: 855 Bytes

Versions: 1

Compression:

Stored size: 855 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(email, password)
          @email = email
          @password = password
        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: @email
          fill_in 'Password', with: @password
        end

        def confirm
          click_button 'Log in'

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
balboa-0.1.7 lib/balboa/interactor/command/login_command.rb