Custom formatter for Cucumber that defends against timecop overriding Time.now.
The _circleci_formatter.rb
file should be dumped into the features/support directory and specified with Cucumber's --format flag:
bundle exec cucumber --format CircleCICucumberFormatter::CircleCIJson
Timecop redefines Time.now
to Time.now_without_mock_time
. If that method exists, then we call that method instead of Time.now
.
This approach is somewhat brittle because it relies on the internals of before_step and after_step not changing.