Permalink
Browse files

Randomize timezone in spec runs

  • Loading branch information...
1 parent 4d4b4fb commit 62bc105e45d1680f86ecf3b8e65ef69f71316c6f @johnnyshields johnnyshields committed Jan 11, 2014
Showing with 8 additions and 4 deletions.
  1. +1 −1 spec/integration/shared/by_direction.rb
  2. +6 −2 spec/spec_helper.rb
  3. +1 −1 spec/unit/normalization_spec.rb
@@ -10,7 +10,7 @@
end
context 'timespan' do
- subject { Event.before(DateTime.parse '2014-01-05') }
+ subject { Event.before(Time.parse '2014-01-05') }
its(:count){ should eq 4 }
end
View
@@ -8,13 +8,17 @@
$:.unshift(File.join(File.dirname(__FILE__), "../lib"))
require 'active_record'
-require 'mongoid' if Gem::Version.create(RUBY_VERSION.dup) >= Gem::Version.create('1.9.3')
+require 'mongoid'
require 'active_support'
require 'active_support/core_ext/string/conversions'
require 'timecop'
require 'by_star'
-Time.zone = 'UTC'
+# Specs should pass regardless of timezone
+Time.zone = %w(Asia/Tokyo America/New_York UTC).sample
+puts "Running specs in #{Time.zone} timezone..."
+
+# Set Rails time to 2014-01-01 00:00:00
Timecop.travel(Time.zone.local(2014))
def testing_mongoid?
@@ -24,7 +24,7 @@
end
context 'DateTime' do
- let(:input){ DateTime.parse('2014-01-01 15:00:00') }
+ let(:input){ DateTime.parse("2014-01-01 15:00:00 #{Time.zone}") }
it { should eq Time.zone.parse('2014-01-01 15:00:00') }
end

0 comments on commit 62bc105

Please sign in to comment.