Class: TestMonthForTime
- Inherits:
-
Test::Unit::TestCase
- Object
- Test::Unit::TestCase
- TestMonthForTime
- Defined in:
- lib/test/modules/time/test_month.rb
Instance Method Summary collapse
- #test_all_fridays_in_month ⇒ Object
- #test_all_mondays_in_month ⇒ Object
- #test_all_saturdays_in_month ⇒ Object
- #test_all_sundays_in_month ⇒ Object
- #test_all_thursdays_in_month ⇒ Object
- #test_all_tuesdays_in_month ⇒ Object
- #test_all_wednesdays_in_month ⇒ Object
- #test_beginning_of_month ⇒ Object
- #test_end_of_month ⇒ Object
- #test_last_day_of_month ⇒ Object
- #test_month? ⇒ Boolean
- #test_name_of_month ⇒ Object
Instance Method Details
#test_all_fridays_in_month ⇒ Object
142 143 144 145 |
# File 'lib/test/modules/time/test_month.rb', line 142 def test_all_fridays_in_month assert_equal [4, 11, 18, 25], Time.new(2013, 1, 1).all_fridays_in_month assert_equal [1, 8, 15, 22], Time.new(2013, 2, 1).all_fridays_in_month end |
#test_all_mondays_in_month ⇒ Object
122 123 124 125 |
# File 'lib/test/modules/time/test_month.rb', line 122 def test_all_mondays_in_month assert_equal [7, 14, 21, 28], Time.new(2013, 1, 1).all_mondays_in_month assert_equal [4, 11, 18, 25], Time.new(2013, 2, 1).all_mondays_in_month end |
#test_all_saturdays_in_month ⇒ Object
147 148 149 150 |
# File 'lib/test/modules/time/test_month.rb', line 147 def test_all_saturdays_in_month assert_equal [5, 12, 19, 26], Time.new(2013, 1, 1).all_saturdays_in_month assert_equal [2, 9, 16, 23], Time.new(2013, 2, 1).all_saturdays_in_month end |
#test_all_sundays_in_month ⇒ Object
117 118 119 120 |
# File 'lib/test/modules/time/test_month.rb', line 117 def test_all_sundays_in_month assert_equal [6, 13, 20, 27], Time.new(2013, 1, 1).all_sundays_in_month assert_equal [3, 10, 17, 24], Time.new(2013, 2, 1).all_sundays_in_month end |
#test_all_thursdays_in_month ⇒ Object
137 138 139 140 |
# File 'lib/test/modules/time/test_month.rb', line 137 def test_all_thursdays_in_month assert_equal [3, 10, 17, 24, 31], Time.new(2013, 1, 1).all_thursdays_in_month assert_equal [7, 14, 21, 28], Time.new(2013, 2, 1).all_thursdays_in_month end |
#test_all_tuesdays_in_month ⇒ Object
127 128 129 130 |
# File 'lib/test/modules/time/test_month.rb', line 127 def test_all_tuesdays_in_month assert_equal [1, 8, 15, 22, 29], Time.new(2013, 1, 1).all_tuesdays_in_month assert_equal [5, 12, 19, 26], Time.new(2013, 2, 1).all_tuesdays_in_month end |
#test_all_wednesdays_in_month ⇒ Object
132 133 134 135 |
# File 'lib/test/modules/time/test_month.rb', line 132 def test_all_wednesdays_in_month assert_equal [2, 9, 16, 23, 30], Time.new(2013, 1, 1).all_wednesdays_in_month assert_equal [6, 13, 20, 27], Time.new(2013, 2, 1).all_wednesdays_in_month end |
#test_beginning_of_month ⇒ Object
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/test/modules/time/test_month.rb', line 91 def test_beginning_of_month assert_equal Time.new(2012, 1, 1), Time.new(2012, 1, 31).beginning_of_month assert_equal Time.new(2012, 2, 1), Time.new(2012, 2, 29).beginning_of_month assert_equal Time.new(2012, 3, 1), Time.new(2012, 3, 31).beginning_of_month assert_equal Time.new(2012, 4, 1), Time.new(2012, 4, 30).beginning_of_month assert_equal Time.new(2012, 5, 1), Time.new(2012, 5, 31).beginning_of_month assert_equal Time.new(2012, 6, 1), Time.new(2012, 6, 30).beginning_of_month assert_equal Time.new(2012, 7, 1), Time.new(2012, 7, 31).beginning_of_month assert_equal Time.new(2012, 8, 1), Time.new(2012, 8, 31).beginning_of_month assert_equal Time.new(2012, 9, 1), Time.new(2012, 9, 30).beginning_of_month assert_equal Time.new(2012, 10, 1), Time.new(2012, 10, 31).beginning_of_month assert_equal Time.new(2012, 11, 1), Time.new(2012, 11, 30).beginning_of_month assert_equal Time.new(2012, 12, 1), Time.new(2012, 12, 31).beginning_of_month end |
#test_end_of_month ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/test/modules/time/test_month.rb', line 65 def test_end_of_month assert_equal Time.new(2012, 1, 31), Time.new(2012, 1, 1).end_of_month assert_equal Time.new(2012, 2, 29), Time.new(2012, 2, 2).end_of_month assert_equal Time.new(2012, 3, 31), Time.new(2012, 3, 1).end_of_month assert_equal Time.new(2012, 4, 30), Time.new(2012, 4, 3).end_of_month assert_equal Time.new(2012, 5, 31), Time.new(2012, 5, 1).end_of_month assert_equal Time.new(2012, 6, 30), Time.new(2012, 6, 30).end_of_month assert_equal Time.new(2012, 7, 31), Time.new(2012, 7, 1).end_of_month assert_equal Time.new(2012, 8, 31), Time.new(2012, 8, 5).end_of_month assert_equal Time.new(2012, 9, 30), Time.new(2012, 9, 2).end_of_month assert_equal Time.new(2012, 10, 31), Time.new(2012, 10, 22).end_of_month assert_equal Time.new(2012, 11, 30), Time.new(2012, 11, 10).end_of_month assert_equal Time.new(2012, 12, 31), Time.new(2012, 12, 15).end_of_month end |
#test_last_day_of_month ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/test/modules/time/test_month.rb', line 39 def test_last_day_of_month assert_equal 31, Time.new(2012, 1, 31).last_day_of_month assert_equal 29, Time.new(2012, 2, 29).last_day_of_month assert_equal 31, Time.new(2012, 3, 31).last_day_of_month assert_equal 30, Time.new(2012, 4, 30).last_day_of_month assert_equal 31, Time.new(2012, 5, 31).last_day_of_month assert_equal 30, Time.new(2012, 6, 30).last_day_of_month assert_equal 31, Time.new(2012, 7, 31).last_day_of_month assert_equal 31, Time.new(2012, 8, 31).last_day_of_month assert_equal 30, Time.new(2012, 9, 30).last_day_of_month assert_equal 31, Time.new(2012, 10, 31).last_day_of_month assert_equal 30, Time.new(2012, 11, 30).last_day_of_month assert_equal 31, Time.new(2012, 12, 31).last_day_of_month end |
#test_month? ⇒ Boolean
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/test/modules/time/test_month.rb', line 13 def test_month? assert Time.new(2012, 1, 1).january? assert Time.new(2012, 2, 1).february? assert Time.new(2012, 3, 1).march? assert Time.new(2012, 4, 1).april? assert Time.new(2012, 5, 1).may? assert Time.new(2012, 6, 1).june? assert Time.new(2012, 7, 1).july? assert Time.new(2012, 8, 1).august? assert Time.new(2012, 9, 1).september? assert Time.new(2012, 10, 1).october? assert Time.new(2012, 11, 1).november? assert Time.new(2012, 12, 1).december? end |
#test_name_of_month ⇒ Object
152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/test/modules/time/test_month.rb', line 152 def test_name_of_month assert_equal 'January', Time.new(2012, 1, 1).name_of_month assert_equal 'February', Time.new(2012, 2, 1).name_of_month assert_equal 'March', Time.new(2012, 3, 1).name_of_month assert_equal 'April', Time.new(2012, 4, 1).name_of_month assert_equal 'May', Time.new(2012, 5, 1).name_of_month assert_equal 'June', Time.new(2012, 6, 1).name_of_month assert_equal 'July', Time.new(2012, 7, 1).name_of_month assert_equal 'August', Time.new(2012, 8, 1).name_of_month assert_equal 'September', Time.new(2012, 9, 1).name_of_month assert_equal 'October', Time.new(2012, 10, 1).name_of_month assert_equal 'November', Time.new(2012, 11, 1).name_of_month assert_equal 'December', Time.new(2012, 12, 1).name_of_month end |