Skip to content

Commit

Permalink
Add test for travisjeffery#88
Browse files Browse the repository at this point in the history
  • Loading branch information
yaauie committed Jun 4, 2013
1 parent 3104370 commit 1f7fcb6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def a_time_stack_item
end

def assert_date_times_equal(dt1, dt2)
assert_equal dt1, dt2, "Failed for timezone: #{ENV['TZ']}: #{dt1.to_s} not equal to #{dt2.to_s}"
assert_in_delta dt1.to_time.to_f, dt2.to_time.to_f, 0.01, "Failed for timezone: #{ENV['TZ']}: #{dt1.to_s} not equal to #{dt2.to_s}"
end

end
13 changes: 13 additions & 0 deletions test/time_stack_item_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,19 @@ def test_utc_offset_to_rational
assert_equal Rational(1, 24), a_time_stack_item.send(:utc_offset_to_rational, 3600)
end

def test_datetime_in_presence_of_activesupport_timezone
skip('requires ActiveSupport') unless Time.respond_to? :zone
backed_up_zone, backed_up_tzvar = Time.zone, ENV['TZ']

Time.zone = ENV['TZ'] = 'America/Los_Angeles'
t = DateTime.new(2001, 2, 28, 23, 59, 59.5)
tsi = Timecop::TimeStackItem.new(:freeze, t)

assert_date_times_equal t, tsi.datetime
ensure
Time.zone, ENV['TZ'] = backed_up_zone, backed_up_tzvar
end

# Ensure DateTimes handle changing DST properly
def test_datetime_for_dst_to_non_dst
Timecop.freeze(DateTime.parse("2009-12-1 00:38:00 -0500"))
Expand Down

0 comments on commit 1f7fcb6

Please sign in to comment.