spy icon indicating copy to clipboard operation
spy copied to clipboard

error: method 'info' has already been hooked after bump to ruby 2.7.2

Open lilien1010 opened this issue 3 years ago • 1 comments

my test code is like below, but it keep saying that method 'info' has already been hooked

Spy.on(Rails.logger, [:debug, :info, :error].freeze)
Error:
xxxx::xxxx:
Spy::AlreadyHookedError: #<ActiveSupport::Logger:0x00007f8f70d28488> method 'info' has already been hooked
    test/xxxx.rb:8:in `block (2 levels) in <module:xxxxxx>'

4904 tests, 13087 assertions, 0 failures, 1 errors, 0 skips

any idea how to fix this?

lilien1010 avatar Mar 10 '21 08:03 lilien1010

I realize it's been 2 years, but did you ever sort this out? I just started using this gem yesterday, but I found I had to call Spy.off to tear down my spies at the end of the test.

https://github.com/ryanong/spy/blob/6ac9240b6b628421f573b6bfc6c30b93a26ba567/lib/spy.rb#L32-L41

krazylegz avatar Apr 04 '23 18:04 krazylegz