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:


46
47
48
# File 'lib/howitzer/utils/string_extensions.rb', line 46

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:


37
38
39
# File 'lib/howitzer/utils/string_extensions.rb', line 37

def as_page_class
  as_class('Page')
end

#displayed?Boolean

Waits until a page is opened or raises error

Examples:

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

See Also:


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

def displayed?
  as_page_class.displayed?
end

#givenObject

Returns an instantiated page by name

Examples:

'home'.given #=> HomePage.given

See Also:


19
20
21
# File 'lib/howitzer/utils/string_extensions.rb', line 19

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

55
56
57
# File 'lib/howitzer/utils/string_extensions.rb', line 55

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

#open(*args) ⇒ Object

Opens a page by name

Examples:

'home'.open #=> HomePage.open

See Also:


10
11
12
# File 'lib/howitzer/utils/string_extensions.rb', line 10

def open(*args)
  as_page_class.open(*args)
end