Sha256: 237622aa7e380ce391385d5feaf189b601d9c08e6542e5e4e5abfc9046fe0095

Contents?: true

Size: 895 Bytes

Versions: 1

Compression:

Stored size: 895 Bytes

Contents

# frozen_string_literal: true

require 'capybara/dsl'

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

        SuccessMessage = '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 'Sign in'
          find('p', text: SuccessMessage)
        rescue Capybara::ElementNotFound
          raise LoginFailure
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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