mirror of
https://github.com/teamcapybara/capybara.git
synced 2022-11-09 12:08:07 -05:00
Show backtrace for some depreaction calls
This commit is contained in:
parent
38b7878112
commit
922d661476
6 changed files with 16 additions and 5 deletions
|
@ -86,7 +86,7 @@ module Capybara
|
||||||
def deprecate(method, alternate_method, once = false)
|
def deprecate(method, alternate_method, once = false)
|
||||||
@deprecation_notified ||= {}
|
@deprecation_notified ||= {}
|
||||||
unless once && @deprecation_notified[method]
|
unless once && @deprecation_notified[method]
|
||||||
warn "DEPRECATED: ##{method} is deprecated, please use ##{alternate_method} instead"
|
warn "DEPRECATED: ##{method} is deprecated, please use ##{alternate_method} instead: #{Capybara::Helpers.filter_backtrace(caller)}"
|
||||||
end
|
end
|
||||||
@deprecation_notified[method] = true
|
@deprecation_notified[method] = true
|
||||||
end
|
end
|
||||||
|
|
|
@ -70,6 +70,17 @@ module Capybara
|
||||||
count == 1 ? singular : plural
|
count == 1 ? singular : plural
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def filter_backtrace(trace)
|
||||||
|
return 'No backtrace' unless trace
|
||||||
|
|
||||||
|
filter = %r{lib/capybara/|lib/rspec/|lib/minitest/}
|
||||||
|
new_trace = trace.take_while { |line| line !~ filter }
|
||||||
|
new_trace = trace.reject { |line| line =~ filter } if new_trace.empty?
|
||||||
|
new_trace = trace.dup if new_trace.empty?
|
||||||
|
|
||||||
|
new_trace.first.split(/:in /, 2).first
|
||||||
|
end
|
||||||
|
|
||||||
if defined?(Process::CLOCK_MONOTONIC)
|
if defined?(Process::CLOCK_MONOTONIC)
|
||||||
def monotonic_time; Process.clock_gettime Process::CLOCK_MONOTONIC; end
|
def monotonic_time; Process.clock_gettime Process::CLOCK_MONOTONIC; end
|
||||||
else
|
else
|
||||||
|
|
|
@ -68,7 +68,7 @@ module Capybara
|
||||||
# @deprecated Use {#matches_style?} instead.
|
# @deprecated Use {#matches_style?} instead.
|
||||||
#
|
#
|
||||||
def has_style?(styles, **options)
|
def has_style?(styles, **options)
|
||||||
warn 'DEPRECATED: has_style? is deprecated, please use matches_style?'
|
warn "DEPRECATED: has_style? is deprecated, please use matches_style? : #{Capybara::Helpers.filter_backtrace(caller)}"
|
||||||
matches_style?(styles, **options)
|
matches_style?(styles, **options)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ module Capybara
|
||||||
|
|
||||||
if expected_text.nil? && !exact?
|
if expected_text.nil? && !exact?
|
||||||
warn 'Checking for expected text of nil is confusing and/or pointless since it will always match. '\
|
warn 'Checking for expected text of nil is confusing and/or pointless since it will always match. '\
|
||||||
'Please specify a string or regexp instead.'
|
"Please specify a string or regexp instead. #{Capybara::Helpers.filter_backtrace(caller)}"
|
||||||
end
|
end
|
||||||
|
|
||||||
@expected_text = expected_text.is_a?(Regexp) ? expected_text : expected_text.to_s
|
@expected_text = expected_text.is_a?(Regexp) ? expected_text : expected_text.to_s
|
||||||
|
|
|
@ -154,7 +154,7 @@ module Capybara
|
||||||
# @deprecated
|
# @deprecated
|
||||||
#
|
#
|
||||||
def have_style(styles, **options)
|
def have_style(styles, **options)
|
||||||
warn 'DEPRECATED: have_style is deprecated, please use match_style'
|
warn "DEPRECATED: have_style is deprecated, please use match_style : #{Capybara::Helpers.filter_backtrace(caller)}"
|
||||||
match_style(styles, **options)
|
match_style(styles, **options)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
Capybara.add_selector(:css, locator_type: [String, Symbol], raw_locator: true) do
|
Capybara.add_selector(:css, locator_type: [String, Symbol], raw_locator: true) do
|
||||||
css do |css|
|
css do |css|
|
||||||
if css.is_a? Symbol
|
if css.is_a? Symbol
|
||||||
warn "DEPRECATED: Passing a symbol (#{css.inspect}) as the CSS locator is deprecated - please pass a string instead."
|
warn "DEPRECATED: Passing a symbol (#{css.inspect}) as the CSS locator is deprecated - please pass a string instead : #{Capybara::Helpers.filter_backtrace(caller)}"
|
||||||
end
|
end
|
||||||
css
|
css
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue