Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: freerange/mocha
base: v1.4.0
Choose a base ref
...
head repository: freerange/mocha
compare: v1.5.0
Choose a head ref
  • 9 commits
  • 28 files changed
  • 1 contributor

Commits on Mar 30, 2018

  1. Call Mocha::Hooks#mocha_setup from legacy integration modules

    Both Mocha::Integration::MiniTest::Adapter and
    Mocha::Integration::TestUnit::Adapter were already calling
    Mocha::Hooks#mocha_setup, but the legacy integration modules were not.
    
    Even though Mocha::Hooks#mocha_setup is currently a no-op, I'm planning
    to change this and making this change now means I'm starting from a
    consistent baseline.
    
    Note that I've confirmed that
    RSpec::Core::MockingAdapters::Mocha#setup_mocks_for_rspec already calls
    Mocha::Hooks#mocha_setup [1].
    
    [1]:
    https://github.com/rspec/rspec-core/blob/a8aae27114dde9ebc429a168b9b3c63dc18e5088/lib/rspec/core/mocking_adapters/mocha.rb#L44
    floehopper committed Mar 30, 2018
    Copy the full SHA
    9c449d7 View commit details
    Browse the repository at this point in the history

Commits on Apr 6, 2018

  1. Explicitly instantiate Mockery from Hooks#mocha_setup

    Previously the Mockery singleton instance was lazily instantiated the
    first time it was needed. This meant that it could be instantiated
    outside the scope of a test with no subsequent calls to Mockery.verify,
    Mockery.teardown, or Mockery.reset_instance. This had the potential to
    leave things in an inconsistent state and resulted in confusing errors
    in tests. See #292 for some examples reported by users. This change is a
    step on the way to solving that issue.
    
    Note that rather than simply instantiating a single instance of a
    Mockery, I've had to store a stack of instances. This is entirely to
    cope with the acceptance tests which result in nested calls to
    Mockery.setup and Mockery.teardown:
    
    1. Outer acceptance test:              Mockery.setup
    2. Inner test in run_as_test(s) block: Mockery.setup
    3. Inner test in run_as_test(s) block: Mockery.teardown
    4. Outer acceptance test:              Mockery.teardown
    
    I've also had to copy the logger instance from the outer Mockery
    instance to the inner one in order that the outer acceptance tests have
    access to the same logger as used by the inner one.
    
    Obviously the above complication is a bit undesirable, given that it's
    only needed to support the acceptance tests and should never be required
    by users. However, I tried various alternatives and I felt this one was
    the best option.
    
    Note also that this indirectly addresses #293.
    floehopper committed Apr 6, 2018
    Copy the full SHA
    03b2053 View commit details
    Browse the repository at this point in the history
  2. Remove unnecessary restoration of Mockery.logger in acceptance tests

    Now that the Mockery instance is being explicitly instantiated and
    destroyed, I think this restoration of the original logger is redundant.
    floehopper committed Apr 6, 2018
    Copy the full SHA
    8ea0c63 View commit details
    Browse the repository at this point in the history
  3. Raise NotInitializedError if Mocha used outside context of a test

    Hopefully this addresses #292.
    
    If no Mockery has been instantiated when a call is made to any method
    which would otherwise change the state of the Mockery instance then
    raise a NotInitializedError.
    
    This is achieved by returning an instance of Mockery::Null if no Mockery
    has been instantiated. Note that the Mockery::Null class inherits from
    the Mockery class, but overrides all methods which result in a change
    of state.
    floehopper committed Apr 6, 2018
    Copy the full SHA
    5bda7c4 View commit details
    Browse the repository at this point in the history
  4. Copy the full SHA
    b57c386 View commit details
    Browse the repository at this point in the history
  5. Copy the full SHA
    89eeb1c View commit details
    Browse the repository at this point in the history
  6. Merge pull request #327 from freerange/prevent-use-of-mocha-outside-test

    Prevent use of Mocha outside the context of a test/example
    floehopper committed Apr 6, 2018
    Copy the full SHA
    d6c6c82 View commit details
    Browse the repository at this point in the history
  7. Update release notes

    floehopper committed Apr 6, 2018
    Copy the full SHA
    44a37b9 View commit details
    Browse the repository at this point in the history
  8. Prepare to release v1.5.0

    floehopper committed Apr 6, 2018
    Copy the full SHA
    12d9ce7 View commit details
    Browse the repository at this point in the history