PageRenderTime 43ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/vendor/gems/facets-2.4.5/test/lore/test_date.rb

https://bitbucket.org/mediashelf/fedora-migrator
Ruby | 66 lines | 46 code | 19 blank | 1 comment | 0 complexity | 7b39b4bc2d414f5cde043100deff5c1d MD5 | raw file
Possible License(s): GPL-3.0, GPL-2.0, IPL-1.0, AGPL-1.0, LGPL-3.0
  1. # Test facets/date.rb
  2. require 'facets/date.rb'
  3. require 'test/unit'
  4. class TC_Date < Test::Unit::TestCase
  5. def setup
  6. @d = Date.civil( 2005, 04, 20 )
  7. end
  8. def test_to_date
  9. assert_instance_of( ::Date, @d.to_date )
  10. end
  11. def test_to_time
  12. assert_instance_of( ::Time, @d.to_time )
  13. end
  14. def test_to_s
  15. assert_equal( "2005-04-20", @d.to_s )
  16. end
  17. def test_stamp_1
  18. assert_equal( "2005-04-20", @d.stamp )
  19. end
  20. def test_stamp_2
  21. assert_equal( "20 Apr", @d.stamp(:short) )
  22. end
  23. def test_stamp_3
  24. assert_equal( "April 20, 2005", @d.stamp(:long) )
  25. end
  26. def test_days_in_month
  27. assert_equal( 31, Date.new(2004,1,1).days_in_month )
  28. end
  29. def test_days_of_month
  30. assert_equal( (1..@d.days_in_month).to_a, @d.days_of_month )
  31. end
  32. end
  33. class TC_String_Date < Test::Unit::TestCase
  34. def test_to_date
  35. s = "2005-10-31"
  36. d = s.to_date
  37. assert_equal( 31, d.day )
  38. assert_equal( 10, d.month )
  39. assert_equal( 2005, d.year )
  40. end
  41. end
  42. class TestTimeConversion < Test::Unit::TestCase
  43. def test_to_date
  44. t = Time.now #parse('4/20/2005 15:37')
  45. assert_instance_of( ::Date, t.to_date )
  46. end
  47. end