class DuckTesting::Reporter::RaiseError

Public Instance Methods

report() click to toggle source

@note Override {DuckTesting::Reporter::Base#report}.

# File lib/duck_testing/reporter/raise_error.rb, line 7
def report
  fail ContractViolationError, failure_message
end

Private Instance Methods

failure_message() click to toggle source
# File lib/duck_testing/reporter/raise_error.rb, line 13
def failure_message
  %(#{message_header}
      Expected: #{violation.expected}
      Actual: #{violation.param.inspect})
end
message_header() click to toggle source
# File lib/duck_testing/reporter/raise_error.rb, line 19
def message_header
  if violation.param?
    "Contract violation for argument of #{violation.method_expr}"
  elsif violation.return?
    "Contract violation for return value from #{violation.method_expr}"
  else
    fail NotImplementedError
  end
end