<commit_before>= approximately

Facilitates comparisons of Floats, primarily in mocking. Some mocking libraries will not allow you to put
delta assertions within the expectations of your method calls. For example:

   some_animated_point = mock()
   some_animated_point.should_receive(:move_to).with(0.01456, -234.786)
   
Then you feed this mock from the outside, using some iterative algorithm with arbitrary precision, and your
assertion fails.

   Expectation not matched: called "move_to" with (0.01455999, -234.78576)

This comes because what you should have done is comparing within a delta/epsilon value instead of comparing verbatim.

And this is what most mocking libraries will do.

Some mocking libraries allow you to stuff an "assert_in_delta" call into the block of the expectation setup, but not
all of them - and the expectation block might not be called at all if the passed arguments do not match. So what
we can do instead is create a special object that will be equal to another Float object when they both are in delta
of one another. So instead you would do this (in your unit/spec framework du jour)
  
  include Approximately
  
  some_animated_point = mock()
  some_animated_point.should_receive(:move_to).with(approx(0.01456, 0.001), approx(-234.786, 0.001))

These objects will compare properly with your reference inputs.

== Contributing to approximately
 
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
* Fork the project.
* Start a feature/bugfix branch.
* Commit and push until you are happy with your contribution.
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.

== Copyright
<commit_msg>Note that we are harmless<commit_after>= approximately

Facilitates comparisons of Floats, primarily in mocking. Some mocking libraries will not allow you to put
delta assertions within the expectations of your method calls. For example:

   some_animated_point = mock()
   some_animated_point.should_receive(:move_to).with(0.01456, -234.786)
   
Then you feed this mock from the outside, using some iterative algorithm with arbitrary precision, and your
assertion fails.

   Expectation not matched: called "move_to" with (0.01455999, -234.78576)

This comes because what you should have done is comparing within a delta/epsilon value instead of comparing verbatim.

And this is what most mocking libraries will do.

Some mocking libraries allow you to stuff an "assert_in_delta" call into the block of the expectation setup, but not
all of them - and the expectation block might not be called at all if the passed arguments do not match. So what
we can do instead is create a special object that will be equal to another Float object when they both are in delta
of one another. So instead you would do this (in your unit/spec framework du jour)
  
  include Approximately
  
  some_animated_point = mock()
  some_animated_point.should_receive(:move_to).with(approx(0.01456, 0.001), approx(-234.786, 0.001))

These objects will compare properly with your reference inputs.

This module is completely uninvasive and contains no hacks for minitest, RSpec or other testing/mocking frameworks.

== Contributing to approximately
 
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
* Fork the project.
* Start a feature/bugfix branch.
* Commit and push until you are happy with your contribution.
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.

== Copyright

{'fraction_non_alphanumeric': 0.0481786133960047, 'fraction_numerical': 0.023031727379553467, 'mean_word_length': 4.3602015113350125, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7093924', 'n_tokens_mistral': 1173, 'n_tokens_neox': 1068, 'n_words': 618}