rspec/rspec-core — pull request #852 by myronmarston (2013-03-31 00:12:28+00:00)
Title: Fix sandboxing of rspec-core's own specs.

Because rspec-core dog-foods itself, rspec-core's spec suite has
examples that define example groups and examples and run them. The
usual lifetime of an RSpec::Mocks::Proxy is for one example
(the proxy cache gets cleared between each example), but since the
specs in rspec-core's suite sometimes create test doubles and pass
them to examples a spec defines and runs, the test double's proxy
must live beyond the inner example: it must live for the scope
of wherever it got defined. Here we implement the necessary semantics
for rspec-core's specs:

- #verify_all and #reset_all affect only mocks that were created
within the current scope.
- Mock proxies live for the duration of the scope in which they are
created.

Thus, mock proxies created in an inner example live for only that
example, but mock proxies created in an outer example can be used
in an inner example but will only be reset/verified when the outer
example completes.

These changes were needed due to the recent refactoring in rspec-mocks
which changed what held a reference to the mock proxy (a proxy cache
rather than an instance variable on the mocked object) and the
lifecycle of those proxies (cleared between each example rather
than persisted for the rest of the process).