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`.
This commit is contained in:
Matt Brictson 2021-01-18 08:24:12 -08:00 committed by GitHub
parent 1c277895c9
commit b83a39bd86
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 0 deletions

View File

@ -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)