Sha256: f7a6f2395c1da84319fb8126dd23110760b8d8178c1f28d5acd8f682f7887327
Contents?: true
Size: 803 Bytes
Versions: 17
Compression:
Stored size: 803 Bytes
Contents
module Spec module Matchers class BeClose #:nodoc: def initialize(expected, delta) @expected = expected @delta = delta end def matches?(given) @given = given (@given - @expected).abs < @delta end def failure_message "expected #{@expected} +/- (< #{@delta}), got #{@given}" end def description "be close to #{@expected} (within +- #{@delta})" end end # :call-seq: # should be_close(expected, delta) # should_not be_close(expected, delta) # # Passes if given == expected +/- delta # # == Example # # result.should be_close(3.0, 0.5) def be_close(expected, delta) Matchers::BeClose.new(expected, delta) end end end
Version data entries
17 entries across 17 versions & 5 rubygems