time_zone.rb 372 B

1234567891011121314
  1. RSpec.configure do |config|
  2. config.around(:each, :time_zone) do |example|
  3. if example.metadata[:type] == :system
  4. old_tz = ENV['TZ']
  5. ENV['TZ'] = example.metadata[:time_zone]
  6. example.run
  7. else
  8. Time.use_zone(example.metadata[:time_zone]) { example.run }
  9. end
  10. ensure
  11. ENV['TZ'] = old_tz if example.metadata[:type] == :system
  12. end
  13. end