Half of the examples are irrelevant to the eventual bug, so I could drop
them but we didn't prove they worked anywhere else which has bugged me in
the past so also open to refactoring...

On Friday, 6 December 2013, Myron Marston wrote:

> In spec/rspec/mocks/any_instance_spec.rb:
>
> > +            example_group.run reporter
> > +            expect(results).to eq([])
> > +          end
> > +
> > +          it 'cleans up sub classes between specs' do
> > +            examples << example_group.example do
> > +              SuperClass.any_instance.stub(:foo)
> > +              SubClass.any_instance.stub(:foo).and_return('baz')
> > +              expect(SubClass.new.foo).to eq('baz')
> > +            end
> > +            examples << example_group.example do
> > +              expect(SubClass.new.foo).to eq('bar')
> > +            end
> > +            example_group.run reporter
> > +            expect(results).to eq([])
> > +          end
>
> This seems pretty messy :(. Elsewhere in rspec-mocks we test this kind of
> stuff by showing the effects that reset has. (Knowing that rspec-core
> calls that after each example). It helps focus the example on the
> rspec-mocks APIs that come into play rather than the rspec-core ones.
>
> Alternately, if you want to do this kind of thing (where you define
> example groups and examples from within an example and then run them),
> maybe we should port rspec-core's sandboxing logic to rspec-support so you
> can use it here?
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/rspec/rspec-mocks/pull/488/files#r8154128>
> .
>