Class: Accessibility::HasDescendentMatcher

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 descendent 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)


92
93
94
# File 'lib/rspec/expectations/ax_elements.rb', line 92

def description
  "should have a descendent matching #{qualifier.describe}"
end

#failure_message_for_shouldString

Returns:

  • (String)


82
83
84
# File 'lib/rspec/expectations/ax_elements.rb', line 82

def failure_message_for_should
  "Expected #@ancestor to have descendent #{qualifier.describe}"
end

#failure_message_for_should_notString

Returns:

  • (String)


87
88
89
# File 'lib/rspec/expectations/ax_elements.rb', line 87

def failure_message_for_should_not
  "Expected #@ancestor to NOT have descendent #@result"
end

#matches?(ancestor) ⇒ Boolean

Parameters:

  • ancestor (AX::Element)

Returns:

  • (Boolean)


75
76
77
78
79
# File 'lib/rspec/expectations/ax_elements.rb', line 75

def matches? ancestor
  @ancestor = ancestor
  @result   = ancestor.search(kind, filters, &block)
  !@result.blank?
end