Class: Mustard::CloseMatcher
- Inherits:
-
Object
- Object
- Mustard::CloseMatcher
- Defined in:
- lib/mustard/matchers/close_matcher.rb
Instance Method Summary collapse
- #failure_message ⇒ Object
-
#initialize(subject, expected, delta = 0.001) ⇒ CloseMatcher
constructor
A new instance of CloseMatcher.
- #match? ⇒ Boolean
- #message_expected ⇒ Object
- #negative_failure_message ⇒ Object
Constructor Details
#initialize(subject, expected, delta = 0.001) ⇒ CloseMatcher
Returns a new instance of CloseMatcher.
3 4 5 6 7 |
# File 'lib/mustard/matchers/close_matcher.rb', line 3 def initialize(subject, expected, delta = 0.001) @subject = subject @expected = expected @delta = delta end |
Instance Method Details
#failure_message ⇒ Object
13 14 15 |
# File 'lib/mustard/matchers/close_matcher.rb', line 13 def "expected #{@subject.inspect} to #{}" end |
#match? ⇒ Boolean
9 10 11 |
# File 'lib/mustard/matchers/close_matcher.rb', line 9 def match? @delta >= (@subject - @expected).abs end |
#message_expected ⇒ Object
21 22 23 |
# File 'lib/mustard/matchers/close_matcher.rb', line 21 def "be within #{@delta.inspect} of #{@expected.inspect}" end |
#negative_failure_message ⇒ Object
17 18 19 |
# File 'lib/mustard/matchers/close_matcher.rb', line 17 def "expected #{@subject.inspect} to not #{}" end |