Class: Reeve::Testing::Checks::AuditCoverage

Inherits:
Base
  • Object
show all
Defined in:
lib/reeve/testing/checks/audit_coverage.rb

Overview

FR-017, FR-008: exactly one ledger entry per invocation.

The failure this is built to catch is not a broken tool but a caller that reaches past the envelope — MyTool.new.call(...) somewhere in a controller. So the check takes the invoker as a collaborator, defaulting to Reeve.invoke, and counts the rows that appeared around it. A tool invoked outside the envelope produces none.

Reeve::Checks::AuditCoverage.new(tool: InvoiceExportTool, principal: alice).call

Instance Method Summary collapse

Methods inherited from Base

check_name, #check_name

Constructor Details

#initialize(tool:, principal:, arguments: {}, invoke: nil, ledger: nil) ⇒ AuditCoverage

Returns a new instance of AuditCoverage.



15
16
17
18
# File 'lib/reeve/testing/checks/audit_coverage.rb', line 15

def initialize(tool:, principal:, arguments: {}, invoke: nil, ledger: nil)
  super(tool: tool, arguments: arguments, invoke: invoke, ledger: ledger)
  @principal = principal
end

Instance Method Details

#callObject



20
21
22
23
24
25
26
27
28
# File 'lib/reeve/testing/checks/audit_coverage.rb', line 20

def call
  return ledger_unavailable("audit coverage") unless ledger.available?

  made = attempt(principal: @principal)
  count = made.rows.size
  return held(count) if count == 1

  failed(message_for(count), entries: count, error: made.error&.class&.name)
end