Class: Accessibility::HasDescendentShortlyMatcher

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

Overview

Custom matcher for RSpec to check if an element has the specified descendent element within a grace period. Used for testing things after an asynchronous action is performed.

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)


152
153
154
# File 'lib/rspec/expectations/ax_elements.rb', line 152

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

#failure_message_for_shouldString

Returns:

  • (String)


142
143
144
# File 'lib/rspec/expectations/ax_elements.rb', line 142

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

#failure_message_for_should_notString

Returns:

  • (String)


147
148
149
# File 'lib/rspec/expectations/ax_elements.rb', line 147

def failure_message_for_should_not
  "Expected #@ancestor to NOT have descendent #@result before a timeout occurred"
end

#matches?(ancestor) ⇒ Boolean

Parameters:

  • ancestor (AX::Element)

Returns:

  • (Boolean)


135
136
137
138
139
# File 'lib/rspec/expectations/ax_elements.rb', line 135

def matches? ancestor
  @filters[:ancestor] = @ancestor = ancestor
  @result = wait_for kind, filters, &block
  !@result.blank?
end