Class: Reeve::Testing::Matchers::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/reeve/testing/matchers/base.rb

Overview

What every reeve matcher is: a check, and nothing else.

failure_message returns the check's own message verbatim. No matcher composes a sentence, reformats one, or adds context (FR-019) — that is the whole reason the same violation reads identically here, in Minitest, and in a rake task.

Written against RSpec's matcher protocol by duck-typing rather than by including RSpec::Matchers::DSL, so nothing under lib/reeve/testing needs RSpec loaded in order to be parsed; only a suite that uses these needs it present.

Direct Known Subclasses

AuditEveryCall, DenyAccessFor, PassReeveCheck

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBase

Returns a new instance of Base.



18
19
20
21
22
# File 'lib/reeve/testing/matchers/base.rb', line 18

def initialize
  @arguments = {}
  @invoke = nil
  @ledger = nil
end

Instance Attribute Details

#resultObject (readonly)

Returns the value of attribute result.



16
17
18
# File 'lib/reeve/testing/matchers/base.rb', line 16

def result
  @result
end

Instance Method Details

#descriptionObject



57
58
59
# File 'lib/reeve/testing/matchers/base.rb', line 57

def description
  self.class.check.check_name
end

#failure_messageObject

No does_not_match?: RSpec negates matches? for us, and a check that had a separate negative path could drift from its positive one.



49
50
51
# File 'lib/reeve/testing/matchers/base.rb', line 49

def failure_message
  result.message
end

#failure_message_when_negatedObject



53
54
55
# File 'lib/reeve/testing/matchers/base.rb', line 53

def failure_message_when_negated
  "expected #{result.check} to fail, but it passed: #{result.message}"
end

#invoked_by(callable) ⇒ Object

How the tool is called. Point this at a host's own invoker to prove that it goes through the envelope.



32
33
34
35
# File 'lib/reeve/testing/matchers/base.rb', line 32

def invoked_by(callable)
  @invoke = callable
  self
end

#matches?(subject) ⇒ Boolean

Returns:

  • (Boolean)


42
43
44
45
# File 'lib/reeve/testing/matchers/base.rb', line 42

def matches?(subject)
  @result = check_for(subject).call
  @result.passed?
end

#reading(ledger) ⇒ Object



37
38
39
40
# File 'lib/reeve/testing/matchers/base.rb', line 37

def reading(ledger)
  @ledger = ledger
  self
end

#supports_block_expectations?Boolean

Returns:

  • (Boolean)


61
62
63
# File 'lib/reeve/testing/matchers/base.rb', line 61

def supports_block_expectations?
  false
end

#with(**arguments) ⇒ Object

The arguments the tool is called with.



25
26
27
28
# File 'lib/reeve/testing/matchers/base.rb', line 25

def with(**arguments)
  @arguments = arguments
  self
end