From: Caleb Clausen Date: 2006-07-28T01:57:56+09:00 Subject: Re: Wrapped method causing infinite recursion in rcov On 7/27/06, Pedro C�rte-Real wrote: > # Wrap around get to check the markup on :success requests. > alias_method :old_get, :get > def get(*args) > old_get(*args) > if @response.success? > assert_valid_markup > end > end > > This works fine with my tests. When running rcov though it creates > infinite recursion in the call to old_get. Has anyone tried anything > of the sort? Is it a bug in rcov? At a guess, (something is) rcov is also wrapping #get and using the same name for the old version of the method. At least, that's always been the explanation when I've encountered these 'wrapping a method causes infinite recursion' problems. Try this way instead, it should eliminate any possibility that your code is participating in the recursion. old_get=instance_method(:get) define_method(:get) do |*args| old_get[*args] if @response.success? assert_valid_markup end end This trick was originated by Mauricio Fernandez, as far as I know.