Last Updated: February 20, 2016
· jodosha
Avatar white

Ruby 1.9 RR's any_instance_of problems

I've got this strange error, while porting a Rails app to 1.9:

Argument Error:
   Wrong number of arguments (1 for 0)

Of course the offending method has the right arity, but at a certain point I found this in an RSpec' before block:

any_instance_of(Resolver, :resolve => ids)

It seems like RR redefines that method at the class level, by messing something with ObjectSpace. The solution is to use the block syntax:

any_instance_of(Resolver) {|r| stub(r).resolve {ids} }
Say Thanks