test/test_parsing.rb in chronic-0.5.0 vs test/test_parsing.rb in chronic-0.6.0
- old
+ new
@@ -1,18 +1,15 @@
-require File.join(File.dirname(__FILE__), *%w[helper])
+require 'helper'
class TestParsing < Test::Unit::TestCase
# Wed Aug 16 14:00:00 UTC 2006
TIME_2006_08_16_14_00_00 = Time.local(2006, 8, 16, 14, 0, 0, 0)
def setup
@time_2006_08_16_14_00_00 = TIME_2006_08_16_14_00_00
end
- def test_parse_m_d
- end
-
def test_handle_rmn_sd
time = parse_now("aug 3")
assert_equal Time.local(2006, 8, 3, 12), time
time = parse_now("aug 3", :context => :past)
@@ -107,10 +104,15 @@
def test_handle_rdn_rmn_sd_t_tz_sy
time = parse_now("Mon Apr 02 17:00:00 PDT 2007")
assert_equal 1175558400, time.to_i
end
+ def test_handle_sy_sm_sd_t_tz
+ time = parse_now("2011-07-03 22:11:35 +0100")
+ assert_equal 1309727495, time.to_i
+ end
+
def test_handle_rmn_sd_sy
time = parse_now("November 18, 2010")
assert_equal Time.local(2010, 11, 18, 12), time
time = parse_now("Jan 1,2010")
@@ -205,10 +207,14 @@
time = parse_now("5/27/1979")
assert_equal Time.local(1979, 5, 27, 12), time
time = parse_now("5/27/1979 4am")
assert_equal Time.local(1979, 5, 27, 4), time
+
+ # month day overflows
+ time = parse_now("30/2/2000")
+ assert_nil time
end
def test_handle_sd_sm_sy
time = parse_now("27/5/1979")
assert_equal Time.local(1979, 5, 27, 12), time
@@ -775,14 +781,14 @@
assert_equal Time.local(2006, 8, 16, 0, 15), parse_now("8/16/2006 at 12:15a")
assert_equal Time.local(2006, 8, 16, 18, 30), parse_now("8/16/2006 at 6:30p")
end
def test_argument_validation
- assert_raise(Chronic::InvalidArgumentException) do
+ assert_raise(ArgumentError) do
time = Chronic.parse("may 27", :foo => :bar)
end
- assert_raise(Chronic::InvalidArgumentException) do
+ assert_raise(ArgumentError) do
time = Chronic.parse("may 27", :context => :bar)
end
end
def test_seasons