Class: ElabsMatchers::Matchers::HaveFields::HaveFieldsMatcher
- Inherits:
-
Struct
- Object
- Struct
- ElabsMatchers::Matchers::HaveFields::HaveFieldsMatcher
- Defined in:
- lib/elabs_matchers/matchers/have_fields.rb
Instance Attribute Summary collapse
-
#fields ⇒ Object
Returns the value of attribute fields.
-
#page ⇒ Object
readonly
Returns the value of attribute page.
Instance Method Summary collapse
- #does_not_match?(page) ⇒ Boolean
- #failure_message ⇒ Object (also: #failure_message_for_should)
- #failure_message_when_negated ⇒ Object (also: #failure_message_for_should_not)
- #matches?(page) ⇒ Boolean
Instance Attribute Details
#fields ⇒ Object
Returns the value of attribute fields
8 9 10 |
# File 'lib/elabs_matchers/matchers/have_fields.rb', line 8 def fields @fields end |
#page ⇒ Object (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
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_message ⇒ Object Also known as: failure_message_for_should
21 22 23 24 25 26 |
# File 'lib/elabs_matchers/matchers/have_fields.rb', line 21 def 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_negated ⇒ Object Also known as: failure_message_for_should_not
29 30 31 |
# File 'lib/elabs_matchers/matchers/have_fields.rb', line 29 def "expected page not to have the fields #{fields.inspect}, but it did." end |
#matches?(page) ⇒ 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 |