Sha256: b1c03a56311a064cc745e75d5ba3567c6a630b91c2de99d56747653012fba0dd
Contents?: true
Size: 929 Bytes
Versions: 3
Compression:
Stored size: 929 Bytes
Contents
module Similatron class Comparison attr_reader :expected, :actual, :diff, :score def initialize(expected:, actual:, score:, diff: nil, overwrite: nil) @expected = expected @actual = actual @diff = diff @score = score @overwrite = overwrite end def same? @score.zero? end def overwrite? @overwrite end def raise_when_different return if same? message_parts = [ "Found #{actual} different from #{expected}\n", "Score: #{score}" ] message_parts << "\nDiff in #{diff}" if diff raise StandardError, message_parts.join end def as_json { expected: expected, actual: actual, diff: diff, score: score, same: !!same?, # rubocop:disable Style/DoubleNegation overwrite: !!overwrite? # rubocop:disable Style/DoubleNegation } end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
similatron-0.2.0 | lib/similatron/comparison.rb |
similatron-0.1.1 | lib/similatron/comparison.rb |
similatron-0.1.0 | lib/similatron/comparison.rb |