Class: ElabsMatchers::Matchers::HaveFields::HaveFieldsMatcher

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#fieldsObject

Returns the value of attribute fields

Returns:

  • (Object)

    the current value of fields



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

def fields
  @fields
end

#pageObject (readonly)

Returns the value of attribute page.



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

def page
  @page
end

Instance Method Details

#does_not_match?(page) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
19
# File 'lib/elabs_matchers/matchers/have_fields.rb', line 16

def does_not_match?(page)
  @page = page
  fields.all? { |label, value| page.has_no_field?(label, :with => value) }
end

#failure_messageObject Also known as: failure_message_for_should



21
22
23
24
25
26
# File 'lib/elabs_matchers/matchers/have_fields.rb', line 21

def failure_message
  field_values = page.all("input, textarea").map { |input| input[:value] }

  "expected page to have the fields #{fields.inspect}, but it didn't.
   The fields on the page had the following values: #{field_values.to_sentence}."
end

#failure_message_when_negatedObject Also known as: failure_message_for_should_not



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

def failure_message_when_negated
  "expected page not to have the fields #{fields.inspect}, but it did."
end

#matches?(page) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
14
# File 'lib/elabs_matchers/matchers/have_fields.rb', line 11

def matches?(page)
  @page = page
  fields.all? { |label, value| page.has_field?(label, :with => value) }
end