Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce duplication in & between Mock & ObjectMethods #431

Open
wants to merge 34 commits into
base: main
Choose a base branch
from

Commits on Nov 29, 2019

  1. make arg iteration similar in expects & stubs

    This will allow us to keep the code DRY by extracting a method with the
    identical bits
    nitishr committed Nov 29, 2019
    Configuration menu
    Copy the full SHA
    22c594f View commit details
    Browse the repository at this point in the history

Commits on Dec 4, 2019

  1. Configuration menu
    Copy the full SHA
    ffac2ad View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    f700c36 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    da280b1 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    7579416 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    7cff8fa View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    7494b2d View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    5f83af5 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    b9422ba View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    7a691d9 View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    bf32420 View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    73cf959 View commit details
    Browse the repository at this point in the history
  12. substitute algorithm for ArgumentIterator.each

    Array will return a single-element array in case the arg is a single value, or a
    Hash converted to an array in case the arg is a Hash. We then yield the single
    element or the key value pair, and return the result of the last yield
    nitishr committed Dec 4, 2019
    Configuration menu
    Copy the full SHA
    b34726e View commit details
    Browse the repository at this point in the history
  13. Configuration menu
    Copy the full SHA
    547a4d5 View commit details
    Browse the repository at this point in the history
  14. Configuration menu
    Copy the full SHA
    bf7ef4e View commit details
    Browse the repository at this point in the history
  15. Configuration menu
    Copy the full SHA
    84e3ee7 View commit details
    Browse the repository at this point in the history
  16. Configuration menu
    Copy the full SHA
    bfd20d8 View commit details
    Browse the repository at this point in the history
  17. Configuration menu
    Copy the full SHA
    9761be3 View commit details
    Browse the repository at this point in the history
  18. call Mock#{expects,stubs} with methods_vs_return_values

    Mock#{expects,stubs} already handle methods_vs_return_values/method_name_or_hash
    Note that this change isn't 100% behavior preserving due to the separation of
    Mockery#stub_method call from the Mock#{expects,stubs} call. It's possible that
    midway through argument iteration, stub_method raises a StubbingError, which
    would leave some methods stubbed without having an expectation set for them. However, I think that's still OK, since you wouldn't expect anything useful to happen after a StubbingError anyway. We're changing undocumented/unpublished behavior in a way that shouldn't matter.
    nitishr committed Dec 4, 2019
    Configuration menu
    Copy the full SHA
    b2354df View commit details
    Browse the repository at this point in the history
  19. Configuration menu
    Copy the full SHA
    7e7a61b View commit details
    Browse the repository at this point in the history
  20. Configuration menu
    Copy the full SHA
    b87733f View commit details
    Browse the repository at this point in the history
  21. Configuration menu
    Copy the full SHA
    2c4a5db View commit details
    Browse the repository at this point in the history
  22. Configuration menu
    Copy the full SHA
    262ea4c View commit details
    Browse the repository at this point in the history
  23. Refactor: rename stubbed_method->stubba_method_for

    Keep the stubba_ prefix to avoid accidental name clash with other valid methods
    nitishr committed Dec 4, 2019
    Configuration menu
    Copy the full SHA
    5a5ed50 View commit details
    Browse the repository at this point in the history
  24. Configuration menu
    Copy the full SHA
    5f1c5f4 View commit details
    Browse the repository at this point in the history
  25. Configuration menu
    Copy the full SHA
    365884e View commit details
    Browse the repository at this point in the history
  26. Configuration menu
    Copy the full SHA
    19004e7 View commit details
    Browse the repository at this point in the history
  27. Configuration menu
    Copy the full SHA
    201cfaa View commit details
    Browse the repository at this point in the history
  28. Configuration menu
    Copy the full SHA
    2840411 View commit details
    Browse the repository at this point in the history

Commits on Feb 19, 2020

  1. more consistent setting of multiple expectations

    When calling expects/stubs with a hash (method_names_vs_return_values),
    only the last expectation would get returned. Any further 'expectation
    setting' methods chained to that call would, therefore, get called only
    on the last expectation. This seems arbitrary, and neither evident nor
    intuitive. We now 'extract' the expectation setting methods into a
    _virtual_ interface, 'implemented' by both Expectation and
    ExpectationSetting, and return ExpectationSetting instead of Expectation
    from the expects/stubs methods. This allows us to pass any further
    expectation setting method calls on to _each_ of the multiple
    expectations, rather than just the _last_ (or some other arbitrary)
    single expectation.
    nitishr committed Feb 19, 2020
    Configuration menu
    Copy the full SHA
    583103b View commit details
    Browse the repository at this point in the history

Commits on Feb 21, 2020

  1. move Mockery#stub_method call to ObjectMethods

    Mock wasn't the right place for calling it. The new yield mechanism is
    more general and less ugly, and allocates responsibilities more
    appropriately.
    nitishr committed Feb 21, 2020
    Configuration menu
    Copy the full SHA
    b80cb98 View commit details
    Browse the repository at this point in the history
  2. remove the Spanish Inquisition special case

    Closes freerange#468 and sets us up to reduce the surface area of the internal
    API exposed to users, by inlining anticipates into expects and using
    that from stubs
    nitishr committed Feb 21, 2020
    Configuration menu
    Copy the full SHA
    8a7af66 View commit details
    Browse the repository at this point in the history
  3. Refactor: inline anticipates into expects

    This reduces the surface area of the internal API exposed to users as
    suggested in freerange#467
    nitishr committed Feb 21, 2020
    Configuration menu
    Copy the full SHA
    9930e5a View commit details
    Browse the repository at this point in the history
  4. Refactor: ExpectationSetting->CompositeExpectation

    Given that the public API of Expectation consists solely of expectation
    setting methods, and that the matching, verifying and other misc methods
    aren't part of the public API, it makes sense to equate the Expectation
    protocol implicitly to the ExpectationSetting protocol. If we were to
    segregate interfaces, we might wanna have other internal-facing
    interfaces like ExpectationMatching, etc.
    
    By naming this CompositeExpectation, we don't need (as much) to expose
    it or to include it in/update the documentation because as far as
    clients are concerned, they still get back an Expectation (technically,
    something that quacks like an Expectation).
    nitishr committed Feb 21, 2020
    Configuration menu
    Copy the full SHA
    1906a10 View commit details
    Browse the repository at this point in the history