Matcher for numbers that are close to the actual or 'near enough'.
Accepts an expected result and a precision modifier.
i.e. .toBeNearTo(100, 2) would match 98, 99, 100, 101 & 102
This should perhaps be called toBeCloseTo(), and the existing method of that name might more accurately be called .toBePrecision() or some such but I'll leave that up to you.
Added .toBeNearTo() matcher that checks if the expected is within a c…
…ertain range of the actual
What about syntax something like expect(foo).toBeWithin(2).of(100) ?
I'm concerned that being 'near to' doesn't sound precise, how about:
A fair point.
@matcarey to be fair this method is all about not being precise.
However, I honestly don't care or know best what the method should be called or which syntax might be used to access such logic. I would though, like to see the functionality implemented so am happy to receive any feedback from repository owners and submit a further commit based on that.
2.0 rc2 has this matcher, but called toBeCloseTo. Closing, please create a new pull request if this is still an issue for you