month.rb 0.11.0 → 0.11.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG +74 -0
- data/Gemfile +2 -0
- data/LICENSE +21 -0
- data/README.md +145 -0
- data/TODO.txt +26 -0
- data/lib/Month/VERSION.rb +1 -1
- data/month.rb.gemspec +44 -0
- data/test/tc_Date_to_month.rb +21 -0
- data/test/tc_Month_begin_date.rb +21 -0
- data/test/tc_Month_beginning.rb +21 -0
- data/test/tc_Month_beginning_of_month.rb +21 -0
- data/test/tc_Month_beginning_of_the_month.rb +21 -0
- data/test/tc_Month_cdate.rb +34 -0
- data/test/tc_Month_cdates.rb +111 -0
- data/test/tc_Month_comparator.rb +17 -0
- data/test/tc_Month_date.rb +34 -0
- data/test/tc_Month_dates.rb +111 -0
- data/test/tc_Month_day.rb +226 -0
- data/test/tc_Month_day_long.rb +152 -0
- data/test/tc_Month_day_short.rb +152 -0
- data/test/tc_Month_day_shortest.rb +152 -0
- data/test/tc_Month_days.rb +21 -0
- data/test/tc_Month_days_in_month.rb +21 -0
- data/test/tc_Month_days_in_the_month.rb +21 -0
- data/test/tc_Month_each_day.rb +21 -0
- data/test/tc_Month_end.rb +21 -0
- data/test/tc_Month_end_date.rb +21 -0
- data/test/tc_Month_end_of_month.rb +21 -0
- data/test/tc_Month_end_of_the_month.rb +21 -0
- data/test/tc_Month_eqlQ.rb +13 -0
- data/test/tc_Month_finish.rb +21 -0
- data/test/tc_Month_finish_date.rb +21 -0
- data/test/tc_Month_finish_of_month.rb +21 -0
- data/test/tc_Month_finish_of_the_month.rb +21 -0
- data/test/tc_Month_initialize.rb +28 -0
- data/test/tc_Month_last.rb +11 -0
- data/test/tc_Month_last_month.rb +11 -0
- data/test/tc_Month_method_missing.rb +116 -0
- data/test/tc_Month_minus.rb +23 -0
- data/test/tc_Month_next.rb +12 -0
- data/test/tc_Month_next_month.rb +12 -0
- data/test/tc_Month_plus.rb +23 -0
- data/test/tc_Month_prev.rb +11 -0
- data/test/tc_Month_prev_month.rb +11 -0
- data/test/tc_Month_previous.rb +11 -0
- data/test/tc_Month_previous_month.rb +11 -0
- data/test/tc_Month_prior.rb +11 -0
- data/test/tc_Month_prior_month.rb +11 -0
- data/test/tc_Month_self.begin_date.rb +46 -0
- data/test/tc_Month_self.beginning.rb +46 -0
- data/test/tc_Month_self.beginning_of_month.rb +46 -0
- data/test/tc_Month_self.beginning_of_the_month.rb +46 -0
- data/test/tc_Month_self.cdate.rb +33 -0
- data/test/tc_Month_self.cdates.rb +325 -0
- data/test/tc_Month_self.date.rb +33 -0
- data/test/tc_Month_self.dates.rb +325 -0
- data/test/tc_Month_self.day.rb +226 -0
- data/test/tc_Month_self.day_long.rb +152 -0
- data/test/tc_Month_self.day_short.rb +152 -0
- data/test/tc_Month_self.day_shortest.rb +152 -0
- data/test/tc_Month_self.days.rb +124 -0
- data/test/tc_Month_self.days_in_month.rb +124 -0
- data/test/tc_Month_self.days_in_the_month.rb +124 -0
- data/test/tc_Month_self.end.rb +21 -0
- data/test/tc_Month_self.end_date.rb +21 -0
- data/test/tc_Month_self.end_of_month.rb +21 -0
- data/test/tc_Month_self.end_of_the_month.rb +21 -0
- data/test/tc_Month_self.finish.rb +21 -0
- data/test/tc_Month_self.finish_date.rb +21 -0
- data/test/tc_Month_self.finish_of_month.rb +21 -0
- data/test/tc_Month_self.finish_of_the_month.rb +21 -0
- data/test/tc_Month_self.from_date.rb +21 -0
- data/test/tc_Month_self.last.rb +47 -0
- data/test/tc_Month_self.last_month.rb +47 -0
- data/test/tc_Month_self.method_missing.rb +227 -0
- data/test/tc_Month_self.next.rb +23 -0
- data/test/tc_Month_self.next_month.rb +23 -0
- data/test/tc_Month_self.now.rb +9 -0
- data/test/tc_Month_self.of.rb +78 -0
- data/test/tc_Month_self.prev.rb +23 -0
- data/test/tc_Month_self.prev_month.rb +23 -0
- data/test/tc_Month_self.previous.rb +23 -0
- data/test/tc_Month_self.previous_month.rb +23 -0
- data/test/tc_Month_self.prior.rb +23 -0
- data/test/tc_Month_self.prior_month.rb +23 -0
- data/test/tc_Month_self.start.rb +21 -0
- data/test/tc_Month_self.start_date.rb +21 -0
- data/test/tc_Month_self.start_of_month.rb +21 -0
- data/test/tc_Month_self.start_of_the_month.rb +21 -0
- data/test/tc_Month_self.succ.rb +23 -0
- data/test/tc_Month_self.succ_month.rb +23 -0
- data/test/tc_Month_self.successor.rb +23 -0
- data/test/tc_Month_self.successor_month.rb +23 -0
- data/test/tc_Month_self.this.rb +23 -0
- data/test/tc_Month_self.to_i.rb +100 -0
- data/test/tc_Month_self.to_long.rb +100 -0
- data/test/tc_Month_self.to_num.rb +100 -0
- data/test/tc_Month_self.to_number.rb +100 -0
- data/test/tc_Month_self.to_short.rb +100 -0
- data/test/tc_Month_self.today.rb +9 -0
- data/test/tc_Month_self.wday.rb +292 -0
- data/test/tc_Month_start.rb +21 -0
- data/test/tc_Month_start_date.rb +21 -0
- data/test/tc_Month_start_of_month.rb +21 -0
- data/test/tc_Month_start_of_the_month.rb +21 -0
- data/test/tc_Month_succ.rb +11 -0
- data/test/tc_Month_succ_month.rb +11 -0
- data/test/tc_Month_successor.rb +11 -0
- data/test/tc_Month_successor_month.rb +11 -0
- data/test/tc_Month_to_date.rb +17 -0
- data/test/tc_Month_to_i.rb +20 -0
- data/test/tc_Month_to_long.rb +20 -0
- data/test/tc_Month_to_num.rb +20 -0
- data/test/tc_Month_to_number.rb +20 -0
- data/test/tc_Month_to_s.rb +40 -0
- data/test/tc_Month_to_short.rb +20 -0
- data/test/tc_gemspec.rb +42 -0
- data/test/ts_Month.rb +14 -0
- metadata +126 -5
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
# test/tc_Month_self.wday.rb
|
|
2
|
+
|
|
3
|
+
class TC_Month_self_wday < Minitest::Test
|
|
4
|
+
|
|
5
|
+
def test_num_as_num
|
|
6
|
+
assert_equal 0, Month.wday(1, 10, 2006)
|
|
7
|
+
assert_equal 1, Month.wday(2, 10, 2006)
|
|
8
|
+
assert_equal 2, Month.wday(3, 10, 2006)
|
|
9
|
+
assert_equal 3, Month.wday(4, 10, 2006)
|
|
10
|
+
assert_equal 4, Month.wday(5, 10, 2006)
|
|
11
|
+
assert_equal 5, Month.wday(6, 10, 2006)
|
|
12
|
+
assert_equal 6, Month.wday(7, 10, 2006)
|
|
13
|
+
assert_equal 0, Month.wday(8, 10, 2006)
|
|
14
|
+
assert_equal 1, Month.wday(9, 10, 2006)
|
|
15
|
+
assert_equal 2, Month.wday(10, 10, 2006)
|
|
16
|
+
assert_equal 3, Month.wday(11, 10, 2006)
|
|
17
|
+
assert_equal 4, Month.wday(12, 10, 2006)
|
|
18
|
+
assert_equal 5, Month.wday(13, 10, 2006)
|
|
19
|
+
assert_equal 6, Month.wday(14, 10, 2006)
|
|
20
|
+
assert_equal 0, Month.wday(15, 10, 2006)
|
|
21
|
+
assert_equal 1, Month.wday(16, 10, 2006)
|
|
22
|
+
assert_equal 2, Month.wday(17, 10, 2006)
|
|
23
|
+
assert_equal 3, Month.wday(18, 10, 2006)
|
|
24
|
+
assert_equal 4, Month.wday(19, 10, 2006)
|
|
25
|
+
assert_equal 5, Month.wday(20, 10, 2006)
|
|
26
|
+
assert_equal 6, Month.wday(21, 10, 2006)
|
|
27
|
+
assert_equal 0, Month.wday(22, 10, 2006)
|
|
28
|
+
assert_equal 1, Month.wday(23, 10, 2006)
|
|
29
|
+
assert_equal 2, Month.wday(24, 10, 2006)
|
|
30
|
+
assert_equal 3, Month.wday(25, 10, 2006)
|
|
31
|
+
assert_equal 4, Month.wday(26, 10, 2006)
|
|
32
|
+
assert_equal 5, Month.wday(27, 10, 2006)
|
|
33
|
+
assert_equal 6, Month.wday(28, 10, 2006)
|
|
34
|
+
assert_equal 0, Month.wday(29, 10, 2006)
|
|
35
|
+
assert_equal 1, Month.wday(30, 10, 2006)
|
|
36
|
+
assert_equal 2, Month.wday(31, 10, 2006)
|
|
37
|
+
assert_equal 3, Month.wday(1, 11, 2006)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def test_num_as_string
|
|
41
|
+
assert_equal 0, Month.wday('1', '10', '2006')
|
|
42
|
+
assert_equal 1, Month.wday('2', '10', '2006')
|
|
43
|
+
assert_equal 2, Month.wday('3', '10', '2006')
|
|
44
|
+
assert_equal 3, Month.wday('4', '10', '2006')
|
|
45
|
+
assert_equal 4, Month.wday('5', '10', '2006')
|
|
46
|
+
assert_equal 5, Month.wday('6', '10', '2006')
|
|
47
|
+
assert_equal 6, Month.wday('7', '10', '2006')
|
|
48
|
+
assert_equal 0, Month.wday('8', '10', '2006')
|
|
49
|
+
assert_equal 1, Month.wday('9', '10', '2006')
|
|
50
|
+
assert_equal 2, Month.wday('10', '10', '2006')
|
|
51
|
+
assert_equal 3, Month.wday('11', '10', '2006')
|
|
52
|
+
assert_equal 4, Month.wday('12', '10', '2006')
|
|
53
|
+
assert_equal 5, Month.wday('13', '10', '2006')
|
|
54
|
+
assert_equal 6, Month.wday('14', '10', '2006')
|
|
55
|
+
assert_equal 0, Month.wday('15', '10', '2006')
|
|
56
|
+
assert_equal 1, Month.wday('16', '10', '2006')
|
|
57
|
+
assert_equal 2, Month.wday('17', '10', '2006')
|
|
58
|
+
assert_equal 3, Month.wday('18', '10', '2006')
|
|
59
|
+
assert_equal 4, Month.wday('19', '10', '2006')
|
|
60
|
+
assert_equal 5, Month.wday('20', '10', '2006')
|
|
61
|
+
assert_equal 6, Month.wday('21', '10', '2006')
|
|
62
|
+
assert_equal 0, Month.wday('22', '10', '2006')
|
|
63
|
+
assert_equal 1, Month.wday('23', '10', '2006')
|
|
64
|
+
assert_equal 2, Month.wday('24', '10', '2006')
|
|
65
|
+
assert_equal 3, Month.wday('25', '10', '2006')
|
|
66
|
+
assert_equal 4, Month.wday('26', '10', '2006')
|
|
67
|
+
assert_equal 5, Month.wday('27', '10', '2006')
|
|
68
|
+
assert_equal 6, Month.wday('28', '10', '2006')
|
|
69
|
+
assert_equal 0, Month.wday('29', '10', '2006')
|
|
70
|
+
assert_equal 1, Month.wday('30', '10', '2006')
|
|
71
|
+
assert_equal 2, Month.wday('31', '10', '2006')
|
|
72
|
+
assert_equal 3, Month.wday('1', '11', '2006')
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def test_num_as_num_with_defaults
|
|
76
|
+
if Date.today.year == 2006 && Date.today.month == 10
|
|
77
|
+
assert_equal 0, Month.wday(1)
|
|
78
|
+
assert_equal 1, Month.wday(2)
|
|
79
|
+
assert_equal 2, Month.wday(3)
|
|
80
|
+
assert_equal 3, Month.wday(4)
|
|
81
|
+
assert_equal 4, Month.wday(5)
|
|
82
|
+
assert_equal 5, Month.wday(6)
|
|
83
|
+
assert_equal 6, Month.wday(7)
|
|
84
|
+
assert_equal 0, Month.wday(8)
|
|
85
|
+
assert_equal 1, Month.wday(9)
|
|
86
|
+
assert_equal 2, Month.wday(10)
|
|
87
|
+
assert_equal 3, Month.wday(11)
|
|
88
|
+
assert_equal 4, Month.wday(12)
|
|
89
|
+
assert_equal 5, Month.wday(13)
|
|
90
|
+
assert_equal 6, Month.wday(14)
|
|
91
|
+
assert_equal 0, Month.wday(15)
|
|
92
|
+
assert_equal 1, Month.wday(16)
|
|
93
|
+
assert_equal 2, Month.wday(17)
|
|
94
|
+
assert_equal 3, Month.wday(18)
|
|
95
|
+
assert_equal 4, Month.wday(19)
|
|
96
|
+
assert_equal 5, Month.wday(20)
|
|
97
|
+
assert_equal 6, Month.wday(21)
|
|
98
|
+
assert_equal 0, Month.wday(22)
|
|
99
|
+
assert_equal 1, Month.wday(23)
|
|
100
|
+
assert_equal 2, Month.wday(24)
|
|
101
|
+
assert_equal 3, Month.wday(25)
|
|
102
|
+
assert_equal 4, Month.wday(26)
|
|
103
|
+
assert_equal 5, Month.wday(27)
|
|
104
|
+
assert_equal 6, Month.wday(28)
|
|
105
|
+
assert_equal 0, Month.wday(29)
|
|
106
|
+
assert_equal 1, Month.wday(30)
|
|
107
|
+
assert_equal 2, Month.wday(31)
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def test_num_as_string_with_defaults
|
|
112
|
+
if Date.today.year == 2006 && Date.today.month == 10
|
|
113
|
+
assert_equal 0, Month.wday('1')
|
|
114
|
+
assert_equal 1, Month.wday('2')
|
|
115
|
+
assert_equal 2, Month.wday('3')
|
|
116
|
+
assert_equal 3, Month.wday('4')
|
|
117
|
+
assert_equal 4, Month.wday('5')
|
|
118
|
+
assert_equal 5, Month.wday('6')
|
|
119
|
+
assert_equal 6, Month.wday('7')
|
|
120
|
+
assert_equal 0, Month.wday('8')
|
|
121
|
+
assert_equal 1, Month.wday('9')
|
|
122
|
+
assert_equal 2, Month.wday('10')
|
|
123
|
+
assert_equal 3, Month.wday('11')
|
|
124
|
+
assert_equal 4, Month.wday('12')
|
|
125
|
+
assert_equal 5, Month.wday('13')
|
|
126
|
+
assert_equal 6, Month.wday('14')
|
|
127
|
+
assert_equal 0, Month.wday('15')
|
|
128
|
+
assert_equal 1, Month.wday('16')
|
|
129
|
+
assert_equal 2, Month.wday('17')
|
|
130
|
+
assert_equal 3, Month.wday('18')
|
|
131
|
+
assert_equal 4, Month.wday('19')
|
|
132
|
+
assert_equal 5, Month.wday('20')
|
|
133
|
+
assert_equal 6, Month.wday('21')
|
|
134
|
+
assert_equal 0, Month.wday('22')
|
|
135
|
+
assert_equal 1, Month.wday('23')
|
|
136
|
+
assert_equal 2, Month.wday('24')
|
|
137
|
+
assert_equal 3, Month.wday('25')
|
|
138
|
+
assert_equal 4, Month.wday('26')
|
|
139
|
+
assert_equal 5, Month.wday('27')
|
|
140
|
+
assert_equal 6, Month.wday('28')
|
|
141
|
+
assert_equal 0, Month.wday('29')
|
|
142
|
+
assert_equal 1, Month.wday('30')
|
|
143
|
+
assert_equal 2, Month.wday('31')
|
|
144
|
+
end
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
def test_num_as_num_with_long_month
|
|
148
|
+
assert_equal 0, Month.wday(1, 'October', 2006)
|
|
149
|
+
assert_equal 1, Month.wday(2, 'October', 2006)
|
|
150
|
+
assert_equal 2, Month.wday(3, 'October', 2006)
|
|
151
|
+
assert_equal 3, Month.wday(4, 'October', 2006)
|
|
152
|
+
assert_equal 4, Month.wday(5, 'October', 2006)
|
|
153
|
+
assert_equal 5, Month.wday(6, 'October', 2006)
|
|
154
|
+
assert_equal 6, Month.wday(7, 'October', 2006)
|
|
155
|
+
assert_equal 0, Month.wday(8, 'October', 2006)
|
|
156
|
+
assert_equal 1, Month.wday(9, 'October', 2006)
|
|
157
|
+
assert_equal 2, Month.wday(10, 'October', 2006)
|
|
158
|
+
assert_equal 3, Month.wday(11, 'October', 2006)
|
|
159
|
+
assert_equal 4, Month.wday(12, 'October', 2006)
|
|
160
|
+
assert_equal 5, Month.wday(13, 'October', 2006)
|
|
161
|
+
assert_equal 6, Month.wday(14, 'October', 2006)
|
|
162
|
+
assert_equal 0, Month.wday(15, 'October', 2006)
|
|
163
|
+
assert_equal 1, Month.wday(16, 'October', 2006)
|
|
164
|
+
assert_equal 2, Month.wday(17, 'October', 2006)
|
|
165
|
+
assert_equal 3, Month.wday(18, 'October', 2006)
|
|
166
|
+
assert_equal 4, Month.wday(19, 'October', 2006)
|
|
167
|
+
assert_equal 5, Month.wday(20, 'October', 2006)
|
|
168
|
+
assert_equal 6, Month.wday(21, 'October', 2006)
|
|
169
|
+
assert_equal 0, Month.wday(22, 'October', 2006)
|
|
170
|
+
assert_equal 1, Month.wday(23, 'October', 2006)
|
|
171
|
+
assert_equal 2, Month.wday(24, 'October', 2006)
|
|
172
|
+
assert_equal 3, Month.wday(25, 'October', 2006)
|
|
173
|
+
assert_equal 4, Month.wday(26, 'October', 2006)
|
|
174
|
+
assert_equal 5, Month.wday(27, 'October', 2006)
|
|
175
|
+
assert_equal 6, Month.wday(28, 'October', 2006)
|
|
176
|
+
assert_equal 0, Month.wday(29, 'October', 2006)
|
|
177
|
+
assert_equal 1, Month.wday(30, 'October', 2006)
|
|
178
|
+
assert_equal 2, Month.wday(31, 'October', 2006)
|
|
179
|
+
assert_equal 3, Month.wday(1, 'November', 2006)
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
def test_num_as_num_with_short_month
|
|
183
|
+
assert_equal 0, Month.wday(1, 'Oct', 2006)
|
|
184
|
+
assert_equal 1, Month.wday(2, 'Oct', 2006)
|
|
185
|
+
assert_equal 2, Month.wday(3, 'Oct', 2006)
|
|
186
|
+
assert_equal 3, Month.wday(4, 'Oct', 2006)
|
|
187
|
+
assert_equal 4, Month.wday(5, 'Oct', 2006)
|
|
188
|
+
assert_equal 5, Month.wday(6, 'Oct', 2006)
|
|
189
|
+
assert_equal 6, Month.wday(7, 'Oct', 2006)
|
|
190
|
+
assert_equal 0, Month.wday(8, 'Oct', 2006)
|
|
191
|
+
assert_equal 1, Month.wday(9, 'Oct', 2006)
|
|
192
|
+
assert_equal 2, Month.wday(10, 'Oct', 2006)
|
|
193
|
+
assert_equal 3, Month.wday(11, 'Oct', 2006)
|
|
194
|
+
assert_equal 4, Month.wday(12, 'Oct', 2006)
|
|
195
|
+
assert_equal 5, Month.wday(13, 'Oct', 2006)
|
|
196
|
+
assert_equal 6, Month.wday(14, 'Oct', 2006)
|
|
197
|
+
assert_equal 0, Month.wday(15, 'Oct', 2006)
|
|
198
|
+
assert_equal 1, Month.wday(16, 'Oct', 2006)
|
|
199
|
+
assert_equal 2, Month.wday(17, 'Oct', 2006)
|
|
200
|
+
assert_equal 3, Month.wday(18, 'Oct', 2006)
|
|
201
|
+
assert_equal 4, Month.wday(19, 'Oct', 2006)
|
|
202
|
+
assert_equal 5, Month.wday(20, 'Oct', 2006)
|
|
203
|
+
assert_equal 6, Month.wday(21, 'Oct', 2006)
|
|
204
|
+
assert_equal 0, Month.wday(22, 'Oct', 2006)
|
|
205
|
+
assert_equal 1, Month.wday(23, 'Oct', 2006)
|
|
206
|
+
assert_equal 2, Month.wday(24, 'Oct', 2006)
|
|
207
|
+
assert_equal 3, Month.wday(25, 'Oct', 2006)
|
|
208
|
+
assert_equal 4, Month.wday(26, 'Oct', 2006)
|
|
209
|
+
assert_equal 5, Month.wday(27, 'Oct', 2006)
|
|
210
|
+
assert_equal 6, Month.wday(28, 'Oct', 2006)
|
|
211
|
+
assert_equal 0, Month.wday(29, 'Oct', 2006)
|
|
212
|
+
assert_equal 1, Month.wday(30, 'Oct', 2006)
|
|
213
|
+
assert_equal 2, Month.wday(31, 'Oct', 2006)
|
|
214
|
+
assert_equal 3, Month.wday(1, 'Nov', 2006)
|
|
215
|
+
end
|
|
216
|
+
|
|
217
|
+
def test_num_as_string_with_long_month
|
|
218
|
+
assert_equal 0, Month.wday('1', 'October', '2006')
|
|
219
|
+
assert_equal 1, Month.wday('2', 'October', '2006')
|
|
220
|
+
assert_equal 2, Month.wday('3', 'October', '2006')
|
|
221
|
+
assert_equal 3, Month.wday('4', 'October', '2006')
|
|
222
|
+
assert_equal 4, Month.wday('5', 'October', '2006')
|
|
223
|
+
assert_equal 5, Month.wday('6', 'October', '2006')
|
|
224
|
+
assert_equal 6, Month.wday('7', 'October', '2006')
|
|
225
|
+
assert_equal 0, Month.wday('8', 'October', '2006')
|
|
226
|
+
assert_equal 1, Month.wday('9', 'October', '2006')
|
|
227
|
+
assert_equal 2, Month.wday('10', 'October', '2006')
|
|
228
|
+
assert_equal 3, Month.wday('11', 'October', '2006')
|
|
229
|
+
assert_equal 4, Month.wday('12', 'October', '2006')
|
|
230
|
+
assert_equal 5, Month.wday('13', 'October', '2006')
|
|
231
|
+
assert_equal 6, Month.wday('14', 'October', '2006')
|
|
232
|
+
assert_equal 0, Month.wday('15', 'October', '2006')
|
|
233
|
+
assert_equal 1, Month.wday('16', 'October', '2006')
|
|
234
|
+
assert_equal 2, Month.wday('17', 'October', '2006')
|
|
235
|
+
assert_equal 3, Month.wday('18', 'October', '2006')
|
|
236
|
+
assert_equal 4, Month.wday('19', 'October', '2006')
|
|
237
|
+
assert_equal 5, Month.wday('20', 'October', '2006')
|
|
238
|
+
assert_equal 6, Month.wday('21', 'October', '2006')
|
|
239
|
+
assert_equal 0, Month.wday('22', 'October', '2006')
|
|
240
|
+
assert_equal 1, Month.wday('23', 'October', '2006')
|
|
241
|
+
assert_equal 2, Month.wday('24', 'October', '2006')
|
|
242
|
+
assert_equal 3, Month.wday('25', 'October', '2006')
|
|
243
|
+
assert_equal 4, Month.wday('26', 'October', '2006')
|
|
244
|
+
assert_equal 5, Month.wday('27', 'October', '2006')
|
|
245
|
+
assert_equal 6, Month.wday('28', 'October', '2006')
|
|
246
|
+
assert_equal 0, Month.wday('29', 'October', '2006')
|
|
247
|
+
assert_equal 1, Month.wday('30', 'October', '2006')
|
|
248
|
+
assert_equal 2, Month.wday('31', 'October', '2006')
|
|
249
|
+
assert_equal 3, Month.wday('1', 'November', '2006')
|
|
250
|
+
end
|
|
251
|
+
|
|
252
|
+
def test_num_as_string_with_short_month
|
|
253
|
+
assert_equal 0, Month.wday('1', 'Oct', '2006')
|
|
254
|
+
assert_equal 1, Month.wday('2', 'Oct', '2006')
|
|
255
|
+
assert_equal 2, Month.wday('3', 'Oct', '2006')
|
|
256
|
+
assert_equal 3, Month.wday('4', 'Oct', '2006')
|
|
257
|
+
assert_equal 4, Month.wday('5', 'Oct', '2006')
|
|
258
|
+
assert_equal 5, Month.wday('6', 'Oct', '2006')
|
|
259
|
+
assert_equal 6, Month.wday('7', 'Oct', '2006')
|
|
260
|
+
assert_equal 0, Month.wday('8', 'Oct', '2006')
|
|
261
|
+
assert_equal 1, Month.wday('9', 'Oct', '2006')
|
|
262
|
+
assert_equal 2, Month.wday('10', 'Oct', '2006')
|
|
263
|
+
assert_equal 3, Month.wday('11', 'Oct', '2006')
|
|
264
|
+
assert_equal 4, Month.wday('12', 'Oct', '2006')
|
|
265
|
+
assert_equal 5, Month.wday('13', 'Oct', '2006')
|
|
266
|
+
assert_equal 6, Month.wday('14', 'Oct', '2006')
|
|
267
|
+
assert_equal 0, Month.wday('15', 'Oct', '2006')
|
|
268
|
+
assert_equal 1, Month.wday('16', 'Oct', '2006')
|
|
269
|
+
assert_equal 2, Month.wday('17', 'Oct', '2006')
|
|
270
|
+
assert_equal 3, Month.wday('18', 'Oct', '2006')
|
|
271
|
+
assert_equal 4, Month.wday('19', 'Oct', '2006')
|
|
272
|
+
assert_equal 5, Month.wday('20', 'Oct', '2006')
|
|
273
|
+
assert_equal 6, Month.wday('21', 'Oct', '2006')
|
|
274
|
+
assert_equal 0, Month.wday('22', 'Oct', '2006')
|
|
275
|
+
assert_equal 1, Month.wday('23', 'Oct', '2006')
|
|
276
|
+
assert_equal 2, Month.wday('24', 'Oct', '2006')
|
|
277
|
+
assert_equal 3, Month.wday('25', 'Oct', '2006')
|
|
278
|
+
assert_equal 4, Month.wday('26', 'Oct', '2006')
|
|
279
|
+
assert_equal 5, Month.wday('27', 'Oct', '2006')
|
|
280
|
+
assert_equal 6, Month.wday('28', 'Oct', '2006')
|
|
281
|
+
assert_equal 0, Month.wday('29', 'Oct', '2006')
|
|
282
|
+
assert_equal 1, Month.wday('30', 'Oct', '2006')
|
|
283
|
+
assert_equal 2, Month.wday('31', 'Oct', '2006')
|
|
284
|
+
assert_equal 3, Month.wday('1', 'Nov', '2006')
|
|
285
|
+
end
|
|
286
|
+
|
|
287
|
+
def test_crap
|
|
288
|
+
assert_nil Month.wday('random')
|
|
289
|
+
assert_nil Month.wday(32)
|
|
290
|
+
end
|
|
291
|
+
|
|
292
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# test/tc_Month_start.rb
|
|
2
|
+
|
|
3
|
+
class TC_Month_start < Minitest::Test
|
|
4
|
+
|
|
5
|
+
def test_start
|
|
6
|
+
assert_equal Date.new(2006, 1, 1), Month.new(2006, 1).start
|
|
7
|
+
assert_equal Date.new(2006, 2, 1), Month.new(2006, 2).start
|
|
8
|
+
assert_equal Date.new(2008, 2, 1), Month.new(2008, 2).start
|
|
9
|
+
assert_equal Date.new(2006, 3, 1), Month.new(2006, 3).start
|
|
10
|
+
assert_equal Date.new(2006, 4, 1), Month.new(2006, 4).start
|
|
11
|
+
assert_equal Date.new(2006, 5, 1), Month.new(2006, 5).start
|
|
12
|
+
assert_equal Date.new(2006, 6, 1), Month.new(2006, 6).start
|
|
13
|
+
assert_equal Date.new(2006, 7, 1), Month.new(2006, 7).start
|
|
14
|
+
assert_equal Date.new(2006, 8, 1), Month.new(2006, 8).start
|
|
15
|
+
assert_equal Date.new(2006, 9, 1), Month.new(2006, 9).start
|
|
16
|
+
assert_equal Date.new(2006, 10, 1), Month.new(2006, 10).start
|
|
17
|
+
assert_equal Date.new(2006, 11, 1), Month.new(2006, 11).start
|
|
18
|
+
assert_equal Date.new(2006, 12, 1), Month.new(2006, 12).start
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# test/tc_Month_start_date.rb
|
|
2
|
+
|
|
3
|
+
class TC_Month_start_date < Minitest::Test
|
|
4
|
+
|
|
5
|
+
def test_start_date
|
|
6
|
+
assert_equal Date.new(2006, 1, 1), Month.new(2006, 1).start_date
|
|
7
|
+
assert_equal Date.new(2006, 2, 1), Month.new(2006, 2).start_date
|
|
8
|
+
assert_equal Date.new(2008, 2, 1), Month.new(2008, 2).start_date
|
|
9
|
+
assert_equal Date.new(2006, 3, 1), Month.new(2006, 3).start_date
|
|
10
|
+
assert_equal Date.new(2006, 4, 1), Month.new(2006, 4).start_date
|
|
11
|
+
assert_equal Date.new(2006, 5, 1), Month.new(2006, 5).start_date
|
|
12
|
+
assert_equal Date.new(2006, 6, 1), Month.new(2006, 6).start_date
|
|
13
|
+
assert_equal Date.new(2006, 7, 1), Month.new(2006, 7).start_date
|
|
14
|
+
assert_equal Date.new(2006, 8, 1), Month.new(2006, 8).start_date
|
|
15
|
+
assert_equal Date.new(2006, 9, 1), Month.new(2006, 9).start_date
|
|
16
|
+
assert_equal Date.new(2006, 10, 1), Month.new(2006, 10).start_date
|
|
17
|
+
assert_equal Date.new(2006, 11, 1), Month.new(2006, 11).start_date
|
|
18
|
+
assert_equal Date.new(2006, 12, 1), Month.new(2006, 12).start_date
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# test/tc_Month_start_of_month.rb
|
|
2
|
+
|
|
3
|
+
class TC_Month_start_of_month < Minitest::Test
|
|
4
|
+
|
|
5
|
+
def test_start_of_month
|
|
6
|
+
assert_equal Date.new(2006, 1, 1), Month.new(2006, 1).start_of_month
|
|
7
|
+
assert_equal Date.new(2006, 2, 1), Month.new(2006, 2).start_of_month
|
|
8
|
+
assert_equal Date.new(2008, 2, 1), Month.new(2008, 2).start_of_month
|
|
9
|
+
assert_equal Date.new(2006, 3, 1), Month.new(2006, 3).start_of_month
|
|
10
|
+
assert_equal Date.new(2006, 4, 1), Month.new(2006, 4).start_of_month
|
|
11
|
+
assert_equal Date.new(2006, 5, 1), Month.new(2006, 5).start_of_month
|
|
12
|
+
assert_equal Date.new(2006, 6, 1), Month.new(2006, 6).start_of_month
|
|
13
|
+
assert_equal Date.new(2006, 7, 1), Month.new(2006, 7).start_of_month
|
|
14
|
+
assert_equal Date.new(2006, 8, 1), Month.new(2006, 8).start_of_month
|
|
15
|
+
assert_equal Date.new(2006, 9, 1), Month.new(2006, 9).start_of_month
|
|
16
|
+
assert_equal Date.new(2006, 10, 1), Month.new(2006, 10).start_of_month
|
|
17
|
+
assert_equal Date.new(2006, 11, 1), Month.new(2006, 11).start_of_month
|
|
18
|
+
assert_equal Date.new(2006, 12, 1), Month.new(2006, 12).start_of_month
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# test/tc_Month_start_of_the_month.rb
|
|
2
|
+
|
|
3
|
+
class TC_Month_start_of_the_month < Minitest::Test
|
|
4
|
+
|
|
5
|
+
def test_start_of_the_month
|
|
6
|
+
assert_equal Date.new(2006, 1, 1), Month.new(2006, 1).start_of_the_month
|
|
7
|
+
assert_equal Date.new(2006, 2, 1), Month.new(2006, 2).start_of_the_month
|
|
8
|
+
assert_equal Date.new(2008, 2, 1), Month.new(2008, 2).start_of_the_month
|
|
9
|
+
assert_equal Date.new(2006, 3, 1), Month.new(2006, 3).start_of_the_month
|
|
10
|
+
assert_equal Date.new(2006, 4, 1), Month.new(2006, 4).start_of_the_month
|
|
11
|
+
assert_equal Date.new(2006, 5, 1), Month.new(2006, 5).start_of_the_month
|
|
12
|
+
assert_equal Date.new(2006, 6, 1), Month.new(2006, 6).start_of_the_month
|
|
13
|
+
assert_equal Date.new(2006, 7, 1), Month.new(2006, 7).start_of_the_month
|
|
14
|
+
assert_equal Date.new(2006, 8, 1), Month.new(2006, 8).start_of_the_month
|
|
15
|
+
assert_equal Date.new(2006, 9, 1), Month.new(2006, 9).start_of_the_month
|
|
16
|
+
assert_equal Date.new(2006, 10, 1), Month.new(2006, 10).start_of_the_month
|
|
17
|
+
assert_equal Date.new(2006, 11, 1), Month.new(2006, 11).start_of_the_month
|
|
18
|
+
assert_equal Date.new(2006, 12, 1), Month.new(2006, 12).start_of_the_month
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# test/tc_Month_succ.rb
|
|
2
|
+
|
|
3
|
+
class TC_Month_succ < Minitest::Test
|
|
4
|
+
|
|
5
|
+
def test_succ
|
|
6
|
+
assert_equal Month.new(2011, 2), Month.new(2011, 1).succ
|
|
7
|
+
assert_equal Month.new(2012, 1), Month.new(2011, 12).succ
|
|
8
|
+
assert_equal Month.new(2012, 12), Month.new(2012, 11).succ
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# test/tc_Month_succ_month.rb
|
|
2
|
+
|
|
3
|
+
class TC_Month_succ_month < Minitest::Test
|
|
4
|
+
|
|
5
|
+
def test_succ_month
|
|
6
|
+
assert_equal Month.new(2011, 2), Month.new(2011, 1).succ_month
|
|
7
|
+
assert_equal Month.new(2012, 1), Month.new(2011, 12).succ_month
|
|
8
|
+
assert_equal Month.new(2012, 12), Month.new(2012, 11).succ_month
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# test/tc_Month_successor.rb
|
|
2
|
+
|
|
3
|
+
class TC_Month_successor < Minitest::Test
|
|
4
|
+
|
|
5
|
+
def test_successor
|
|
6
|
+
assert_equal Month.new(2011, 2), Month.new(2011, 1).successor
|
|
7
|
+
assert_equal Month.new(2012, 1), Month.new(2011, 12).successor
|
|
8
|
+
assert_equal Month.new(2012, 12), Month.new(2012, 11).successor
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# test/tc_Month_successor_month.rb
|
|
2
|
+
|
|
3
|
+
class TC_Month_successor_month < Minitest::Test
|
|
4
|
+
|
|
5
|
+
def test_successor_month
|
|
6
|
+
assert_equal Month.new(2011, 2), Month.new(2011, 1).successor_month
|
|
7
|
+
assert_equal Month.new(2012, 1), Month.new(2011, 12).successor_month
|
|
8
|
+
assert_equal Month.new(2012, 12), Month.new(2012, 11).successor_month
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# test/tc_Month_to_date.rb
|
|
2
|
+
|
|
3
|
+
class TC_Month_to_date < Minitest::Test
|
|
4
|
+
|
|
5
|
+
def test_plus
|
|
6
|
+
assert_equal Date.new(2010, 12, 1).year, Month.new(2010, 12).to_date.year
|
|
7
|
+
assert_equal Date.new(2010, 12, 1).month, Month.new(2010, 12).to_date.month
|
|
8
|
+
assert_equal Date.new(2010, 12, 1).day, Month.new(2010, 12).to_date.day
|
|
9
|
+
assert_equal Date.new(2011, 11, 1).year, Month.new(2011, 11).to_date.year
|
|
10
|
+
assert_equal Date.new(2011, 11, 1).month, Month.new(2011, 11).to_date.month
|
|
11
|
+
assert_equal Date.new(2011, 11, 1).day, Month.new(2011, 11).to_date.day
|
|
12
|
+
assert_equal Date.new(2011, 10, 1).year, Month.new(2011, 10).to_date.year
|
|
13
|
+
assert_equal Date.new(2011, 10, 1).month, Month.new(2011, 10).to_date.month
|
|
14
|
+
assert_equal Date.new(2011, 10, 1).day, Month.new(2011, 10).to_date.day
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# test/tc_Month_to_i.rb
|
|
2
|
+
|
|
3
|
+
class TC_Month_to_i < Minitest::Test
|
|
4
|
+
|
|
5
|
+
def test_to_i
|
|
6
|
+
assert_equal 1, Month.new(2006, 1).to_i
|
|
7
|
+
assert_equal 2, Month.new(2006, 2).to_i
|
|
8
|
+
assert_equal 3, Month.new(2006, 3).to_i
|
|
9
|
+
assert_equal 4, Month.new(2006, 4).to_i
|
|
10
|
+
assert_equal 5, Month.new(2006, 5).to_i
|
|
11
|
+
assert_equal 6, Month.new(2006, 6).to_i
|
|
12
|
+
assert_equal 7, Month.new(2006, 7).to_i
|
|
13
|
+
assert_equal 8, Month.new(2006, 8).to_i
|
|
14
|
+
assert_equal 9, Month.new(2006, 9).to_i
|
|
15
|
+
assert_equal 10, Month.new(2006, 10).to_i
|
|
16
|
+
assert_equal 11, Month.new(2006, 11).to_i
|
|
17
|
+
assert_equal 12, Month.new(2006, 12).to_i
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# test/tc_Month_to_long.rb
|
|
2
|
+
|
|
3
|
+
class TC_Month_to_long < Minitest::Test
|
|
4
|
+
|
|
5
|
+
def test_to_long
|
|
6
|
+
assert_equal 'January', Month.new(2006, 1).to_long
|
|
7
|
+
assert_equal 'February', Month.new(2006, 2).to_long
|
|
8
|
+
assert_equal 'March', Month.new(2006, 3).to_long
|
|
9
|
+
assert_equal 'April', Month.new(2006, 4).to_long
|
|
10
|
+
assert_equal 'May', Month.new(2006, 5).to_long
|
|
11
|
+
assert_equal 'June', Month.new(2006, 6).to_long
|
|
12
|
+
assert_equal 'July', Month.new(2006, 7).to_long
|
|
13
|
+
assert_equal 'August', Month.new(2006, 8).to_long
|
|
14
|
+
assert_equal 'September', Month.new(2006, 9).to_long
|
|
15
|
+
assert_equal 'October', Month.new(2006, 10).to_long
|
|
16
|
+
assert_equal 'November', Month.new(2006, 11).to_long
|
|
17
|
+
assert_equal 'December', Month.new(2006, 12).to_long
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# test/tc_Month_to_num.rb
|
|
2
|
+
|
|
3
|
+
class TC_Month_to_num < Minitest::Test
|
|
4
|
+
|
|
5
|
+
def test_to_num
|
|
6
|
+
assert_equal 1, Month.new(2006, 1).to_num
|
|
7
|
+
assert_equal 2, Month.new(2006, 2).to_num
|
|
8
|
+
assert_equal 3, Month.new(2006, 3).to_num
|
|
9
|
+
assert_equal 4, Month.new(2006, 4).to_num
|
|
10
|
+
assert_equal 5, Month.new(2006, 5).to_num
|
|
11
|
+
assert_equal 6, Month.new(2006, 6).to_num
|
|
12
|
+
assert_equal 7, Month.new(2006, 7).to_num
|
|
13
|
+
assert_equal 8, Month.new(2006, 8).to_num
|
|
14
|
+
assert_equal 9, Month.new(2006, 9).to_num
|
|
15
|
+
assert_equal 10, Month.new(2006, 10).to_num
|
|
16
|
+
assert_equal 11, Month.new(2006, 11).to_num
|
|
17
|
+
assert_equal 12, Month.new(2006, 12).to_num
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# test/tc_Month_to_number.rb
|
|
2
|
+
|
|
3
|
+
class TC_Month_to_number < Minitest::Test
|
|
4
|
+
|
|
5
|
+
def test_to_number
|
|
6
|
+
assert_equal 1, Month.new(2006, 1).to_number
|
|
7
|
+
assert_equal 2, Month.new(2006, 2).to_number
|
|
8
|
+
assert_equal 3, Month.new(2006, 3).to_number
|
|
9
|
+
assert_equal 4, Month.new(2006, 4).to_number
|
|
10
|
+
assert_equal 5, Month.new(2006, 5).to_number
|
|
11
|
+
assert_equal 6, Month.new(2006, 6).to_number
|
|
12
|
+
assert_equal 7, Month.new(2006, 7).to_number
|
|
13
|
+
assert_equal 8, Month.new(2006, 8).to_number
|
|
14
|
+
assert_equal 9, Month.new(2006, 9).to_number
|
|
15
|
+
assert_equal 10, Month.new(2006, 10).to_number
|
|
16
|
+
assert_equal 11, Month.new(2006, 11).to_number
|
|
17
|
+
assert_equal 12, Month.new(2006, 12).to_number
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# test/tc_Month_to_s.rb
|
|
2
|
+
|
|
3
|
+
class TC_Month_to_s < Minitest::Test
|
|
4
|
+
|
|
5
|
+
def test_to_s_with_no_arguments
|
|
6
|
+
assert_equal 'January 2011', Month.new(2011, 1).to_s
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def test_to_s_with_long_argument
|
|
10
|
+
assert_equal 'January 2011', Month.new(2011, 1).to_s(:long)
|
|
11
|
+
assert_equal 'January 2011', Month.new(2011, 1).to_s('long')
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def test_to_s_with_short_argument
|
|
15
|
+
assert_equal 'Jan 2011', Month.new(2011, 1).to_s(:short)
|
|
16
|
+
assert_equal 'Jan 2011', Month.new(2011, 1).to_s('short')
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def test_to_s_with_iso_argument
|
|
20
|
+
assert_equal '2011-01', Month.new(2011, 1).to_s(:iso)
|
|
21
|
+
assert_equal '2011-01', Month.new(2011, 1).to_s('iso')
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def test_to_s_with_iso_iso_8601_argument
|
|
25
|
+
assert_equal '2011-01', Month.new(2011, 1).to_s(:iso_8601)
|
|
26
|
+
assert_equal '2011-01', Month.new(2011, 1).to_s('iso_8601')
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def test_to_s_with_an_unknown_argument
|
|
30
|
+
assert_raises(ArgumentError){Month.new(2011, 1).to_s(:medium)}
|
|
31
|
+
assert_raises(ArgumentError){Month.new(2011, 1).to_s('medium')}
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def test_to_s_with_an_argument_which_is_not_a_name_at_all
|
|
35
|
+
assert_raises(ArgumentError){Month.new(2011, 1).to_s(3)}
|
|
36
|
+
assert_raises(ArgumentError){Month.new(2011, 1).to_s(nil)}
|
|
37
|
+
assert_raises(ArgumentError){Month.new(2011, 1).to_s([:long])}
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# test/tc_Month_to_short.rb
|
|
2
|
+
|
|
3
|
+
class TC_Month_to_short < Minitest::Test
|
|
4
|
+
|
|
5
|
+
def test_to_short
|
|
6
|
+
assert_equal 'Jan', Month.new(2006, 1).to_short
|
|
7
|
+
assert_equal 'Feb', Month.new(2006, 2).to_short
|
|
8
|
+
assert_equal 'Mar', Month.new(2006, 3).to_short
|
|
9
|
+
assert_equal 'Apr', Month.new(2006, 4).to_short
|
|
10
|
+
assert_equal 'May', Month.new(2006, 5).to_short
|
|
11
|
+
assert_equal 'Jun', Month.new(2006, 6).to_short
|
|
12
|
+
assert_equal 'Jul', Month.new(2006, 7).to_short
|
|
13
|
+
assert_equal 'Aug', Month.new(2006, 8).to_short
|
|
14
|
+
assert_equal 'Sep', Month.new(2006, 9).to_short
|
|
15
|
+
assert_equal 'Oct', Month.new(2006, 10).to_short
|
|
16
|
+
assert_equal 'Nov', Month.new(2006, 11).to_short
|
|
17
|
+
assert_equal 'Dec', Month.new(2006, 12).to_short
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
end
|
data/test/tc_gemspec.rb
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# test/tc_gemspec.rb
|
|
2
|
+
|
|
3
|
+
class TC_gemspec < Minitest::Test
|
|
4
|
+
|
|
5
|
+
def spec
|
|
6
|
+
@spec ||= Gem::Specification.load(File.expand_path('../month.rb.gemspec', __dir__))
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def test_is_a_valid_specification
|
|
10
|
+
assert_equal true, spec.validate
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def test_does_not_pin_a_date
|
|
14
|
+
assert_equal Gem::Specification.new.date, spec.date
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def test_takes_its_version_from_Month_VERSION
|
|
18
|
+
assert_equal Month::VERSION, spec.version.to_s
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def test_declares_the_metadata_links_rubygems_shows_beside_the_gem
|
|
22
|
+
assert_equal %w{bug_tracker_uri changelog_uri documentation_uri source_code_uri}, spec.metadata.keys.sort
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def test_points_its_metadata_at_the_branch_which_exists
|
|
26
|
+
refute_empty spec.metadata.values.grep(%r{/blob/})
|
|
27
|
+
assert_equal [], spec.metadata.values.grep(%r{/blob/(?!master/)})
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def test_ships_the_loose_files_and_not_only_lib
|
|
31
|
+
assert_equal %w{CHANGELOG Gemfile LICENSE README.md TODO.txt month.rb.gemspec}, spec.files.reject{|f| f =~ %r{^(lib|test)/}}.sort
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def test_declares_no_runtime_dependencies
|
|
35
|
+
assert_equal [], spec.runtime_dependencies
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def test_declares_its_development_dependencies
|
|
39
|
+
assert_equal %w{minitest}, spec.development_dependencies.map(&:name).sort
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
end
|
data/test/ts_Month.rb
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# test/ts_Month.rb
|
|
2
|
+
|
|
3
|
+
require 'minitest/autorun'
|
|
4
|
+
|
|
5
|
+
test_dir = File.dirname(File.expand_path(__FILE__))
|
|
6
|
+
$LOAD_PATH.unshift(test_dir) unless $LOAD_PATH.include?(test_dir)
|
|
7
|
+
|
|
8
|
+
lib_dir = File.expand_path(File.join(test_dir, '..', 'lib'))
|
|
9
|
+
$LOAD_PATH.unshift(lib_dir) unless $LOAD_PATH.include?(lib_dir)
|
|
10
|
+
|
|
11
|
+
require File.join(lib_dir, 'Month.rb')
|
|
12
|
+
|
|
13
|
+
test_files = Dir[File.join(test_dir, '*.rb')].reject{|file| file == File.expand_path(__FILE__)}
|
|
14
|
+
test_files.each{|test_file| load test_file}
|