[rspec-users] any_instance

Matt Mower self at mattmower.com
Wed Jun 4 05:19:13 EDT 2008

Hi folks.

I'm very interested in the status of a port of any_instance from Mocha to RSpec.

In particular I have a spec suite that I wrote using RSpec but with
Mocha that depends heavily on any_instance. This is because it stubs
out one or two methods from an underlying API. In attempting to
convert the suite to RSpec mocks (because that's what we're using for
the rest of the project) I had to give up. Attempting to replace
objects by stubbing :new and returning mocks felt like a huge amount
of busy work compared to one-line with any_instance.

I noticed that Brian Takita appears to have an implementation of
any_instance here:


which I tried, without success, to make work in my own version of
rspec (1.1.4). I was able to call any_instance but it didn't seem to
be having an effect. I emailed Brian but I think he was at rails conf
so I guess he may be fighting a backlog of work/email.

Is there any likelyhood of any_instance making it into RSpec proper?
If not, has anyone else had any luck implementing it?



Matt Mower :: http://matt.blogs.it/

More information about the rspec-users mailing list