Class: BloodContracts::Runner

Inherits:
Object
  • Object
show all
Extended by:
Dry::Initializer
Defined in:
lib/blood_contracts/runner.rb

Direct Known Subclasses

Debugger

Instance Method Summary collapse

Instance Method Details

#callObject



33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/blood_contracts/runner.rb', line 33

def call
  iterate do
    next if match_rules?(matches_storage: statistics) do
      input = suite.data_generator.call
      [input, checking_proc.call(input)]
    end
    throw :unexpected_behavior, :stop if stop_on_unexpected
  end
  return if stopped_by_unexpected_behavior?

  validator.valid?(statistics)
end

#descriptionObject

FIXME: Move to locales



62
63
64
65
66
# File 'lib/blood_contracts/runner.rb', line 62

def description
  "meet the contract:\n#{contract_description} \n"\
  " during #{iterations} run(s). Stats:\n#{statistics}\n\n"\
  "For further investigations open: #{storage.suggestion}\n"
end

#failure_messageObject

FIXME: Move to locales



47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/blood_contracts/runner.rb', line 47

def failure_message
  intro = "expected that given Proc would meet the contract:"

  if validator.expected_behavior?
    "#{intro}\n#{contract_description}\n"\
      " during #{iterations} run(s) but got:\n#{statistics}\n\n"\
      "For further investigations open: #{storage.suggestion}"
  else
    "#{intro}\n#{contract_description}\n"\
    " during #{iterations} run(s) but got unexpected behavior.\n\n"\
    "For further investigations open: #{storage.unexpected_suggestion}"
  end
end