Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Commits on Sep 19, 2012
  1. @myronmarston

    Fix confusing error message.

    myronmarston authored
    When a class method was mocked and it was called an extra time with the wrong arguments, the error being raised was:
    "NoMethodError: undefined method `bar' for Object:Class"
    ...which was very confusing.
Commits on Sep 16, 2012
  1. @basvodde @alindeman

    and_raise more closely matches Kernel#raise

    basvodde authored alindeman committed
    * Closes #177
Commits on Sep 15, 2012
  1. @alindeman

    Fixes regression with methods stubbed multiple times in a single test

    alindeman authored
    * Regression introduced by a727464.
    * The cause:
      - Test code requests a method be stubbed
      - Since the method was not defined on the object's singleton class, it
        did not need to be stashed
      - Proxied method is defined on the object's singleton class
      - Test code requests a method to be stubbed (again)
      - Since the proxied method is defined on the object's singleton class,
        it is stashed (bug here!)
      - Later, the proxied method is restored in the reset step; future
        calls to that method are broken
    * The fix:
      - Do not stash methods if a method has already been proxied by
    * Test written by @myronmarston (thanks!)
Commits on Sep 9, 2012
  1. @alindeman

    Adds test to prevent regression of #69

    alindeman authored
    * Bug fixed in a727464
    * Closes #69
  2. @alindeman

    Correctly unstubs methods stubbed with `#any_instance`

    alindeman authored
    * Instances stubbed with `#any_instance` would not be usable after the
      test finished because `MethodDouble` would stash the implementation of
      the method already overridden by `AnyInstance::Recorder`. When the
      test finished, that implementation would be restored on the object's
      singleton class, and any future calls to it would blow up with a stack
    * This fix only stashes methods if they are defined on the object's
      singleton class to begin with; `AnyInstance::Recorder` defines a
      method on the object's class so that method will not be stashed.
    * If there is no method on the object's singleton class, RSpec can
      safely define one there without stashing the original implementation.
      At the end of the test, the method is simply removed entirely from the
      singleton class. Any original implementation defined in the object's
      ancestor chain will show through again.
    * This issue cannot be fixed on MRI 1.8.6 because it does not support
      `Method#owner`. However, `#any_instance` itself is not supported on
      1.8.6 for the same reason. The fix should not negatively affect 1.8.6,
      though, because the fallback behavior is to stash the method in all
      cases (which was the original behavior).
    * This commit also refactors the stashing behavior out into its own
      object. While not explicitly necessary, it helped me reason about the
      fix much easier than when all the responsibility was in `MethodDouble`
      (which also has other responsibilities).
    * Fixes #167
    * Closes #182
Commits on Aug 26, 2012
  1. @alindeman
Commits on Aug 24, 2012
  1. @myronmarston

    Explicitly load psych.

    myronmarston authored
    This is needed on 1.9.2 to get the serialization specs to pass when run in isolation w/o bundler.
    For #174.
  2. @myronmarston
Commits on Aug 20, 2012
  1. @dchelimsky
  2. @dchelimsky

    Merge pull request #151 from c42engineering/issue_134

    dchelimsky authored
    Issue #134: Add deprecation warning for should_not_receive followed by and_return
Commits on Aug 16, 2012
  1. @dchelimsky

    Use pure doubles ( in the middle of stub_chain

    dchelimsky authored
    - was using
    - Fixes #587
Commits on Aug 14, 2012
  1. @myronmarston

    Fix transfer_nested_constants option of stub_const.

    myronmarston authored
    My changes in deec990 caused it to blow up in the face of inherited constants.
Commits on Aug 11, 2012
  1. @myronmarston

    Fix use of const_defined? and const_get so it ignores top-level const…

    myronmarston authored
    I didn't realize this previously, but these methods can pick up a top-level
    constant when you don't intend it (e.g. ::Hash when checking MyGem.const_defined?("Hash")).
Commits on Aug 3, 2012
  1. @myronmarston

    Cleanup spec a bit.

    myronmarston authored
  2. @daneget @myronmarston

    Fix any_instance to handle methods defined on superclasses.

    daneget authored myronmarston committed
    Previously, the recorder implementation created a SystemStackError.
    Closes #152.
Commits on Aug 1, 2012
  1. @dchelimsky
Commits on Jul 11, 2012
  1. @myronmarston

    Fix ruby warnings.

    myronmarston authored
    - lib/rspec/mocks/error_generator.rb:32: warning: assigned but unused variable - expected_args
    - lib/rspec/mocks/error_generator.rb:33: warning: assigned but unused variable - actual_args
    - lib/rspec/mocks/stub_const.rb:8: warning: shadowing outer local variable - name
    - lib/rspec/mocks/stub_const.rb:12: warning: shadowing outer local variable - name
    - spec/rspec/mocks/stub_const_spec.rb:60: warning: assigned but unused variable - orig_value
    - lib/rspec/mocks/stub_const.rb:233: warning: instance variable @registered_with_mocks_space not initialized
    Closes #162.
Commits on Jul 9, 2012
  1. @myronmarston

    Fix edge case bug exposed w/ `should_receive` on a null object w/ a p…

    myronmarston authored
    …revious stub.
    In a case like:
      double = stub.as_null_object
      double.stub(:foo => "bar")
      double.should_receive(:foo) used to return "bar", but due to my changes in a5f296e it was returning `self`.
Commits on Jun 27, 2012
  1. @amarshall
Commits on Jun 24, 2012
  1. @myronmarston

    Fix `should_receive` to preserve null object behavior.

    myronmarston authored
    Given a case like:
       double = mock.as_null_object
    ...`` was returning nil when it should return the double itself, since that's the expected null object behavior and no implementation was provided for the mock expectation.
    Closes #155.
Commits on Jun 18, 2012
  1. @myronmarston
  2. @myronmarston
Commits on Jun 15, 2012
  1. @dchelimsky

    refactor: rename ExpectationChain to PositiveExpectationChain

    dchelimsky authored
    Also extract base ExpectationChain.
Commits on Jun 11, 2012
  1. Issue #134: Add deprecation warning for should_not_receive followed b…

    Neha Kumari authored
    …y and_return.
  2. @myronmarston
Commits on Jun 8, 2012
  1. @myronmarston

    Refactor away the use of #its.

    myronmarston authored
    #its is going away in rspec-core at some future point, so we shouldn't use it here.
Commits on Jun 7, 2012
  1. @myronmarston

    Add `Constant.original` API to query rspec-mocks about stubbed consta…

    myronmarston authored
    This needs to be documented, but I want to get feedback from others before spending effort on that.
  2. @myronmarston

    Return stubbed value rather than original value from stub_const.

    myronmarston authored
    This allows chaining:
      stub_const("Foo", double).stub(:foo)
Commits on Jun 4, 2012
  1. @dchelimsky
  2. Issue #123: Improved error message when user forgets to stub a method…

    Neha Kumari authored
    … with default behavior.
  3. @myronmarston
Commits on Jun 2, 2012
  1. @myronmarston

    Fix a constant stubbing edge case.

    myronmarston authored
    stub_const("A::B::C", whatever) cannot work if A::B is defined
    but A::B is not a module.
    For #144.
  2. @myronmarston

    Always restore original constants.

    myronmarston authored
    The original logic from rspec-fire did not restore original constants
    if the user changed them in the example after stubbing them, but after
    talking it over with @dchelimsky and @garyberhnardt we've decided to
    be consistent and always restore them.
    For #144.
  3. @myronmarston

    First pass at implementing constant stubbing.

    myronmarston authored
    This is almost copied verbatim from rspec-fire.
    For #144.
Commits on May 24, 2012
  1. @dchelimsky

    `should_receive(x).at_least(:once).and_return(y)` always returns y ev…

    dchelimsky authored
    …en if x is already stubbed
        widget.stub(:count => 1)
        widget.count #=> 2
        widget.count #=> 2
    If there is no return value set, it will fall back to the stub value:
        widget.stub(:count => 1)
        widget.count #=> 1
        widget.count #=> 1
    - Fixes #142
Something went wrong with that request. Please try again.