Module: Howitzer

Defined in:
lib/howitzer.rb,
lib/howitzer/log.rb,
lib/howitzer/web.rb,
lib/howitzer/meta.rb,
lib/howitzer/cache.rb,
lib/howitzer/email.rb,
lib/howitzer/utils.rb,
lib/howitzer/version.rb,
lib/howitzer/web/page.rb,
lib/howitzer/gmail_api.rb,
lib/howitzer/exceptions.rb,
lib/howitzer/meta/entry.rb,
lib/howitzer/mailgun_api.rb,
lib/howitzer/meta/iframe.rb,
lib/howitzer/web/section.rb,
lib/howitzer/mailtrap_api.rb,
lib/howitzer/meta/actions.rb,
lib/howitzer/meta/element.rb,
lib/howitzer/meta/section.rb,
lib/howitzer/web/page_dsl.rb,
lib/howitzer/mail_adapters.rb,
lib/howitzer/web/blank_page.rb,
lib/howitzer/web/iframe_dsl.rb,
lib/howitzer/web/element_dsl.rb,
lib/howitzer/web/section_dsl.rb,
lib/howitzer/capybara_helpers.rb,
lib/howitzer/gmail_api/client.rb,
lib/howitzer/web/base_section.rb,
lib/howitzer/mailgun_api/client.rb,
lib/howitzer/web/page_validator.rb,
lib/howitzer/mail_adapters/gmail.rb,
lib/howitzer/mailtrap_api/client.rb,
lib/howitzer/mailgun_api/response.rb,
lib/howitzer/mail_adapters/mailgun.rb,
lib/howitzer/mailgun_api/connector.rb,
lib/howitzer/mail_adapters/abstract.rb,
lib/howitzer/mail_adapters/mailtrap.rb,
lib/howitzer/utils/string_extensions.rb,
lib/howitzer/web/capybara_context_holder.rb,
lib/howitzer/web/capybara_methods_proxy.rb

Overview

:nocov:

Defined Under Namespace

Modules: Cache, CapybaraHelpers, GmailApi, MailAdapters, MailgunApi, MailtrapApi, Meta, Utils, Web Classes: Email, Log

Constant Summary collapse

VERSION =

:nodoc:

'2.2.0'.freeze
CommunicationError =

:nodoc:

Class.new(StandardError)
ParseError =

:nodoc:

Class.new(StandardError)
InvalidApiKeyError =

:nodoc:

Class.new(StandardError)
BadElementParamsError =

:nodoc:

Class.new(StandardError)
NoValidationError =

:nodoc:

Class.new(StandardError)
UnknownValidationError =

:nodoc:

Class.new(StandardError)
EmailNotFoundError =

:nodoc:

Class.new(StandardError)
NoAttachmentsError =

:nodoc:

Class.new(StandardError)
DriverNotSpecifiedError =

:nodoc:

Class.new(StandardError)
UnknownDriverError =

:nodoc:

Class.new(StandardError)
CloudBrowserNotSpecifiedError =

:nodoc:

Class.new(StandardError)
SelBrowserNotSpecifiedError =

:nodoc:

Class.new(StandardError)
UnknownBrowserError =

:nodoc:

Class.new(StandardError)
IncorrectPageError =

:nodoc:

Class.new(StandardError)
AmbiguousPageMatchingError =

:nodoc:

Class.new(StandardError)
NoMailAdapterError =

:nodoc:

Class.new(StandardError)
NoPathForPageError =

:nodoc:

Class.new(StandardError)
NoEmailSubjectError =

:nodoc:

Class.new(StandardError)
NoDataError =

:nodoc:

Class.new(StandardError)
UndefinedElementError =

:nodoc:

Class.new(StandardError)
UndefinedSexySettingError =

:nodoc:

Class.new(StandardError)

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.current_rake_taskObject

Returns the value of attribute current_rake_task


71
72
73
# File 'lib/howitzer.rb', line 71

def current_rake_task
  @current_rake_task
end

Class Method Details

.app_uri(name = nil) ⇒ Object

Returns an application uri for particular application name

Examples:

returns default application url with auth

app_uri.site

returns example application url with auth

app_uri(:example).site

returns default application url without auth

app_uri.origin

Parameters:

  • name (Symbol, String) (defaults to: nil)

    an application name from framework settings

Returns:

  • an application uri for particular application name


85
86
87
88
89
90
91
92
93
# File 'lib/howitzer.rb', line 85

def self.app_uri(name = nil)
  prefix = "#{name}_" if name.present?
  ::Addressable::URI.new(
    user: Howitzer.sexy_setting!("#{prefix}app_base_auth_login"),
    password: Howitzer.sexy_setting!("#{prefix}app_base_auth_pass"),
    host: Howitzer.sexy_setting!("#{prefix}app_host"),
    scheme: Howitzer.sexy_setting!("#{prefix}app_protocol") || 'http'
  )
end

.mailgun_idle_timeoutObject

Deprecated.

27
28
29
30
# File 'lib/howitzer.rb', line 27

def mailgun_idle_timeout
  puts "WARNING! 'mailgun_idle_timeout' setting is deprecated. Please replace with 'mail_wait_time' setting."
  ::SexySettings::Base.instance.all['mailgun_idle_timeout']
end

.session_nameObject

Returns active session name

Returns:

  • active session name


34
35
36
# File 'lib/howitzer.rb', line 34

def session_name
  @session_name ||= 'default'
end

.session_name=(name) ⇒ Object

Sets new session name

Howitzer.session_name = 'browser2' LoginPage.on do

expect(title).to eq('Login Page')

end

# Switching back to main browser Howitzer.session_name = 'default'

Examples:

Executing code in another browser

Parameters:

  • name (String)

    string identifier for the session


51
52
53
54
# File 'lib/howitzer.rb', line 51

def session_name=(name)
  @session_name = name
  Capybara.session_name = @session_name
end

.sexy_setting!(name) ⇒ Object

Returns an setting value or raise error

Parameters:

  • name (Symbol, String)

    an setting name

Returns:

  • an setting value or raise error

Raises:


100
101
102
103
104
105
# File 'lib/howitzer.rb', line 100

def self.sexy_setting!(name)
  return Howitzer.public_send(name) if Howitzer.respond_to?(name)

  raise UndefinedSexySettingError,
        "Undefined '#{name}' setting. Please add the setting to config/default.yml:\n #{name}: some_value\n"
end

.using_session(name) ⇒ Object

Yield a block using a specific session name

Howitzer.using_session('browser2') do

LoginPage.on do
  expect(title).to eq('Login Page')
end

end

Examples:

Opening page in another browser

Parameters:

  • name (String)

    string identifier for the session


67
68
69
# File 'lib/howitzer.rb', line 67

def using_session(name)
  Capybara.using_session(name) { yield }
end