Class: Utensils::CustomMatchers::Ordered
- Inherits:
-
Object
- Object
- Utensils::CustomMatchers::Ordered
- Defined in:
- lib/utensils/custom_matchers.rb
Instance Method Summary collapse
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object
-
#initialize(args) ⇒ Ordered
constructor
A new instance of Ordered.
- #matches?(page) ⇒ Boolean
Constructor Details
#initialize(args) ⇒ Ordered
Returns a new instance of Ordered.
122 123 124 125 126 127 |
# File 'lib/utensils/custom_matchers.rb', line 122 def initialize(args) @within = args.pop[:within] @selectors = args.map do |selector| selector.is_a?(String) ? selector : '#' + ApplicationController.helpers.dom_id(selector) end end |
Instance Method Details
#failure_message ⇒ Object
137 138 139 |
# File 'lib/utensils/custom_matchers.rb', line 137 def "expected #{@page.body} to have elements in this order: #{@selectors.inspect}" end |
#failure_message_when_negated ⇒ Object
141 142 143 |
# File 'lib/utensils/custom_matchers.rb', line 141 def "expected #{@page.body} to not have elements in this order: #{@selectors.inspect}" end |
#matches?(page) ⇒ Boolean
129 130 131 132 133 134 135 |
# File 'lib/utensils/custom_matchers.rb', line 129 def matches?(page) @page = page @selectors.each_with_index do |selector,i| return false unless @page.has_css?("#{@within} #{selector}:nth-child(#{i+1})") end true end |