You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I found it frustrating that the output didn't tell me where in my test suite these deprecated calls are, and didn't really know where to find them to change them appropriately. I suggest that file name and line number information be added.
I did this for myself by making the following change:
diff --git a/lib/mocha/mock.rb b/lib/mocha/mock.rb
index 69e1bcc..5a293cb 100644
--- a/lib/mocha/mock.rb+++ b/lib/mocha/mock.rb@@ -261,7 +261,8 @@ module Mocha
@responder = nil
@unexpected_invocation = nil
if block
- Deprecation.warning('Passing a block is deprecated. Use Object#tap or define stubs/expectations with an explicit receiver instead.')+ file = caller.detect { |x| !(x.include?('mocha')) }+ Deprecation.warning("Passing a block is deprecated. Use Object#tap or define stubs/expectations with an explicit receiver instead. Called from #{file}")
instance_eval(&block)
end
end
It works well and looks nice for my use case, but I'm not sure if that simple backtrace check covers all edge cases and sadly don't have time to be more thorough and make a pull request, but I thought I'd share anyway.
The text was updated successfully, but these errors were encountered:
@chrisarcand: Thanks for reporting this and posting your code changes.
There is an existing un-documented feature whereby you can enable a debug mode which will output backtraces for each deprecation warning. You can do this by setting the MOCHA_OPTIONS environment variable to debug.
Given that there's already a way to get the backtraces for deprecation warnings and that I've captured these other issues, I hope you don't mind but I'm going to close this one. Please let me know if you disagree.
After updating to the latest version of mocha, I get many of these deprecations in my test suite:
This comes from this change: #290
I found it frustrating that the output didn't tell me where in my test suite these deprecated calls are, and didn't really know where to find them to change them appropriately. I suggest that file name and line number information be added.
I did this for myself by making the following change:
It works well and looks nice for my use case, but I'm not sure if that simple backtrace check covers all edge cases and sadly don't have time to be more thorough and make a pull request, but I thought I'd share anyway.
The text was updated successfully, but these errors were encountered: