From 7c6dd8002fb104b8acc1de0264a33953c28bf0d5 Mon Sep 17 00:00:00 2001 From: Matt Wynne Date: Wed, 20 Jan 2016 21:50:52 +0000 Subject: [PATCH] Better deprecation warnings Ref #942 --- lib/cucumber/deprecate.rb | 2 +- lib/cucumber/running_test_case.rb | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/cucumber/deprecate.rb b/lib/cucumber/deprecate.rb index c212290238..7ef7a191d1 100644 --- a/lib/cucumber/deprecate.rb +++ b/lib/cucumber/deprecate.rb @@ -7,7 +7,7 @@ module ForUsers AnsiEscapes = Cucumber::Gherkin::Formatter::AnsiEscapes def self.call(message, method, remove_after_version) - STDERR.puts AnsiEscapes.failed + "WARNING: #{method} is deprecated and will be removed after version #{remove_after_version}. #{message}" + AnsiEscapes.reset + STDERR.puts AnsiEscapes.failed + "\nWARNING: ##{method} is deprecated and will be removed after version #{remove_after_version}. #{message}.\n(Called from #{caller[2]})" + AnsiEscapes.reset end end diff --git a/lib/cucumber/running_test_case.rb b/lib/cucumber/running_test_case.rb index 40ac1bd32a..acbd8519b9 100644 --- a/lib/cucumber/running_test_case.rb +++ b/lib/cucumber/running_test_case.rb @@ -81,12 +81,18 @@ def passed? end def title - warn("deprecated: call #name instead") + Cucumber.deprecate( + "Call #name instead", + "RunningTestCase#title", + "2.9.9") name end def source_tags - #warn('deprecated: call #tags instead') + Cucumber.deprecate( + "Call #tags instead", + "RunningTestCase#source_tags", + "2.9.9") tags end @@ -96,8 +102,8 @@ def source_tag_names def skip_invoke! Cucumber.deprecate( - "Just call #skip_this_scenario directly", - "skip_invoke!", + "Call #skip_this_scenario directly (not on any object)", + "RunningTestCase#skip_invoke!", "2.9.9") raise Cucumber::Core::Test::Result::Skipped end