Skip to content

Commit

Permalink
Merge pull request #313 from freerange/display-file-and-line-number-i…
Browse files Browse the repository at this point in the history
…n-deprecation-warning

Display file and line number in deprecation warning
  • Loading branch information
floehopper committed Jan 6, 2018
2 parents 9732726 + 6e40487 commit 582ec7e
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/mocha/deprecation.rb
@@ -1,4 +1,4 @@
require 'mocha/debug'
require 'mocha/backtrace_filter'

module Mocha

Expand All @@ -10,13 +10,16 @@ class << self

def warning(message)
@messages << message
$stderr.puts "\n*** Mocha deprecation warning: #{message}\n\n" unless mode == :disabled
$stderr.puts caller.join("\n ") if mode == :debug
unless mode == :disabled
filter = BacktraceFilter.new
location = filter.filtered(caller)[0]
$stderr.puts "Mocha deprecation warning at #{location}: #{message}"
end
end

end

self.mode = Debug::OPTIONS['debug'] ? :debug : :enabled
self.mode = :enabled
self.messages = []

end
Expand Down

0 comments on commit 582ec7e

Please sign in to comment.