Class: Dommy::Rails::RSpec::Matchers::MatchAriaSnapshot

Inherits:
Object
  • Object
show all
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

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

#descriptionObject



235
236
237
# File 'lib/dommy/rails/rspec/matchers.rb', line 235

def description
  "match aria snapshot"
end

#does_not_match?(actual) ⇒ Boolean

Returns:

  • (Boolean)


231
232
233
# File 'lib/dommy/rails/rspec/matchers.rb', line 231

def does_not_match?(actual)
  !matches?(actual)
end

#failure_messageObject



239
240
241
# File 'lib/dommy/rails/rspec/matchers.rb', line 239

def failure_message
  "expected aria snapshot to match:\n#{@expected}\ngot:\n#{@actual}"
end

#failure_message_when_negatedObject



243
244
245
# File 'lib/dommy/rails/rspec/matchers.rb', line 243

def failure_message_when_negated
  "expected aria snapshot not to match:\n#{@expected}"
end

#matches?(actual) ⇒ Boolean

Returns:

  • (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