Skip to content

Instantly share code, notes, and snippets.

@fotinakis
Last active August 29, 2015 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fotinakis/602c6bb955937681ea46 to your computer and use it in GitHub Desktop.
Save fotinakis/602c6bb955937681ea46 to your computer and use it in GitHub Desktop.
Pure-Rails timefreeze and flaky-ness removal for all specs
RSpec.configure do |config|
# Freeze time and truncate microseconds in all examples.
config.around(:each) do |example|
# Truncate microseconds to avoid test flakiness when the DB truncates microseconds
now_without_microseconds = Time.now.in_time_zone.change(usec: 0)
travel_to(now_without_microseconds) do
example.run
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment