Class: ElabsMatchers::Matchers::HaveFormErrorsOn::HaveFormErrorsOnMatcher

Inherits:
Struct
  • Object
show all
Defined in:
lib/elabs_matchers/matchers/have_form_errors_on.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#fieldObject

Returns the value of attribute field

Returns:

  • (Object)

    the current value of field



8
9
10
# File 'lib/elabs_matchers/matchers/have_form_errors_on.rb', line 8

def field
  @field
end

#messageObject

Returns the value of attribute message

Returns:

  • (Object)

    the current value of message



8
9
10
# File 'lib/elabs_matchers/matchers/have_form_errors_on.rb', line 8

def message
  @message
end

#pageObject (readonly)

Returns the value of attribute page.



9
10
11
# File 'lib/elabs_matchers/matchers/have_form_errors_on.rb', line 9

def page
  @page
end

Instance Method Details

#does_not_match?(page) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
22
# File 'lib/elabs_matchers/matchers/have_form_errors_on.rb', line 19

def does_not_match?(page)
  @page = page
  page.has_no_field?(field) || page.find_field(field).has_no_selector?(selector_type, selector, :text => message)
end

#failure_messageObject Also known as: failure_message_for_should



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/elabs_matchers/matchers/have_form_errors_on.rb', line 24

def failure_message
  if page.has_field?(field)
    error = page.find_field(field).all(selector_type, selector).first
    if not error
      "Expected field '#{field}' to have an error, but it didn't."
    elsif error.text != message
      "Expected error message on #{field} to be '#{message}' but was '#{error.text}'."
    end
  else
    "No such field #{field}."
  end
end

#failure_message_when_negatedObject Also known as: failure_message_for_should_not



38
39
40
# File 'lib/elabs_matchers/matchers/have_form_errors_on.rb', line 38

def failure_message_when_negated
  "Expected error message on '#{field}' not to be '#{message}' but it was."
end

#matches?(page) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
14
15
16
17
# File 'lib/elabs_matchers/matchers/have_form_errors_on.rb', line 11

def matches?(page)
  @page = page

  if page.has_field?(field)
    page.find_field(field).has_selector?(selector_type, selector, :text => message)
  end
end