Last active
May 17, 2017 07:58
-
-
Save dcorking/30b452d923b2ef6bc8b8873720f83f4c to your computer and use it in GitHub Desktop.
rails_helper or spec_helper snippet to trace the clock before and after each rspec example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ENV["RAILS_ENV"] ||= 'test' | |
require 'spec_helper' | |
# ... | |
RSpec.configure do |config| | |
# Can help you spot problems with system time, timezones and time travel, | |
# especially if multiple specs interact with each other | |
# Check this doc for the difference between ::now and ::current : | |
# http://api.rubyonrails.org/classes/ActiveSupport/Testing/TimeHelpers.html#method-i-travel_to | |
config.around(:each) do |example| | |
puts "Time.now: #{Time.now}" | |
puts "Time.current: #{Time.current}" | |
example.run | |
puts "Time.now: #{Time.now}" | |
puts "Time.current: #{Time.current}" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment