rspec/rspec-mocks — pull request #688 by myronmarston (2014-05-30 01:45:04+00:00)
Title: Dont create any instance recorder unnecessarily, and other cleanup

This fixes #687. It also optimizes a few things internally.

Note that the infinite recursion is still possible with a spec like this:

``` ruby
it 'fails when `class` is stubbed on a partial double when `any_instance` has already been used' do
allow_any_instance_of(Object).to receive(:bar).and_return(2)
dbl = Object.new
allow(dbl).to receive_messages(:foo => 1, :class => String)
expect(dbl.foo).to eq(1)
end
```

* Must stub `class` on a partial double, not a normal test double
* Must use `any_instance` so that there is an active any instance recorder

However, I'm OK not fixing this. If you are taking a real object and making it lie and say that it's class is something else, you're waaaaaay off the farm, IMO. Stubbing `class` on a test double as #687 demonstrates, while still odd, is more reasonable, IMO. I don't really want to go down the rabbit hole of having to explicitly disallow things that I don't think users will actually do and that are pretty obviously outside the scope of accepted practice.

Thoughts?

/cc @PragTob @JonRowe @xaviershay @soulcutter @cupakromer