Class: Reeve::Testing::Checks::RulePresent
- Defined in:
- lib/reeve/testing/checks/rule_present.rb
Overview
FR-009: every entry explains itself.
A ledger row that records that a call was denied but not what denied it is the row you are holding during an incident, and it answers nothing. The gem's own recorder cannot write one — Entry validates the column — but a host-supplied recorder can, which is exactly the case this check covers.
Reeve::Checks::RulePresent.new(tool: InvoiceSearchTool, principal: alice).call
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(tool:, principal:, arguments: {}, invoke: nil, ledger: nil) ⇒ RulePresent
constructor
A new instance of RulePresent.
Methods inherited from Base
Constructor Details
#initialize(tool:, principal:, arguments: {}, invoke: nil, ledger: nil) ⇒ RulePresent
Returns a new instance of RulePresent.
15 16 17 18 |
# File 'lib/reeve/testing/checks/rule_present.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
#call ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/reeve/testing/checks/rule_present.rb', line 20 def call return ledger_unavailable("the deciding rule") unless ledger.available? entries = attempt(principal: @principal).rows return no_entry if entries.empty? missing = entries.reject { |entry| present?(entry.rule) } return held(entries) if missing.empty? failed( "expected every audit entry for #{tool_label} to name the rule that decided, " \ "but entry #{missing.map(&:id).join(', ')} has no rule", entries: entries.size, without_rule: missing.map(&:id) ) end |