Class: Spec::Matchers::BeClose
Overview
:nodoc:
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
-
#initialize(expected, delta) ⇒ BeClose
constructor
A new instance of BeClose.
- #matches?(actual) ⇒ Boolean
Constructor Details
#initialize(expected, delta) ⇒ BeClose
Returns a new instance of BeClose.
5 6 7 8 |
# File 'lib/spec/matchers/be_close.rb', line 5 def initialize(expected, delta) @expected = expected @delta = delta end |
Instance Method Details
#description ⇒ Object
19 20 21 |
# File 'lib/spec/matchers/be_close.rb', line 19 def description "be close to #{@expected} (within +- #{@delta})" end |
#failure_message ⇒ Object
15 16 17 |
# File 'lib/spec/matchers/be_close.rb', line 15 def "expected #{@expected} +/- (< #{@delta}), got #{@actual}" end |
#matches?(actual) ⇒ Boolean
10 11 12 13 |
# File 'lib/spec/matchers/be_close.rb', line 10 def matches?(actual) @actual = actual (@actual - @expected).abs < @delta end |