Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Mar 12, 2013

  1. Cody Cutrer

    add Expectation#including_subclasses

    normally, stubbing a class method on a superclass simply makes
    calling that method on a subclass be an unexpected invocation.
    now you can optionally use the same stub for all subclasses

Mar 07, 2013

  1. James Mead

    Update release notes and bump version to 0.13.3.

    floehopper authored
  2. James Mead

    Ensure `Mockery` instance gets reset even if exception raised.

    It's unlikely but possible that an exception may be raised in
    `Mockery#teardown`. We should ensure that the `Mockery` instance gets
    reset if this happens.
    I'm not really happy with the way the test works, but without major
    changes this is the best I can do for now.
    Fixes #144.
    I saw this while investigating #142.
    floehopper authored
  3. James Mead

    Make the `Hooks` module easier to unit test.

    Simplify the `Mockery` "API" that is used by the `Hooks` module i.e.
    there is no real need for `Hooks` to have direct access to the `Mockery`
    floehopper authored

Mar 06, 2013

  1. Aman Gupta

    Safer restoration of stubbed method visibility. Fixes #141.

    It is possible for `Module#public`, `#protected` and `#private` to be
    redefined on descendant classes, so it' safer to use the original
    version of these methods on `Module` when restoring the visibility of
    stubbed methods.
    Rather than add a completely new set of tests for these scenarios, I
    have just embellished the existing tests. It's not ideal, because it
    makes it less clear what's going on, but I think it'll do.
    tmm1 authored floehopper committed

Mar 05, 2013

  1. James Mead

    Adapt tests to changes in MiniTest output.

    The Mocha integration tests are unfortunately dependent on the
    exact format of the test results output by MiniTest. This means that
    since the format changed in MiniTest v4.6.1, we have to change the
    regular expressions used to parse the output.
    It would be nicer to use named capture groups for the regular
    expression, but these only appear to be available in Ruby >= v1.9.
    floehopper authored
  2. James Mead

    Make auto-activation of Test::Unit integration more resilient.

    This change is specifically to cope with the nasty re-defining of
    classes that is done by the `minitest-spec-rails` gem [1]. This
    confuses the Test::Unit version detection logic in Mocha and it thinks
    that the Ruby 1.8 standard library version of Test::Unit is being used
    when in fact there is no Test::Unit version present.
    I'm not completely sure why this has reared its head [2] with Rails 4
    and/or Ruby 2, and haven't checked carefully that this change is
    (a) completely logical; and (b) hasn't introduced any regressions,
    but it does seem to fix the problem. I'm going to push it now and try to
    track down any regressions separately - I'm pretty hopeful there won't
    be any.
    Note that it will be possible to avoid this problem in the future
    when we introduce the ability to manually activate specific test library
    integration and stop using the automatic activation.
    [1] metaskills/minitest-spec-rails#17
    [2] freerange#143
    floehopper authored

Mar 04, 2013

  1. James Mead

    Merge pull request #140 from tmiller/master

    Use `require` instead of `load` with `test/unit/version`.
    Other gems also require `test/unit/version`. When mocha loads the
    same file it over writes the constant and causes a warning.
    I tried to reproduce the original problem [1] with more recent
    versions of the test-unit and mocha gems, but I ran into a
    different exception. This exception was fixed by adding a
    `gem "test-unit"` statement before the `require "test/unit"`
    floehopper authored

Feb 26, 2013

  1. James Mead

    Attempt a Ruby 2.0 build on Travis CI.

    floehopper authored

Feb 24, 2013

  1. Tom Miller

    Use require instead of load with test/unit/version

      Other gems also require test/unit/version. When this gem loads the
    same file it over writes the constant and causes a warning.
    tmiller authored

Feb 18, 2013

  1. James Mead

    Avoid deprecation warning in Bundler v1.2.4.

    I was seeing the following warning message:
        The source :rubygems is deprecated because HTTP requests are
        insecure. Please change your source to '';
        if possible, or ''; if not.
    floehopper authored
  2. James Mead

    Ensure all files have a newline at end-of-file.

    This is to avoid spurious git diffs.
    floehopper authored

Feb 17, 2013

  1. James Mead

    Updates to README based on latest Rails releases.

    floehopper authored

Feb 10, 2013

  1. James Mead

    Allow stubbing of private Kernel methods. Fixes #134.

    We were only testing stubbing of the public and protected methods on
    Note that `#method_defined?` and `#instance_methods` include both public
    and protected, but not private methods.
    There are still a few methods that are awkward, but I've just
    excluded them from the tests for now.
    There's probably a better solution to this in 1.9 involving inheriting
    Mock from BasicObject instead of Object, but that's a job for another
    floehopper authored

Jan 24, 2013

  1. James Mead

    Style tweak to ParameterMatchers::Includes#mocha_inspect implementation.

    I prefer unabbreviated variable names.
    floehopper authored
  2. James Mead

    Tweaks to unit test for ParameterMatchers::Includes.

    floehopper authored
  3. James Mead

    Fix documentation for ParameterMatchers::Includes.

    floehopper authored
  4. Changed `includes` API to accept more than on item to match against t…

    …he subject
    Simao Mata authored floehopper committed

Jan 23, 2013

  1. James Mead

    Fix latest version of Mocha mentioned in README.

    floehopper authored

Jan 22, 2013

  1. James Mead

    Bump version to 0.13.2 and prepare for release.

    floehopper authored
  2. James Mead

    Attempt to head Rails-related issues off at the pass.

    floehopper authored

Jan 10, 2013

  1. James Mead

    Add a Gem Badge to provide a link to Mocha on Rubygems.

    floehopper authored

Jan 08, 2013

  1. James Mead

    Add Google Analytics javascript to Mocha docs.

    Customising YARD templates is a bit obscure and this was the best I
    could come up with. The javascript appears as the last section within
    the content div, but before the footer div. Not ideal, but I think it
    should be ok.
    The tracking javascript is only displayed if the
    `GOOGLE_ANALYTICS_WEB_PROPERTY_ID` environment variable is set.
    floehopper authored

Jan 04, 2013

  1. James Mead

    Make `Expectation#inspect` less verbose and more useful. Fixes #122.

    floehopper authored

Jan 03, 2013

  1. James Mead

    Make unit tests more robust to changes in environment. Fixes #121.

    @voxik wanted to run the tests by simply requiring the files rather than
    running the rake task. If the unit tests and acceptance tests are loaded
    in the same process and if a recent version of MiniTest is available,
    then `ExpectationErrorFactory.exception_class` was being set to
    `MiniTest::Assertion` at file load time and then later when the unit
    tests ran, the latter exception was being raised instead of the default
    `ExpectationError` exception. This causes a number of unit tests to
    I have fixed this by changing the assertions to expect
    `ExpectationErrorFactory.exception_class`. I've also had to change
    `ExpectationErrorFactory.exception_class` to be set to the default at
    file load time to make this work.
    floehopper authored
  2. Chris Roos & James Mead

    Stubbing of methods re-declared with different visibilty. Fixes #109.

    Given a method which is re-declared with a different visibility lower
    down the ancestor chain, and given we stub the "version" of the method
    that is lower down the ancestor chain, we should ensure it is restored
    to its original visibility when it is "unstubbed".
    This was highlighted in #109 where the FileUtils module in Ruby 2.0
    declares the module-instance methods as private and then re-declares
    the module-class methods as public [1]. Even though this bug was
    highlighted in Ruby 2.0, it can happen in Ruby 1.8 or 1.9 if methods
    are declared in the same way.
    We've added a new acceptance test to demonstrate the bug and fixed it.
    The fix is to store and restore the method visibility whether or not
    we remove the stubbed method.
    Note that in Ruby 1.8.7 there is a warning about re-defining the method,
    but we can't see an easy way around this at the moment.

Jan 02, 2013

  1. James Mead

    Add `Mock#responds_like_instance_of`. Fixes #119.

    This is useful if you have a class that is awkward to instantiate. The
    implementation uses `Class#allocate` to instantiate the responder
    _without_ calling the class' `#initialize` method. Having built the
    responder instance, the implementation is the same as for
    Thanks to @simao for the original suggestion.
    floehopper authored
  2. James Mead

    Make whitespace consistent.

    floehopper authored
  3. James Mead

    Make documentation example consistent with other examples.

    Elsewhere we are using `# =>` to display the expected output and not
    using `Test::Unit::Assertions`.
    floehopper authored

Dec 04, 2012

  1. James Mead

    Bump version to 0.13.1 and prepare for release.

    floehopper authored
  2. James Mead

    Tweaks to fix for #97.

    - I don't abbreviated variable names or variable names with digits in
      them, so I've got rid of `param_1`.
    - I've used some more case statements to simplify the code and hopefully
      make it more obvious what's going on. This also helped me find another
      edge case that we'd missed. See next bullet point.
    - Raise an argument error when someone supplies a single argument that
      is not a Hash.
    - Use some idiomatic Ruby to assign `key` & `value` in a single simpler
    - Added a test for the case where more than two arguments are supplied
      and an argument error is raised.
    floehopper authored
  3. Neal Gokli

    Untested fix for #97: has_entry() does not work with an array as a ha…

    …sh value.
    Explicitly populate the key and value in different cases, rather than using flatten.
    Untested because I use rvm, which interferes with mocha unit testing
    ngokli authored floehopper committed

Nov 12, 2012

  1. James Mead

    Allow deprecation debug to be switched on from MOCHA_OPTIONS env var.

    I suspect there may be a lot of libraries out there that are requiring
    "mocha" directly will now be generating deprecation warnings. This
    should make it easier to find them.
    floehopper authored

Nov 11, 2012

  1. James Mead

    Added release note about deprecation of mocha standalone.

    floehopper authored
  2. James Mead

    Update release notes and bump version to 0.13.0.

    floehopper authored
Something went wrong with that request. Please try again.