Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

We’re showing branches in this repository, but you can also compare across forks.

base fork: rspec/rspec-mocks
...
head fork: rspec/rspec-mocks
Commits on Nov 13, 2012
alindeman alindeman Fixes changes link c1af6e8
Commits on Nov 25, 2012
Myron Marston myronmarston Fig line arg passed to class_eval so that it's correct.
There contents of the heredoc starts on the next line, hence the need for `+ 1`.
8b8d801
Myron Marston myronmarston Fix broken link. 0d6eea7
Myron Marston myronmarston Add support for #and_call_original to an #any_instance partial mock.
Fixes #197.
0f77e46
Myron Marston myronmarston Add explanatory comments for my last commit. d2ef056
Myron Marston myronmarston Handle additional any_instance / and_call_original edge cases.
For #197.
148db3c
Commits on Dec 03, 2012
Myron Marston myronmarston Fix stub_const/hide_const to work properly with a const like "::Foo".
It didn't work properly with names containing leading '::' before.

Fixes #200.
17daf44
Commits on Dec 10, 2012
Murahashi Sanemat Kenichi sanemat Use Kernel#inspect instead of #to_s
Kernel#inspect does not call #to_s anymore, on Ruby2.0.0
394c14a
Myron Marston myronmarston Merge pull request #204 from sanemat/fix/class-name
Use Kernel#inspect instead of #to_s
a209077
Commits on Dec 16, 2012
Myron Marston myronmarston Run travis builds against ruby 2.0. 2dcfb20
Commits on Dec 19, 2012
Myron Marston myronmarston Improve the way we run builds.
- No need for `find_path_to_rspec_exe`; I've discovered that `--standalone`
  and `--binstubs` together produce bins that don't load bundler.
- Add `-x` to `set -e` as that will cause the script to print each command
  as it runs.  No need for `print_and_run`.
- Add cucumber to test_all script, and use just that for the build.
63ae97f
Commits on Dec 20, 2012
Myron Marston myronmarston Stash and restore aliased methods when the owner is reported wrong.
Fixes #206.

While I was at it, I wanted to verify that `and_call_original` works
with this case, so I added a spec for it, too.
f86d02c
alindeman alindeman Merge pull request #207 from rspec/handle_aliased_methods
Stash and restore aliased methods when the owner is reported wrong.
ac90673
Commits on Dec 21, 2012
Myron Marston myronmarston Update Changelog. 5e41915
Myron Marston myronmarston Release 2.12.1. d7aac2c
Myron Marston myronmarston 1 more changelog entry I forgot.
[ci skip]
1ee14fc
Commits on Dec 26, 2012
Myron Marston myronmarston Cleanup whitespace. 11cccc4
Myron Marston myronmarston Simplify implementation of `and_raise`.
It can use an implementation block rather than needing to
maintain some extra state.
d9a7e36
Myron Marston myronmarston Simplify implementation of `and_throw`.
It can use an implementation block rather than needing to
maintain some extra state.
16d30dc
Myron Marston myronmarston Don't assume presence of rspec-core's `warn_deprecation` method.
rspec-mocks should be usable outside of rspec-core.
363406a
Myron Marston myronmarston Deprecate `spec/mocks` file (for rspec-1 compatibility). f9c5d6a
Commits on Dec 31, 2012
Myron Marston myronmarston Cleanup whitespace. eb6e30f
Myron Marston myronmarston Add missing require. 0db78bc
Myron Marston myronmarston Switch to new expect syntax. e5f11d7
Commits on Jan 01, 2013
Myron Marston myronmarston Convert one more example I missed to `expect` syntax.
This one isn't run on 1.8.7 (the version I was using
last night when doing the conversion).
352870a
alindeman alindeman Merge pull request #208 from rspec/new_expect_syntax
Switch to new expect syntax.
dd06392
Commits on Jan 04, 2013
alindeman alindeman Adds failing spec demonstrating #210 8825ed3
alindeman alindeman Adds a candidate fix for #210 763dda3
Commits on Jan 05, 2013
Myron Marston myronmarston Ignore .rspec-local. 6356c92
Myron Marston myronmarston Fix `and_call_original` so that it looks for the method in all ancestors
...including those mixed into the singleton class (i.e.
via a module extended onto an object instance).

Fixes #212.
14ae958
Myron Marston myronmarston Merge pull request #213 from rspec/issue-212
Fix `and_call_original` so that it looks for the method in all ancestors
80899f0
Commits on Jan 07, 2013
alindeman alindeman Cleans up the implementation after feedback from @myronmarston e3ab91c
Myron Marston myronmarston Merge pull request #211 from rspec/issue_210
Adds failing spec demonstrating #210
a0c8217
Commits on Jan 28, 2013
Myron Marston myronmarston Fix doc string typos.
[ci skip]
57543ba
Myron Marston myronmarston Handle `stub_const("::SomeUndefinedConst")`.
I thought I fixed the problem in 17daf44,
but I missed this edge case.  That only fixed `stub_const("::SomeDefinedConst").

Fixes #200.
1e3f431
Myron Marston myronmarston 2.12.2 release. bde69f0
Commits on Jan 31, 2013
Myron Marston myronmarston Simplify implementation of consecutive return values.
There's no need to track extra instance variable state (e.g. @consecutive); 
instead, the implementation lambda can just do the right thing.

This also fixes #217. Previously, message_expectation got confused when it
was in consecutive mode (due to being stubbed with multiple return values)
and then got mocked with a single return value. This simplified implementation
fixes this bug.
6123c97
Commits on Feb 04, 2013
Myron Marston myronmarston Merge pull request #218 from rspec/remove_consecutive
Simplify implementation of consecutive return values.
d90f7f8
Myron Marston myronmarston Refactor spec for greater clarity.
I found the use of `File.open` confusing for a spec
that demonstrates yielding multiple times. `File.open`
is a well-known API that only yields once.
c454058
Commits on Feb 05, 2013
Myron Marston myronmarston Use the matching parent stub rather than just picking the first one.
Previously, when a mock expectation was added, it was derived as a
child stub from the first existing stub. However, if there were multiple
existing stubs constrained with different `with` criteria, this could
cause it to pick the wrong one because it arbitrarily chose the first
one.

Our fix is to defer the choosing of the parent stub until the message
expectation is invoked, at which point we can properly match the
parent stub based on the arguments.

As part of this, I've refactored MessageExpectation, extracting a new
MessageImplementation class to hold the logic for an implementation
based on `and_return` and `and_yield` declarations.

Fixes #127.
977dc00
Commits on Feb 07, 2013
Ryan Jones ryanjones disallow unstub! on any_instance a283324
Commits on Feb 09, 2013
Myron Marston myronmarston Merge pull request #221 from rspec/use_matching_parent_stub
Use the matching parent stub rather than just picking the first one.
6e89c7f
Commits on Feb 10, 2013
Myron Marston myronmarston MRI 2.0 is passing on travis, and we want to keep it that way. a6b052b
Commits on Feb 13, 2013
Pierre pjambet Use new Codeclimate badge, made by @olivierlacan ec9b5e5
Myron Marston myronmarston Merge pull request #225 from pjambet/use_new_codeclimate_shield
Use new Codeclimate badge, made by @olivierlacan
7f10451
Commits on Feb 15, 2013
Myron Marston myronmarston Do not call `#nil?` extra times.
...in case `nil?` is expected a set number of times.

Fixes #224.
962c5a0
Myron Marston myronmarston Update changelog [ci skip]. ae02d47
Commits on Feb 17, 2013
Myron Marston myronmarston rbx-18 is failing with strange errors on travis.
    
Missing or uninitialized constant: RbConfig (NameError)
    
I don't have the energy to fight with it now :(.
0594c4f
Commits on Feb 18, 2013
Myron Marston myronmarston Fix missing_default_stub_error message so array args are handled prop…
…erly.

The source of this bug is that `raise_similar_message_args_error` receives
a list of args from multiple calls, e.g.:

foo.bar("a")
foo.bar(2, 3)

translates to `[["a"], [2, 3]]` being passed to it.  For the other `raise_...` methods, they receive an args list from a single call
(e.g. just `["a"]` for the first call in the example above).

`raise_similar_message_args_error` has slightly different logic to handle
the fact that it is different, but when `raise_missing_default_stub_error`
was added in 409955f, it wrongly copied this logic.

Fixes #226.
8c58de8
Myron Marston myronmarston Add changelog entry for #226.
[ci skip]
5f842f3
Myron Marston myronmarston Refactoring: don't make `message_expectation` responsible for finding…
… a parent stub.

This was suggested by @dchelimsky:

#221 (comment)
958485c
Myron Marston myronmarston Rename MessageImplementation to Implementation.
See #221 (comment) for the surrounding discussion.
e6771ce
Myron Marston myronmarston Merge pull request #223 from RyanonRails/unstub_any_instance
disallow unstub! on any_instance
4695072
Myron Marston myronmarston Add changelog entry for #223.
[ci skip]
8e4015f
Myron Marston myronmarston Fix `any_instance` stubbing so that it works with `Delegator` subclas…
…ses.

Fixes #219.
aa3b226
David Chelimsky dchelimsky Only run example with BasicObject when BasicObject is defined.
It's not in Ruby < 1.9.
91b0259
Myron Marston myronmarston Better fix for SimpleDelegator subclasses (#219).
My last fix did not properly simulate SimpleDelegator since it mixes in
a dup of Kernel and not Kernel itself.  This actually fixes it, and I
also fixed `and_call_original` (which suffered from the same bug) for
this case as well.
5d0e6de
Commits on Feb 21, 2013
Myron Marston myronmarston Fix any_instance.should_not_receive when used w/ any_instance.should_…
…receive.

Fixes #228.
8dc2b1d
Commits on Feb 23, 2013
David Chelimsky dchelimsky add note about expecting same message multiple times with diff args t…
…o README
eea518f
David Chelimsky dchelimsky fix type in README (that I introduced in previous commit) d0df33c
David Chelimsky dchelimsky more about should_receive multiple times with args in README 42faffa
Myron Marston myronmarston Update changelog for release 88878d1
Myron Marston myronmarston 2.13.0 release e652a02
Commits on Feb 28, 2013
Jeffrey Cutler vfrride Uses secure RubyGems URL 5d3c41f
Myron Marston myronmarston Merge pull request #232 from vfrride/patch-1
Uses secure RubyGems URL
90f10df
Commits on Mar 01, 2013
Michi Huber michihuber instantiate TestDoubles with #double instead of #stub consistently 75a3505
Michi Huber michihuber output warning if #mock or #stub are used to instantiate test doubles 843a40f
Myron Marston myronmarston Merge pull request #233 from michihuber/deprecate_stub_mock
Deprecate stub mock
e7e72dd
Myron Marston myronmarston Update changelog for #233.
[ci skip]
73d7236
Commits on Mar 03, 2013
Jon Rowe JonRowe whitespace trim ac21e3c
Jon Rowe JonRowe move resetting the mock proxy to the duplicate object, this fixes the…
… bizare issue with dup and frozen
3e23efd
Commits on Mar 04, 2013
Jon Rowe JonRowe refactor back to one method and move spec e0eca44
Myron Marston myronmarston Merge pull request #234 from JonRowe/fix_issue_with_stubbing_any_inst…
…ance_and_dup

Fix issue #229 runtime error caused by duplicating an object which is frozen and stubbing with any_instance
12532f8
Myron Marston myronmarston Changelog for #234.
[ci skip]
9dfd530
Commits on Mar 06, 2013
Myron Marston myronmarston Move method comments above method def. 359ff6a
Commits on Mar 12, 2013
Myron Marston myronmarston Fix travis CI build.
Fix travis CI build.

- Bundler 1.3 needs rbconfig to be required to run `bin/rspec` after
  installing with `--standalone --binstubs`.
  bundler/bundler#2382
- The Travis VMs no longer have 32-bit JVMs available. Aruba 0.4.11
  forced the -d32 flag. 0.5 just documents it and makes a file available
  to require that will set it. We've updated Aruba here so that the jruby
  ENV vars aren't set automatically; we've kept the flag to disable JIT
  but removed -d32.
e7417e1
Commits on Mar 15, 2013
Joe Ferris and Joël Quenneville Add test spies
* Adds have_received matcher
* Extends Proxy/MethodDouble/MessageExpectation
* Records all invocations on stubbed methods
e8cae54
Jon Rowe JonRowe deprecate stub! d1d46c0
Jon Rowe JonRowe deprecate unstub! b797760
Commits on Mar 16, 2013
Myron Marston myronmarston Merge pull request #242 from JonRowe/deprectate_stub_bang_and_unstub_…
…bang

Deprecate #stub! and #unstub!
7b8a993
Myron Marston myronmarston This is a bug fix, not a deprecation.
[ci skip]
6f88317
Myron Marston myronmarston Changelog entry for #242.
[ci skip]
ee0ecbf
Myron Marston myronmarston Remove redundancy from doc string. 5ad011c
Commits on Mar 18, 2013
Myron Marston myronmarston Add a spec that helps us limit the number of methods added to all obj…
…ects.
512bbbf
Myron Marston myronmarston Move `stub_chain` functionality out of `RSpec::Mocks::Methods`
...while maintaining the same API.

This allows us to remove the `format_chain` method from every object and
begins to prepare us for the future addition of a new expect-based syntax
to rspec-mocks (#153).
1461794
Commits on Mar 19, 2013
Jon Rowe JonRowe cleanup stray whitespace 6ac50f2
Jon Rowe JonRowe pass through arguments to @implementation as is 7c30818
Myron Marston myronmarston Merge pull request #244 from JonRowe/cleanup_whitespace
Cleanup stray whitespace
42a175e
Jon Rowe JonRowe fix style issues c843e1f
Commits on Mar 22, 2013
Myron Marston myronmarston Merge pull request #245 from JonRowe/call_original_args
Make and_call_original raise ArgumentErrors when arguments passed to methods with no arguments
8688ef6
Myron Marston myronmarston Changelog for #245.
[ci skip]
c5a83d4
Joe Ferris jferris Update documentation 0e6fcc7
Joe Ferris jferris Remove any_number_of_times 0bb2e92
Joe Ferris jferris Intention-revealing name for ignored backtrace line e300fb1
Joe Ferris jferris Remove unnecessary have_received definition 238189d
Joe Ferris jferris Reformat expectation 5badc42
Joe Ferris jferris Add another example for have_received documentation cdb0600
Joe Ferris jferris Add more cucumber scenarios for spies 110a768
Commits on Mar 23, 2013
Jon Rowe JonRowe Fix 1.9.2 bug with wrapping doubles in arrays 5416b2c
Jon Rowe JonRowe update change log 08d67c9
Myron Marston myronmarston Merge pull request #247 from JonRowe/double_array_bug
Fix a bug which prevented doubles being wrapped in an Array
ec801fc
Myron Marston myronmarston Clarify changelog entry.
Seems important to mention it was a problem with `Array(double)` but
not with `[double]`.
06f6bcb
Myron Marston myronmarston Merge branch 'master' into thoughtbot-jf-jq-spies
Conflicts:
	lib/rspec/mocks/framework.rb
658eacb
Myron Marston myronmarston Refactor specs to use public instead of private APIs.
- Just use the have_received matcher directly as its intended
  to be used, rather than invoking `matches?`, `does_not_match?`,
  etc. directly.
- Don't test `__mock_expectation` directly. I'm planning to refactor
  things to remove this method, anyway.
- Going through this exercise surfaced a few issues:
  - The failure messages when `with`, `at_least` or `at_most`
    constraints are used are quite confusing and should be improved.
    I left some TODOs in the specs to remind us to come back
    and revisit.
  - The count constraints create confusion when used with a
    negative expectation (e.g.
    `expect(dbl).not_to have_received(:a).at_most(3).times`
    is confusing and isn't specifying much. We should disallow
    them. I left a pending spec for this so we don't forget.
- These changes were necessary to enable the removal of
  `__mock_expectation` (in my next commit) -- the current ones
  were coupled to the implementation, and did not allow that
  refactoring.
4fcd9ef
Myron Marston myronmarston Remove __mock_expectation.
We want to limit the number of methods added to all object.
The use of `__send__` to get around this is a code smell
but I believe it's preferable to polluting every object with
an extra method.

This was also necessary to get the spec I added in 512bbbf to pass.
55ad2db
Myron Marston myronmarston I prefer formatting specs with blank lines between each example. b08bf17
Commits on Mar 25, 2013
Myron Marston myronmarston Extract rspec_reset/rspec_verify into a spec helper method.
This refactoring is in prep for removing rspec_reset/rspec_verify
from every object; by extracting it into a helper method it
will make it easier to change w/o breaking specs.
73fb798
Myron Marston myronmarston Externalize methods and state that was previously held on all objects.
- Remove `@mock_proxy` ivar
- Remove `rspec_verify`, `rspec_reset`, `__mock_proxy` and `__remove_mock_proxy` methods.

This is a refactoring that I'm doing to pave the way for the new expect
syntax (#153). As that syntax "wraps" objects in order to mock or stub
them, we need to externalize these methods and state. The methods directly
on the object (e.g. `stub` and `should_receive`) will simply delegate to
this external logic.

This refactoring had some nice side benefits:

- No need for the hacky YAML fix. It was only needed because we were storing
  `@mock_proxy` on the mocked object.
- AnyInstance no longer needs to much with `dup`; again, this was only needed
  because it dup'd the `@mock_proxy` ivar.
- The Marshal extension gets significantly simpler (again, due to not
  storing `@mock_proxy` on the object anymore).

Rather than storing the mock proxies on the objects, we are now storing
them in a hash, keyed by object_id.  This is pretty simple and consistent,
but could be problematic for objects that muck with `object_id`. That method
seems a bit sacred, though, so I'm not too worried about it.
210c9f0
Myron Marston myronmarston Fix specs on 1.8.7.
Hashes are ordered on 1.9 but not on 1.8. Thus, we cannot count on
the order the mock proxies will be reset or verified since they are
held in a hash.
554d80c
Commits on Mar 26, 2013
Joe Ferris jferris Disallow confusing, negative count constraints ec56b78
Joe Ferris jferris Add cucumber coverage for partial mocks ce82738
Joe Ferris jferris Fix spy failures on 1.8 2c1673f
Joe Ferris jferris Add support for as_null_object with spies 1e1fb87
Joe Ferris jferris Add special error message when using should_received with a mocked me…
…thod
0c08d6e
Commits on Mar 27, 2013
Joe Ferris jferris Clear messages received when mocks reset
* Proxy objects for class methods/global objects persist between test runs

Fixes #248.
3cb4ccc
Joe Ferris jferris Improve failure message for unexpected arguments 138d298
Commits on Mar 28, 2013
Myron Marston myronmarston Make spec pending that intermittently fails on JRuby in 1.9 mode.
I've spent a few hours troubleshooting this and haven't been able
to make progress.  It's intermittent and bizarre.  For now, just
making it pending.
d2cc42d
Myron Marston myronmarston Rename `tracked_klasses` to `tracked_classes`.
As per @dchelimsky's suggestion.
cccfb46
Myron Marston myronmarston RSpec::Mocks.space.mock_proxy_for => RSpec::Mocks.proxy_for
...for a bit shorter, nicer API.
e57b5cc
Myron Marston myronmarston Actually, this intermittently fails on JRuby 1.8, too. 34053de
Myron Marston myronmarston Merge pull request #250 from rspec/externalize_methods_and_mock_state
Externalize methods and state that was previously held on all objects.
5618f72
Myron Marston myronmarston Changelog entry for #250.
[ci skip]
39cbc13
Commits on Mar 29, 2013
Myron Marston myronmarston Merge branch 'master' into thoughtbot-jf-jq-spies d83cd03
Myron Marston myronmarston Deal with our recent changes to __mock_proxy in master.
Proxies are no longer held internally in each mock'd object.
aa1b448
Myron Marston myronmarston Fix typo: constrait => constraint b45bdad
Myron Marston myronmarston Mention new test spies feature in Changelog. dce3fd9
Myron Marston myronmarston Merge branch 'thoughtbot-jf-jq-spies' 1015876
David Chelimsky dchelimsky minor optimization: each_value instead of values.each 73e1f75
Commits on Mar 30, 2013
Marc-André Lafortune marcandre Isolate original_method_from_ancestry ffcee39
Marc-André Lafortune marcandre Handle Ruby 2.1 with full ancestry 801addc
Myron Marston myronmarston Merge pull request #257 from marcandre/ruby_21
Ruby 2.1 compatibility
37fbb27
Myron Marston myronmarston Play with seperating all proxies from current proxies. b220495