# File lib/mspec/matchers/be_close.rb, line 4 def initialize(expected, tolerance) @expected = expected @tolerance = tolerance end
# File lib/mspec/matchers/be_close.rb, line 14 def failure_message ["Expected #{@expected}", "to be within +/- #{@tolerance} of #{@actual}"] end
# File lib/mspec/matchers/be_close.rb, line 9 def matches?(actual) @actual = actual (@actual - @expected).abs < @tolerance end
# File lib/mspec/matchers/be_close.rb, line 18 def negative_failure_message ["Expected #{@expected}", "not to be within +/- #{@tolerance} of #{@actual}"] end