Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Commits on Mar 12, 2013
  1. add Expectation#including_subclasses

    authored
    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
Commits on Mar 7, 2013
  1. @floehopper
  2. @floehopper

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

    floehopper authored
    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.
  3. @floehopper

    Make the `Hooks` module easier to unit test.

    floehopper authored
    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`
    instance.
Commits on Mar 6, 2013
  1. @tmm1 @floehopper

    Safer restoration of stubbed method visibility. Fixes #141.

    tmm1 authored floehopper committed
    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.
Commits on Mar 5, 2013
  1. @floehopper

    Adapt tests to changes in MiniTest output.

    floehopper authored
    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.
  2. @floehopper

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

    floehopper authored
    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
Commits on Mar 4, 2013
  1. @floehopper

    Merge pull request #140 from tmiller/master

    floehopper authored
    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"`
    statement.
    
    [1] http://floehopper.lighthouseapp.com/projects/22289-mocha/tickets/50#ticket-50-13
Commits on Feb 26, 2013
  1. @floehopper
Commits on Feb 24, 2013
  1. @tmiller

    Use require instead of load with test/unit/version

    tmiller authored
      Other gems also require test/unit/version. When this gem loads the
    same file it over writes the constant and causes a warning.
Commits on Feb 18, 2013
  1. @floehopper

    Avoid deprecation warning in Bundler v1.2.4.

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

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

    floehopper authored
    This is to avoid spurious git diffs.
Commits on Feb 17, 2013
  1. @floehopper
Commits on Feb 10, 2013
  1. @floehopper

    Allow stubbing of private Kernel methods. Fixes #134.

    floehopper authored
    We were only testing stubbing of the public and protected methods on
    Object.
    
    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
    day.
Commits on Jan 24, 2013
  1. @floehopper

    Style tweak to ParameterMatchers::Includes#mocha_inspect implementation.

    floehopper authored
    I prefer unabbreviated variable names.
  2. @floehopper
  3. @floehopper
  4. @floehopper

    Changed `includes` API to accept more than on item to match against t…

    Simao Mata authored floehopper committed
    …he subject
Commits on Jan 23, 2013
  1. @floehopper
Commits on Jan 22, 2013
  1. @floehopper
  2. @floehopper
Commits on Jan 10, 2013
  1. @floehopper
Commits on Jan 8, 2013
  1. @floehopper

    Add Google Analytics javascript to Mocha docs.

    floehopper authored
    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.
Commits on Jan 4, 2013
  1. @floehopper
Commits on Jan 3, 2013
  1. @floehopper

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

    floehopper authored
    @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
    fail.
    
    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.
  2. @chrisroos-and-floehopper

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

    chrisroos-and-floehopper authored
    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.
    
    [1]
    ruby/ruby@ace4630#L1R161
Commits on Jan 2, 2013
  1. @floehopper

    Add `Mock#responds_like_instance_of`. Fixes #119.

    floehopper authored
    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
    `Mock#responds_lie`.
    
    Thanks to @simao for the original suggestion.
  2. @floehopper
  3. @floehopper

    Make documentation example consistent with other examples.

    floehopper authored
    Elsewhere we are using `# =>` to display the expected output and not
    using `Test::Unit::Assertions`.
Commits on Dec 4, 2012
  1. @floehopper
  2. @floehopper

    Tweaks to fix for #97.

    floehopper authored
    - 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
      statement.
    
    - Added a test for the case where more than two arguments are supplied
      and an argument error is raised.
  3. @ngokli @floehopper

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

    ngokli authored floehopper committed
    …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
Commits on Nov 12, 2012
  1. @floehopper

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

    floehopper authored
    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.
Commits on Nov 11, 2012
  1. @floehopper
  2. @floehopper
Something went wrong with that request. Please try again.