Module: Howitzer::Utils::StringExtensions

Defined in:
lib/howitzer/utils/string_extensions.rb

Overview

This module extends standard String class with useful methods for Cucumber step definitions

Instance Method Summary collapse

Instance Method Details

#as_email_classObject

Returns an email class by name

Examples:

'Reset Password'.as_email_class #=> ResetPasswordEmail

See Also:



50
51
52
# File 'lib/howitzer/utils/string_extensions.rb', line 50

def as_email_class
  as_class('Email')
end

#as_page_classObject

Returns a page class by name

Examples:

'home'.as_page_class #=> HomePage

See Also:



41
42
43
# File 'lib/howitzer/utils/string_extensions.rb', line 41

def as_page_class
  as_class('Page')
end

#displayed?Boolean

Waits until a page is opened or raises error

Examples:

'home'.displayed? #=> HomePage.displayed?

Returns:

  • (Boolean)

See Also:



32
33
34
# File 'lib/howitzer/utils/string_extensions.rb', line 32

def displayed?
  as_page_class.displayed?
end

#givenObject

Returns an instantiated page by name

Examples:

'home'.given #=> HomePage.given

See Also:



23
24
25
# File 'lib/howitzer/utils/string_extensions.rb', line 23

def given
  as_page_class.given
end

#on(&block) ⇒ Object

Executes code in context of the page

Examples:

'home'.on { puts 1 } #=> HomePage.on { puts 1 }

See Also:

  • Web::Page.on


59
60
61
# File 'lib/howitzer/utils/string_extensions.rb', line 59

def on(&block)
  as_page_class.on(&block)
end

#open(*args, **options) ⇒ Object

Opens a page by name

Examples:

'home'.open #=> HomePage.open

See Also:



10
11
12
13
14
15
16
# File 'lib/howitzer/utils/string_extensions.rb', line 10

def open(*args, **options)
  if options.present?
    as_page_class.open(*args, **options)
  else
    as_page_class.open(*args)
  end
end