Module: Dommy::RSpec::CapyStyleMatchers::FailureContext

Defined in:
lib/dommy/rspec/capy_style_matchers.rb

Overview

Prepended to every concrete matcher so it sits first in the method resolution order: it remembers the matched subject and wraps the matcher's own failure_message (via super) with any extra context a host registered through Dommy::RSpec.failure_context (e.g. dommy-rails appends a recent trace for a trace-enabled session). With no context registered the message is returned unchanged, so existing behavior — and existing message assertions — are preserved.

Instance Method Summary collapse

Instance Method Details

#does_not_match?(scope) ⇒ Boolean

Returns:

  • (Boolean)


443
444
445
446
# File 'lib/dommy/rspec/capy_style_matchers.rb', line 443

def does_not_match?(scope)
  @__dommy_subject = scope
  super
end

#failure_messageObject



448
449
450
# File 'lib/dommy/rspec/capy_style_matchers.rb', line 448

def failure_message
  Dommy::RSpec.__decorate_failure(super, @__dommy_subject)
end

#failure_message_when_negatedObject



452
453
454
# File 'lib/dommy/rspec/capy_style_matchers.rb', line 452

def failure_message_when_negated
  Dommy::RSpec.__decorate_failure(super, @__dommy_subject)
end

#matches?(scope) ⇒ Boolean

Returns:

  • (Boolean)


438
439
440
441
# File 'lib/dommy/rspec/capy_style_matchers.rb', line 438

def matches?(scope)
  @__dommy_subject = scope
  super
end