Class: Matchy::Expectations::BeCloseExpectation
- Defined in:
- lib/matchy/built_in/truth_expectations.rb
Instance Method Summary collapse
- #failure_message ⇒ Object
-
#initialize(expected, delta, test_case) ⇒ BeCloseExpectation
constructor
A new instance of BeCloseExpectation.
- #matches?(receiver) ⇒ Boolean
- #negative_failure_message ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(expected, delta, test_case) ⇒ BeCloseExpectation
Returns a new instance of BeCloseExpectation.
35 36 37 38 39 |
# File 'lib/matchy/built_in/truth_expectations.rb', line 35 def initialize(expected, delta, test_case) @expected = expected @test_case = test_case @delta = delta end |
Instance Method Details
#failure_message ⇒ Object
47 48 49 |
# File 'lib/matchy/built_in/truth_expectations.rb', line 47 def "Expected #{@receiver.inspect} to be close to #{@expected.inspect} (delta: #{@delta})." end |
#matches?(receiver) ⇒ Boolean
41 42 43 44 45 |
# File 'lib/matchy/built_in/truth_expectations.rb', line 41 def matches?(receiver) @receiver = receiver (receiver - @expected).abs < @delta end |
#negative_failure_message ⇒ Object
51 52 53 |
# File 'lib/matchy/built_in/truth_expectations.rb', line 51 def "Expected #{@receiver.inspect} to not be close to #{@expected.inspect} (delta: #{@delta})." end |