Last active
July 17, 2019 09:39
-
-
Save nruth/82d10c861b612bc37c3b4d66da1d9489 to your computer and use it in GitHub Desktop.
Finding where deprecation warnings are coming from (Capybara, Rails, etc, anything that calls Kernel#warn)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TracePoint.trace(:c_call) do |tp| | |
# the various methods on tp tell you where warn is defined, but we want to know about the call stack, | |
# in particular the test code that the test library didn't like and decided to warn us about, | |
# so let's Array#grep the caller strings, filtering out the rspec library lines | |
if tp.method_id == :warn | |
app_lines = caller(0).grep(%r{enough-of-your-app-code-path-to-match/}) | |
app_lines_without_reporter = app_lines.grep_v(/name-of-your-rspec-support-file-holding-this-code/) | |
p app_lines_without_reporter.join("\n") | |
p | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment