Module: ElabsMatchers

Defined in:
lib/elabs_matchers.rb,
lib/elabs_matchers/version.rb,
lib/elabs_matchers/helpers/fixtures.rb,
lib/elabs_matchers/matchers/persist.rb,
lib/elabs_matchers/matchers/have_flash.rb,
lib/elabs_matchers/matchers/have_image.rb,
lib/elabs_matchers/matchers/have_fields.rb,
lib/elabs_matchers/matchers/have_header.rb,
lib/elabs_matchers/helpers/reload_record.rb,
lib/elabs_matchers/matchers/contain_hash.rb,
lib/elabs_matchers/matchers/only_include.rb,
lib/elabs_matchers/helpers/normalize_keys.rb,
lib/elabs_matchers/matchers/be_valid_with.rb,
lib/elabs_matchers/matchers/have_attribute.rb,
lib/elabs_matchers/matchers/have_form_errors_on.rb,
lib/elabs_matchers/helpers/select_year_and_month.rb

Defined Under Namespace

Modules: Helpers, Matchers

Constant Summary collapse

VERSION =
"2.0.0"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.attribute_selectorObject

Returns the value of attribute attribute_selector.



29
30
31
# File 'lib/elabs_matchers.rb', line 29

def attribute_selector
  @attribute_selector
end

.attribute_selector_typeObject

Returns the value of attribute attribute_selector_type.



29
30
31
# File 'lib/elabs_matchers.rb', line 29

def attribute_selector_type
  @attribute_selector_type
end

.flash_alert_selectorObject

Returns the value of attribute flash_alert_selector.



30
31
32
# File 'lib/elabs_matchers.rb', line 30

def flash_alert_selector
  @flash_alert_selector
end

.flash_alert_selector_typeObject

Returns the value of attribute flash_alert_selector_type.



30
31
32
# File 'lib/elabs_matchers.rb', line 30

def flash_alert_selector_type
  @flash_alert_selector_type
end

.flash_notice_selectorObject

Returns the value of attribute flash_notice_selector.



30
31
32
# File 'lib/elabs_matchers.rb', line 30

def flash_notice_selector
  @flash_notice_selector
end

.flash_notice_selector_typeObject

Returns the value of attribute flash_notice_selector_type.



30
31
32
# File 'lib/elabs_matchers.rb', line 30

def flash_notice_selector_type
  @flash_notice_selector_type
end

.form_errors_on_selectorObject

Returns the value of attribute form_errors_on_selector.



31
32
33
# File 'lib/elabs_matchers.rb', line 31

def form_errors_on_selector
  @form_errors_on_selector
end

.header_selectorObject

Returns the value of attribute header_selector.



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

def header_selector
  @header_selector
end

.header_selector_typeObject

Returns the value of attribute header_selector_type.



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

def header_selector_type
  @header_selector_type
end

.image_selectorObject

Returns the value of attribute image_selector.



32
33
34
# File 'lib/elabs_matchers.rb', line 32

def image_selector
  @image_selector
end

.image_selector_typeObject

Returns the value of attribute image_selector_type.



32
33
34
# File 'lib/elabs_matchers.rb', line 32

def image_selector_type
  @image_selector_type
end

.table_row_selectorObject

Returns the value of attribute table_row_selector.



33
34
35
# File 'lib/elabs_matchers.rb', line 33

def table_row_selector
  @table_row_selector
end

Class Method Details

.configure {|_self| ... } ⇒ Object

Configure ElabsMatchers to suit your needs. The spec/spec_helper.rb file is a good place to put your configurations in.

ElabsMatchers.configure do |config|
  config.header_selector = "//h1"
  config.header_selector_type = :xpath
  config.image_selector = lambda { |src| "img[src='#{src}']" }
end

Configurable options

header_selctor = String

The selector to use when finding header tags (Default: “h1,h2”)

header_selector_type = Symbol

The type of selector to use, :css or :xpath (Default: :css)

image_selctor = lamda

The selector to use when finding images (Default: see matcher)

image_selector_type = Symbol

The type of selector to use, :css or :xpath (Default: :css)

attribute_selector = lambda

A lambda that takes label and value as arguments and return a selector (Default: see matcher)

attribute_selector_type = Symbol

The type of selector to use, :css or :xpath (Default: :xpath)

flash_notice_selector = String

The selector to use when finding the flash notice (Default: “#flash.notice, #flash .notice, .flash.notice”)

flash_notice_selector_type = Symbol

The type of selector to use, :css or :xpath (Default: :css)

flash_alert_selector = String

The selector to use when finding the flash alert (Default: “#flash.alert, #flash .alert, .flash.alert”)

flash_alert_selector_type = Symbol

The type of selector to use, :css or :xpath (Default: :css)

form_errors_on_selector = String

A xpath expression to be used when finding associated error notices (Default: see matcher)

table_row_selector = lambda

A lambda that takes table row return a selector (Default: see matcher)

Yields:

  • (_self)

Yield Parameters:

  • _self (ElabsMatchers)

    the object that the method was called on



66
67
68
# File 'lib/elabs_matchers.rb', line 66

def configure
  yield self
end

.use_default_configuration!Object

Reset Elabs matchers to use the default configuration.



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/elabs_matchers.rb', line 74

def use_default_configuration!
  configure do |config|
    config.header_selector = "h1,h2"
    config.header_selector_type = :css

    config.image_selector = nil
    config.image_selector_type = :css

    config.attribute_selector = nil
    config.attribute_selector_type = :xpath

    config.flash_notice_selector = "#flash.notice, #flash .notice, .flash.notice"
    config.flash_notice_selector_type = :css
    config.flash_alert_selector = "#flash.alert, #flash .alert, .flash.alert"
    config.flash_alert_selector_type = :css

    config.form_errors_on_selector = nil

    config.table_row_selector = nil
  end
end