[rspec-users] any_instance
David Chelimsky
dchelimsky at gmail.com
Wed Jun 4 09:24:00 EDT 2008
On Jun 4, 2008, at 4:19 AM, Matt Mower wrote:
> 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:
>
> http://github.com/btakita/pain-point/tree/ca9a65e7110ccaa37175c741e1cea1aaa9776180/vendor/plugins/rspec/lib/spec/mocks
>
> 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?
There was an implementation of it that didn't quite work for me in http://github.com/dchelimsky/rspec/commit/45a6837
so we reverted it. I have zero personal interest in this feature
(use of which I find to be an anti-pattern) but am open to applying a
patch as long as it meets criteria described in http://rspec.lighthouseapp.com/projects/5645/tickets/28
.
Until such a patch comes my way, you can re-apply the existing patch
(probably have to use git-format patch and tweak some things - any git-
pros got advice on the best way to do that?) and it should work for
most cases for you.
Cheers,
David
More information about the rspec-users
mailing list