Sha256: b03fcba55e374d2dad0d7904ffbee61b4191d9f8e165babac566fff30caa5072

Contents?: true

Size: 1.54 KB

Versions: 2

Compression:

Stored size: 1.54 KB

Contents

require 'date'
require 'test/unit'
require File.join(File.dirname(__FILE__), '..', 'lib', 'timecop')

class TestTimecopInternals < Test::Unit::TestCase
  
  def test_parse_travel_args_with_time
    t = Time.now
    y, m, d, h, min, s = t.year, t.month, t.day, t.hour, t.min, t.sec
    ty, tm, td, th, tmin, ts = Timecop.instance().send(:parse_travel_args, t)
    assert_equal y, ty
    assert_equal m, tm
    assert_equal d, td
    assert_equal h, th
    assert_equal min, tmin
    assert_equal s, ts
  end

  def test_parse_travel_args_with_datetime
    t = DateTime.now
    y, m, d, h, min, s = t.year, t.month, t.day, t.hour, t.min, t.sec
    ty, tm, td, th, tmin, ts = Timecop.instance().send(:parse_travel_args, t)
    assert_equal y, ty
    assert_equal m, tm
    assert_equal d, td
    assert_equal h, th
    assert_equal min, tmin
    assert_equal s, ts
  end

  def test_parse_travel_args_with_date
    date = Date.today
    y, m, d, h, min, s = date.year, date.month, date.day, 0, 0, 0
    ty, tm, td, th, tmin, ts = Timecop.instance().send(:parse_travel_args, date)
    assert_equal y, ty
    assert_equal m, tm
    assert_equal d, td
    assert_equal h, th
    assert_equal min, tmin
    assert_equal s, ts
  end

  def test_parse_travel_args_with_individual_arguments
    y, m, d, h, min, s = 2008, 10, 10, 10, 10, 10
    ty, tm, td, th, tmin, ts = Timecop.instance().send(:parse_travel_args, y, m, d, h, min, s)
    assert_equal y, ty
    assert_equal m, tm
    assert_equal d, td
    assert_equal h, th
    assert_equal min, tmin
    assert_equal s, ts
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
jtrupiano-timecop-0.2.0 test/test_timecop_internals.rb
timecop-0.2.0 test/test_timecop_internals.rb