Sha256: 1abf77e3c1d9b4b237a814ccbd8c6cb6b85eeaafd83f075debbbb8dc3d781bc6
Contents?: true
Size: 946 Bytes
Versions: 23
Compression:
Stored size: 946 Bytes
Contents
class WithinMatcher defm match(expected, actual) delta = expected[0] num = expected[1] self.result = abs(num - actual) return self.result <= delta end defm failure_message_for_match(expected, actual) delta = expected[0] num = expected[1] actual_str = printf("%f", actual) delta_str = printf("%f", delta) num_str = printf("%f", num) result_str = printf('%f', self.result) return "expected “#{actual_str}” to be within +/- “#{delta_str}” of “#{num_str}”, delta was “#{result_str}”" end defm failure_message_for_mismatch(expected, actual) delta = expected[0] num = expected[1] actual_str = printf("%f", actual) delta_str = printf("%f", delta) num_str = printf("%f", num) result_str = printf('%f', self.result) return "expected “#{actual_str}” to not be within +/- “#{delta_str}” of “#{num_str}”, delta was “#{result_str}”" end end
Version data entries
23 entries across 23 versions & 1 rubygems
Version | Path |
---|---|
speckle-0.1.4 | lib/matchers/within_matcher.riml |
speckle-0.1.3 | lib/matchers/within_matcher.riml |
speckle-0.1.2 | lib/matchers/within_matcher.riml |