Class: Dommy::Rails::RSpec::Matchers::MatchAriaSnapshot
- Inherits:
-
Object
- Object
- Dommy::Rails::RSpec::Matchers::MatchAriaSnapshot
- Defined in:
- lib/dommy/rails/rspec/matchers.rb
Overview
Playwright-style ARIA snapshot subset match. ‘expected` is a template snapshot (its nodes must appear in the actual tree, in order); names may be `/regex/`.
Instance Method Summary collapse
- #description ⇒ Object
- #does_not_match?(actual) ⇒ Boolean
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object
-
#initialize(expected) ⇒ MatchAriaSnapshot
constructor
A new instance of MatchAriaSnapshot.
- #matches?(actual) ⇒ Boolean
Constructor Details
#initialize(expected) ⇒ MatchAriaSnapshot
Returns a new instance of MatchAriaSnapshot.
222 223 224 |
# File 'lib/dommy/rails/rspec/matchers.rb', line 222 def initialize(expected) @expected = expected end |
Instance Method Details
#description ⇒ Object
235 236 237 |
# File 'lib/dommy/rails/rspec/matchers.rb', line 235 def description "match aria snapshot" end |
#does_not_match?(actual) ⇒ Boolean
231 232 233 |
# File 'lib/dommy/rails/rspec/matchers.rb', line 231 def does_not_match?(actual) !matches?(actual) end |
#failure_message ⇒ Object
239 240 241 |
# File 'lib/dommy/rails/rspec/matchers.rb', line 239 def "expected aria snapshot to match:\n#{@expected}\ngot:\n#{@actual}" end |
#failure_message_when_negated ⇒ Object
243 244 245 |
# File 'lib/dommy/rails/rspec/matchers.rb', line 243 def "expected aria snapshot not to match:\n#{@expected}" end |
#matches?(actual) ⇒ Boolean
226 227 228 229 |
# File 'lib/dommy/rails/rspec/matchers.rb', line 226 def matches?(actual) @actual = MatchTarget.document(actual).aria_snapshot Dommy::Rails::AriaSnapshotMatching.matches?(@actual, @expected) end |