Class: Accessibility::HasChildMatcher

Inherits:
AbstractMatcher show all
Defined in:
lib/rspec/expectations/ax_elements.rb

Overview

Custom matcher for RSpec to check if an element has the specified child element.

Instance Attribute Summary

Attributes inherited from AbstractMatcher

#block, #filters, #kind

Instance Method Summary collapse

Methods inherited from AbstractMatcher

#does_not_match?, #initialize

Constructor Details

This class inherits a constructor from Accessibility::AbstractMatcher

Instance Method Details

#descriptionString

Returns:

  • (String)


65
66
67
# File 'lib/rspec/expectations/ax_elements.rb', line 65

def description
"should have a child that matches #{qualifier.describe}"
end

#failure_message_for_shouldString

Returns:

  • (String)


55
56
57
# File 'lib/rspec/expectations/ax_elements.rb', line 55

def failure_message_for_should
  "Expected #@parent to have child #{qualifier.describe}"
end

#failure_message_for_should_notString

Returns:

  • (String)


60
61
62
# File 'lib/rspec/expectations/ax_elements.rb', line 60

def failure_message_for_should_not
  "Expected #@parent to NOT have child #@result"
end

#matches?(parent) ⇒ Boolean

Parameters:

  • parent (AX::Element)

Returns:

  • (Boolean)


48
49
50
51
52
# File 'lib/rspec/expectations/ax_elements.rb', line 48

def matches? parent
  @parent = parent
  @result = parent.children.find { |x| qualifier.qualifies? x }
  !@result.blank?
end