Skip to content

Instantly share code, notes, and snippets.

@uranusjr
Created April 2, 2013 14:01
Show Gist options
  • Save uranusjr/5292424 to your computer and use it in GitHub Desktop.
Save uranusjr/5292424 to your computer and use it in GitHub Desktop.
require 'date'
def three_months_from(d)
return d >> 3
end
require './dm'
require 'test/unit'
class TestThreeMonthsFromDate < Test::Unit::TestCase
def _test_date(input_params, output_params)
target = DateTime.new(*input_params)
assert_equal(three_months_from(target), DateTime.new(*output_params))
end
def test20130331
_test_date([2013, 3, 31], [2013, 6, 30])
end
def test20130401
_test_date([2013, 4, 1], [2013, 7, 1])
end
def test20131129
_test_date([2013, 11, 29], [2014, 2, 28])
end
def test20131130
_test_date([2013, 11, 30], [2014, 2, 28])
end
def test20151129
_test_date([2015, 11, 29], [2016, 2, 29])
end
def test20151130
_test_date([2015, 11, 30], [2016, 2, 29])
end
end
# Result:
#
# Loaded suite test_dm
# Started
# ......
# Finished in 0.002752 seconds.
#
# 6 tests, 6 assertions, 0 failures, 0 errors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment