Module: Philiprehberger::Approx::RSpecMatchers
- Defined in:
- lib/philiprehberger/approx/rspec_matchers.rb
Defined Under Namespace
Classes: BeApproxMatcher, BeApproxWithinMatcher
Instance Method Summary collapse
-
#be_approx(expected, epsilon: Float::EPSILON, rel_tol: 0) ⇒ Object
Matcher for approximate equality using epsilon.
-
#be_approx_within(expected, abs: nil, rel: nil, percent: nil) ⇒ Object
Matcher for approximate equality using abs, rel, or percent tolerance.
Instance Method Details
#be_approx(expected, epsilon: Float::EPSILON, rel_tol: 0) ⇒ Object
Matcher for approximate equality using epsilon
When rel_tol is non-zero, the matcher passes if either the absolute epsilon or the relative tolerance is met (Python math.isclose semantics).
15 16 17 |
# File 'lib/philiprehberger/approx/rspec_matchers.rb', line 15 def be_approx(expected, epsilon: Float::EPSILON, rel_tol: 0) BeApproxMatcher.new(expected, epsilon, rel_tol) end |
#be_approx_within(expected, abs: nil, rel: nil, percent: nil) ⇒ Object
Matcher for approximate equality using abs, rel, or percent tolerance
25 26 27 |
# File 'lib/philiprehberger/approx/rspec_matchers.rb', line 25 def be_approx_within(expected, abs: nil, rel: nil, percent: nil) BeApproxWithinMatcher.new(expected, abs, rel, percent) end |