From b83a39bd865e82710cf465068187671af6d04441 Mon Sep 17 00:00:00 2001 From: Matt Brictson Date: Mon, 18 Jan 2021 08:24:12 -0800 Subject: [PATCH] Fix cucumber `puts` deprecation warnings (#2075) Cucumber has deprecated `puts` in favor of `log` for logging messages to the current cucumber formatter. In our case we actually want it both ways: we want to log messages using the cucumber formatter when cucumber is running, but use `Kernel#puts` otherwise. So, use `respond_to?` to see if cucumber's `log` is available, and if not, fall back to `puts`. --- features/support/vagrant_helpers.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/features/support/vagrant_helpers.rb b/features/support/vagrant_helpers.rb index a0465a2a..5f75f8af 100644 --- a/features/support/vagrant_helpers.rb +++ b/features/support/vagrant_helpers.rb @@ -30,6 +30,12 @@ module VagrantHelpers return [stdout, stderr] if status.success? raise VagrantSSHCommandError, status end + + def puts(message) + # Attach log messages to the current cucumber feature (`log`), + # or simply puts to the console (`super`) if we are outside of cucumber. + respond_to?(:log) ? log(message) : super(message) + end end World(VagrantHelpers)