Class: Micronaut::Matchers::BeClose
- Defined in:
- lib/micronaut/matchers/be_close.rb
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 |
# File 'lib/micronaut/matchers/be_close.rb', line 5 def initialize(expected, delta) @expected, @delta = expected, delta end |
Instance Method Details
#description ⇒ Object
18 19 20 |
# File 'lib/micronaut/matchers/be_close.rb', line 18 def description "be close to #{@expected} (within +- #{@delta})" end |
#failure_message ⇒ Object
14 15 16 |
# File 'lib/micronaut/matchers/be_close.rb', line 14 def "expected #{@expected} +/- (< #{@delta}), got #{@actual}" end |
#matches?(actual) ⇒ Boolean
9 10 11 12 |
# File 'lib/micronaut/matchers/be_close.rb', line 9 def matches?(actual) @actual = actual (@actual - @expected).abs < @delta end |