class Compact::Ledger
Public Class Methods
new()
click to toggle source
# File lib/compact/ledger.rb, line 4 def initialize @contracts = {} end
Public Instance Methods
prepare_double(name, block = Proc.new)
click to toggle source
# File lib/compact/ledger.rb, line 8 def prepare_double(name, block = Proc.new) @contracts[name] ||= Contract.new contract = @contracts[name] contract.prepare_double(block) end
record_contract(name, test_double, methods_to_watch = [])
click to toggle source
deprecate this?
# File lib/compact/ledger.rb, line 15 def record_contract(name, test_double, methods_to_watch = []) @contracts[name] ||= Contract.new contract = @contracts[name] contract.watch(test_double, methods_to_watch) end
summary()
click to toggle source
# File lib/compact/ledger.rb, line 27 def summary unverified_contracts = [] @contracts.each do |name, contract| unverified_contracts << contract unless contract.verified? end if unverified_contracts.empty? 'All test double contracts are satisfied.' else msg = <<~EOF The following contracts could not be verified: #{summarise_untested_contracts} #{summarise_pending_contracts} #{summarise_failing_contracts} EOF msg.gsub(/\n+/, "\n") end end
verify_contract(name, collaborator, block = Proc.new )
click to toggle source
# File lib/compact/ledger.rb, line 21 def verify_contract(name, collaborator, block = Proc.new ) @contracts[name] ||= Contract.new contract = @contracts[name] contract.verify(collaborator, block) end