Skip to content


Subversion checkout URL

You can clone with
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: rspec/rspec-mocks
head fork: rspec/rspec-mocks
Commits on Jun 13, 2013
@pda pda Bypass RSpec::Mocks::Syntax when mass-assigning stubs via double().
When mock_with's `config.syntax = [:expect]`, the `#stub` method is not
available on the TestDouble.

This change bypasses the pluggable syntax layer, directly setting up
allowance for a Matcher::Receive instance.

Another option would be to use
however the `#to` DSL-like method feels out of place when not used with
the `allow(target)` receiver syntax, and also the AcceptanceTarget
delegation implementation complexity is not required for internals like
@pda pda Spec double() stubs hash in different syntax modes.
This tests a regression referenced in #306 where disabling the :should
syntax raised errors when a stubs hash was passed to double().
@samphippen samphippen Add a changelog entry for #306.
Signed-off-by: Sam Phippen <>

Commits on Jun 20, 2013
@JonRowe JonRowe JRuby 1.7.4 in 1.9 mode is falsely reporting defined?(::BasicObject) …
…=> nil see jruby/jruby#814
@myronmarston myronmarston Refactor implementation pieces in prep for #230.
This splits each implementation piece into a separate object
so that it is easier to combine them.
@myronmarston myronmarston Clarify relationship between different method stub actions.
In 2.13.0 only `and_yield` and `and_return` could be combined, since
that was the only combination case that was specified by an example.
This was a regression, as reported by a user in #230.

I tried here to fully specify all of the various combinations of stub
actions. Notes:

* `and_return`, `and_raise` and `and_throw` are "terminal" actions
  in the sense that they terminate the method. They _must_ happen last
  and it is impossible to support more than one of these. Hence, we allow
  only one of these, and allow them to be overridden. We also return `nil`
  from these methods to discourage further stub configuration.
* `and_call_original` is a special case that doesn't make sense to be
  combined with any of the others. Once you've set it up, this causes
  any further instructions to raise an error.
* `and_yield` is treated as an "initial" action. Yielding doesn't exit
  a method the way the terminal actions do. It is the only initial action.
  Calling it multiple times sets up multiple yields.
* Setting a block implementation (possible by passing a block to almost
  any method on the fluent interface) sets the block as the "inner" action.
  It runs between the configured yields (if there are any) and the configured
  terminal action (if there is one). My thinking here is that in many cases,
  users use a block implementation to specify a return value, essentially
  making it like a terminal action (so it should come after the `and_yield`
  actions), but in other cases, the user may just use a block for a side
  effect, and may configure an terminal action as well. Only one block
  implementation is supported and it can be overridden.
@JonRowe JonRowe Merge pull request #320 from rspec/apply_243_onto_299_maintenance
Apply 243 onto 299 maintenance
@JonRowe JonRowe allow lambdas to be passed with argument lists that dont match call b8e68ec
@JonRowe JonRowe rename method 4651154
Commits on Jun 21, 2013
@JonRowe JonRowe Merge pull request #321 from rspec/fix_lambdas_for_299
Allow lambdas to be passed with argument lists that dont match called method signature
@JonRowe JonRowe Merge pull request #322 from rspec/refactor_jruby_fix
Refactor the workaround for JRuby 1.7.4
@JonRowe JonRowe deprecation message for missmatched lambda arguments a49a812
@JonRowe JonRowe work around jrubys stack trace being different 90ec477
Commits on Jun 22, 2013
@JonRowe JonRowe find the first non rspec file from caller 70ba587
@JonRowe JonRowe ws 471a400
@JonRowe JonRowe changelog 7b407b1
@JonRowe JonRowe fix issue where you couldn't use and_call_original on any_instance stuff a5443e1
@JonRowe JonRowe assert upon old syntax too 3bc662c
@JonRowe JonRowe pull backported lambda? method for 1.8.7 a076cb2
Commits on Jun 23, 2013
@JonRowe JonRowe convert lambda to proc to supress false warning d72347c
Commits on Jun 24, 2013
@JonRowe JonRowe work around 1.8.6 c46c4e4
@JonRowe JonRowe Merge pull request #323 from rspec/deprecation_message_for_missmatche…

Deprecation message for missmatched lambdas
Commits on Jun 25, 2013
@JonRowe JonRowe Merge pull request #312 from rspec/features_for_expect_any_instance_o…

Need better docs for `expect_any_instance_of` and `allow_any_instance_of`
@JonRowe JonRowe Merge pull request #328 from rspec/features_for_expect_any_instance_o…

Better docs for `expect_any_instance_of` and `allow_any_instance_of`
Commits on Jun 28, 2013
@JonRowe JonRowe Merge pull request #326 from rspec/feature_for_allow
Documentation for allow (counterpart to stub in the expect syntax)
@JonRowe JonRowe Merge pull request #331 from rspec/feature_for_allow_299
Documentation for allow (#326 for 2.99)
@JonRowe JonRowe Merge pull request #333 from rspec/faster_jruby_builds
Run tests using the client mode JVM (or as close as we can get to it)
Commits on Jun 29, 2013
@JonRowe JonRowe lock to 2-99 on other repos 9ba8683
Commits on Jul 02, 2013
@alindeman alindeman Resolves rspec/rspec-core#950 and adds specs
* Hopefully the code clarity is improved here
* We also change the behavior by *not* duping an object if `space` is
  not yet initialized. This should have been the behavior from the
  beginning, but it was overlooked and did not have specs.
@alindeman alindeman Improves clarity of nil check addc6a9
@alindeman alindeman Improves strength of assertions per @myronmarston's suggestions 367afbc
@alindeman alindeman Changelog entry 69c7c84
@alindeman alindeman Merge branch 'issue-950-with-specs' into 2-99-maintenance 22e50a2
Commits on Jul 03, 2013
@pda pda Creates syntax agnostic matchers for message expectations.
See pull: #311 and #334.

Signed-off-by: Sam Phippen <>

Commits on Jul 05, 2013
@myronmarston myronmarston Change an error back to a deprecation warning.
When we merged from a master-focused PR we accidentally change this for 2.14.
@myronmarston myronmarston Merge pull request #346 from rspec/remove_breaking_2_99_change
Change an error back to a deprecation warning.
Commits on Jul 06, 2013
@myronmarston myronmarston Reword a couple of confusing changelog entries.
[ci skip]
@myronmarston myronmarston Use new `allow_message` API. 7eea1e6
@myronmarston myronmarston Merge pull request #350 from rspec/allow_message_api_2_99
Use new `allow_message` API.
Commits on Jul 07, 2013
@myronmarston myronmarston Update changelog to reflect 2.14.0 release.
[ci skip]
@myronmarston myronmarston This branch is 2.99.0.pre now.
[ci skip]
@alindeman alindeman Works around Rubinius bug 4953923
@alindeman alindeman rbx build is green; let us try to keep it that way 9ab4c1f
@myronmarston myronmarston Add missing 2.13.1 release notes.
[ci skip]
@myronmarston myronmarston Deprecate reliance on a double's null-ness persisting between examples. 0731ddf
Commits on Jul 08, 2013
@alindeman alindeman Revert "rbx build is green; let us try to keep it that way"
This reverts commit 9ab4c1f.
@alindeman alindeman Merge pull request #354 from rspec/deprecate_double_null_object_leakage
Deprecate reliance on a double's null-ness persisting between examples.
@myronmarston myronmarston Update changelog with 2.14.1 release notes.
[ci skip]
Commits on Jul 11, 2013
@JonRowe JonRowe ensure null objects behave correctly with to_a and to_ary
@JonRowe JonRowe 1.8.7 has a default implementation on top 81601ac
@JonRowe JonRowe more descriptive comment c4a2a40
@JonRowe JonRowe refactor to case statement d8e0082
@JonRowe JonRowe Merge pull request #361 from rspec/revisited_bugfix_for_doubles_in_ar…

Ensure null objects behave correctly with to_a and to_ary in 299
Commits on Jul 28, 2013
@JonRowe JonRowe rspec-mocks is always loaded from source via `gemspec` command 70d1dab
Commits on Jul 30, 2013
@myronmarston myronmarston Split spec into two to specify each behavior individually. dec75de
@myronmarston myronmarston Fix `stub!` regression in 2.14.
Fixes #387.
@myronmarston myronmarston Add missing changelog entry for #360. f078e2e
@myronmarston myronmarston Update changelog to reflect 2.14.2 release. 4a01273
Commits on Aug 01, 2013
@samphippen samphippen Pass the receiving instance to any instance stubs.
Signed-off-by: Sam Phippen <>
@samphippen samphippen Disable any_instance receiving the object by default.
Add specs and warnings.

Signed-off-by: Sam Phippen <>
Commits on Aug 04, 2013
@soulcutter soulcutter Exhibit problem with stubbing and prepend
As described in #384 the way that original methods are stashed
breaks the ability to stub the non-prepended method.
@soulcutter soulcutter Allow stubbing instance methods on a prepended class
@soulcutter soulcutter Changelog entry 32b99eb
Commits on Aug 07, 2013
@samphippen samphippen Improve the warning message for any_instance block expectations.
Signed-off-by: Sam Phippen <>
@samphippen samphippen Add warn_deprecation to mocks.
Signed-off-by: Sam Phippen <>
@samphippen samphippen Only warn if there is an expectation block.
Signed-off-by: Sam Phippen <>
Commits on Aug 09, 2013
@myronmarston myronmarston Update changelog to reflect 2.14.3 release.
[ci skip]
Commits on Aug 11, 2013
@samphippen samphippen Make any instance expectation warning work with more implementations.
Signed-off-by: Sam Phippen <>
@samphippen samphippen Merge pull request #383 from samphippen/2-99-maintenance
Add the any_instance stubs receiving the instance to 2-99
Commits on Aug 23, 2013
@myronmarston myronmarston Fix unstubing existing instances of any instance
* access proxies for any instance of klass
* remove stubs from "running" instances
* pass recorder into chains to register stubs
* reduce lookup cost of proxies by klass
* record stubs used
* remove just the stubs recorded by any instance
* switch from to each
* allow unstubing of instances that are a sub class
* refactor lookup for subclass
* Improve doc string.
* "local instance" didn't really give me the right
* sense for what this was testing.
* Improve space spec.
    - The old spec only checked the number of proxies returned,
      and didn't actually check that it returned the right ones.
    - The old spec only tested who were instances of the given
      class, and did not check instances of subclasses.
@myronmarston myronmarston Backport caller filter. 4194abd
Commits on Aug 26, 2013
@myronmarston myronmarston Pass __FILE__ and __LINE__ to `class_eval` properly.
This is important because w/o this, lines in the
eval'd code do not indicate what file or line
they are from when they are in a backtrace, and
that can cause CallerFilter to improperly consider
these lines to be non-rspec lines.
@myronmarston myronmarston Improve travis build.
- No need to install bundler twice.
- No need to bundle install twice.
- Skip one-by-one specs on JRuby.
- Bundler issue #2383 has been resolved,
  no need to work around it anymore.
@myronmarston myronmarston Update caller filter.
- Include additional libs.
- Don't put it at `rspec/caller_filter`.
- Ignore the "same content as rspec-core" spec for now.

The way I had this was brittle and is causing problems in rspec-core.
In rspec-core I'm trying to update the regex and add some specs but
the fact that the file is at the same path in all 3 libs (which seemed
like a simple way to ensure only one of them loads) is causing
the _wrong_ version to be loaded in rspec-core's specs, so that it's not
picking up the changes I've made.  Putting the file at the same
path in all 3 libs was a terrible idea in retrospect :(.
@myronmarston myronmarston Update caller filter once more... 2cdedfc
@myronmarston myronmarston be_true/be_false is deprecated. cee9366
@myronmarston myronmarston Refactor: reduce duplication by moving logic into super class. a3d52e4
@myronmarston myronmarston Refactor: eliminate unneeded superclass. 3f1cc33
@myronmarston myronmarston Fix source line in any_instance deprecation message.
Before, the printed line was from where a particular
instance got its `any_instance` recordings played back,
not from where the `any_instance` block originated.

This was very confusing :(.
@myronmarston myronmarston Ensure the line in the warning is the block's source location.
Note: on 1.8.7, we can't always make that work because
Proc does not have `source_location`, and even if we
define `source_location` on it manually, it loses that
when we forward it on using `&block`.
@myronmarston myronmarston Don't warn if the block ignores arguments. 528d904
@myronmarston myronmarston Silence `any_number_of_times` deprecation warning. 19c1b85
@myronmarston myronmarston On 1.8 a block doesn't indicate if it ignores args. { }.arity # => -1 { |*a| }.arity # => -1

The first one returns 0 on 1.9, allowing us to differentiate
these two cases, but returns -1 on 1.8 (as shown above).
Thus, we can't differentiate here and we have to err on
the side of printing the warning.
Commits on Aug 27, 2013
@myronmarston myronmarston Merge pull request #414 from rspec/address_warnings
Address warnings
Commits on Oct 05, 2013
@xaviershay xaviershay Deprecate using a with block with arguments.
It is confusing to have different behaviour depending on whether the
block has arguments or not, and there are better ways to do this.
@myronmarston myronmarston Merge pull request #425 from rspec/issue-377-deprecation
Deprecate using a with block with arguments.
Commits on Oct 07, 2013
@JonRowe JonRowe Merge pull request #428 from rspec/handle_receive_do_end_block_chaining
Allow chaining receive modifications off do..end blocks
@JonRowe JonRowe changelog for #428 4393eb7
Commits on Oct 16, 2013
@myronmarston myronmarston Add release notes for 2.14.4.
[ci skip]
Commits on Oct 24, 2013
@JonRowe JonRowe Merge pull request #442 from rspec/use_git_repos_env
Allow suppression of local repos
Commits on Nov 05, 2013
@xaviershay xaviershay Consistent formatting of changelog. 1afb695
@myronmarston myronmarston Merge pull request #451 from rspec/2-99-changelog
Consistent formatting of changelog.
@myronmarston myronmarston Add specs for string vs symbol usage.
Each of these specs covers a case that was previously
uncovered. We use `to_sym` in a bunch of places to
normalize message names to a symbol. This is important,
but when I removed the `to_sym` calls, nothing was failing.

Without the `to_sym` calls, these specs fail, and they also
cause subsequent specs to fail because `reset` fails to
reset (since it winds up with two message doubles, `:foo`
and "foo", and resets the first and blows up on the second
since it already got reset -- that leaves the method double
around and it is attempted to be reset on reset for
subsequent specs).
@myronmarston myronmarston Stop using deprecated `have` matchers. c882a41
@myronmarston myronmarston Silence deprecation about `with` with no args. 086b52b
Commits on Nov 06, 2013
@myronmarston myronmarston Merge pull request #453 from rspec/add-symbol-vs-string-specs
Add symbol vs string specs
Commits on Nov 07, 2013
@myronmarston myronmarston Fix unused variable warning. a7e1f9d
@myronmarston myronmarston Update changelog for v2.99.0.beta1 [ci skip] 1b15437
@myronmarston myronmarston Release 2.99.0.beta1 6844df0