Skip to content

Commit

Permalink
Fix cucumber puts deprecation warnings (capistrano#2075)
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
mattbrictson authored Jan 18, 2021
1 parent 1c27789 commit b83a39b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions features/support/vagrant_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ def run_vagrant_command(command)
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)

0 comments on commit b83a39b

Please sign in to comment.