Class: Reeve::Testing::Matchers::Base
- Inherits:
-
Object
- Object
- Reeve::Testing::Matchers::Base
- 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
Instance Attribute Summary collapse
-
#result ⇒ Object
readonly
Returns the value of attribute result.
Instance Method Summary collapse
- #description ⇒ Object
-
#failure_message ⇒ Object
No
does_not_match?: RSpec negatesmatches?for us, and a check that had a separate negative path could drift from its positive one. - #failure_message_when_negated ⇒ Object
-
#initialize ⇒ Base
constructor
A new instance of Base.
-
#invoked_by(callable) ⇒ Object
How the tool is called.
- #matches?(subject) ⇒ Boolean
- #reading(ledger) ⇒ Object
- #supports_block_expectations? ⇒ Boolean
-
#with(**arguments) ⇒ Object
The arguments the tool is called with.
Constructor Details
#initialize ⇒ Base
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
#result ⇒ Object (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
#description ⇒ Object
57 58 59 |
# File 'lib/reeve/testing/matchers/base.rb', line 57 def description self.class.check.check_name end |
#failure_message ⇒ Object
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 result. end |
#failure_message_when_negated ⇒ Object
53 54 55 |
# File 'lib/reeve/testing/matchers/base.rb', line 53 def "expected #{result.check} to fail, but it passed: #{result.}" 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
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
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 |