workpattern 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +8 -20
- data/.travis.yml +18 -12
- data/{CHANGELOG → CHANGELOG.md} +19 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +31 -0
- data/LICENSE.txt +21 -0
- data/README.md +2 -27
- data/Rakefile +0 -0
- data/lib/workpattern.rb +5 -73
- data/lib/workpattern/clock.rb +0 -0
- data/lib/workpattern/constants.rb +72 -0
- data/lib/workpattern/day.rb +245 -0
- data/lib/workpattern/version.rb +1 -1
- data/lib/workpattern/week.rb +119 -296
- data/lib/workpattern/week_pattern.rb +144 -0
- data/lib/workpattern/workpattern.rb +73 -125
- data/script/console +0 -0
- data/script/destroy +0 -0
- data/script/generate +0 -0
- data/script/txt2html +0 -0
- data/workpattern.gemspec +32 -20
- metadata +21 -33
- data/lib/workpattern/utility/base.rb +0 -27
- data/test/test_clock.rb +0 -29
- data/test/test_helper.rb +0 -2
- data/test/test_week.rb +0 -532
- data/test/test_workpattern.rb +0 -307
- data/test/test_workpattern_module.rb +0 -88
data/test/test_workpattern.rb
DELETED
@@ -1,307 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
-
|
3
|
-
class TestWorkpattern < MiniTest::Test #:nodoc:
|
4
|
-
def setup
|
5
|
-
Workpattern.clear
|
6
|
-
end
|
7
|
-
|
8
|
-
def test_can_diff_between_working_period_and_resting_day
|
9
|
-
# This is the test for issue 15
|
10
|
-
mywp = Workpattern.new('My Workpattern', 2013, 3)
|
11
|
-
mywp.resting(days: :weekend)
|
12
|
-
mywp.resting(days: :weekday,
|
13
|
-
from_time: Workpattern.clock(0, 0),
|
14
|
-
to_time: Workpattern.clock(8, 59))
|
15
|
-
mywp.resting(days: :weekday,
|
16
|
-
from_time: Workpattern.clock(12, 0),
|
17
|
-
to_time: Workpattern.clock(12, 59))
|
18
|
-
mywp.resting(days: :weekday,
|
19
|
-
from_time: Workpattern.clock(18, 0),
|
20
|
-
to_time: Workpattern.clock(23, 59))
|
21
|
-
|
22
|
-
mydate1 = Time.gm(2013, 9, 27, 0, 0, 0)
|
23
|
-
mydate2 = Time.gm(2013, 9, 27, 23, 59, 59)
|
24
|
-
|
25
|
-
mywp.resting(start: mydate1, finish: mydate2, days: :all,
|
26
|
-
from_time: Workpattern.clock(0, 0),
|
27
|
-
to_time: Workpattern.clock(23, 59))
|
28
|
-
time_a = Time.gm(2013, 9, 26, 17, 0)
|
29
|
-
time_b = Time.gm(2013, 9, 27, 10, 0)
|
30
|
-
assert_equal 60, mywp.diff(time_a, time_b)
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_must_create_a_working_workpattern
|
34
|
-
name = 'mywp'
|
35
|
-
base = 2001
|
36
|
-
span = 11
|
37
|
-
wp = Workpattern.new(name, base, span)
|
38
|
-
assert_equal name, wp.name
|
39
|
-
assert_equal base, wp.base
|
40
|
-
assert_equal span, wp.span
|
41
|
-
assert_equal Time.gm(base), wp.from
|
42
|
-
assert_equal Time.gm(base + span - 1, 12, 31, 23, 59), wp.to
|
43
|
-
end
|
44
|
-
|
45
|
-
def test_must_set_patterns_correctly
|
46
|
-
name = 'mypattern'
|
47
|
-
base = 2000
|
48
|
-
span = 11
|
49
|
-
wp = Workpattern.new(name, base, span)
|
50
|
-
|
51
|
-
start = clock(0, 0)
|
52
|
-
finish = clock(8, 59)
|
53
|
-
assert_equal 10_080, get_week(wp.weeks).week_total
|
54
|
-
wp.workpattern(days: :all, from_time: start,
|
55
|
-
to_time: finish, work_type: 0)
|
56
|
-
assert_equal 6_300, get_week(wp.weeks).week_total
|
57
|
-
wp.workpattern(days: :sun, from_time: start,
|
58
|
-
to_time: finish, work_type: 1)
|
59
|
-
assert_equal 6_840, get_week(wp.weeks).week_total
|
60
|
-
wp.workpattern(days: :mon, from_time: start,
|
61
|
-
to_time: finish, work_type: 1)
|
62
|
-
assert_equal 7_380, get_week(wp.weeks).week_total
|
63
|
-
wp.workpattern(days: :all, from_time: clock(18, 0),
|
64
|
-
to_time: clock(18, 19), work_type: 0)
|
65
|
-
assert_equal 7_240, get_week(wp.weeks).week_total
|
66
|
-
wp.workpattern(days: :all, from_time: clock(0, 0),
|
67
|
-
to_time: clock(23, 59), work_type: 0)
|
68
|
-
assert_equal 0, get_week(wp.weeks).week_total
|
69
|
-
wp.workpattern(days: :all, from_time: clock(0, 0),
|
70
|
-
to_time: clock(0, 0), work_type: 1)
|
71
|
-
assert_equal 7, get_week(wp.weeks).week_total
|
72
|
-
wp.workpattern(days: :all, from_time: clock(23, 59),
|
73
|
-
to_time: clock(23, 59), work_type: 1)
|
74
|
-
assert_equal 14, get_week(wp.weeks).week_total
|
75
|
-
wp.workpattern(days: :all, from_time: clock(0, 0),
|
76
|
-
to_time: clock(23, 59), work_type: 1)
|
77
|
-
assert_equal 10_080, get_week(wp.weeks).week_total
|
78
|
-
wp.workpattern(days: :weekend, from_time: clock(0, 0),
|
79
|
-
to_time: clock(23, 59), work_type: 0)
|
80
|
-
assert_equal 7_200, get_week(wp.weeks).week_total
|
81
|
-
end
|
82
|
-
|
83
|
-
def test_must_add_minutes_in_a_working_workpattern
|
84
|
-
name = 'mypattern'
|
85
|
-
base = 1999
|
86
|
-
span = 11
|
87
|
-
wp = Workpattern.new(name, base, span)
|
88
|
-
tests = [[2000, 1, 1, 0, 0, 3, 2000, 1, 1, 0, 3],
|
89
|
-
[2000, 1, 1, 23, 59, 0, 2000, 1, 1, 23, 59],
|
90
|
-
[2000, 1, 1, 23, 59, 1, 2000, 1, 2, 0, 0],
|
91
|
-
[2000, 1, 1, 23, 59, 2, 2000, 1, 2, 0, 1],
|
92
|
-
[2000, 1, 1, 9, 10, 33, 2000, 1, 1, 9, 43],
|
93
|
-
[2000, 1, 1, 9, 10, 60, 2000, 1, 1, 10, 10],
|
94
|
-
[2000, 1, 1, 9, 0, 931, 2000, 1, 2, 0, 31],
|
95
|
-
[2000, 1, 1, 0, 0, 3, 2000, 1, 1, 0, 3]]
|
96
|
-
clue = 'add minutes in a working workpattern'
|
97
|
-
calc_test(wp, tests, clue)
|
98
|
-
end
|
99
|
-
|
100
|
-
def test_must_add_minutes_in_a_resting_workpattern
|
101
|
-
name = 'mypattern'
|
102
|
-
base = 1999
|
103
|
-
span = 11
|
104
|
-
wp = Workpattern.new(name, base, span)
|
105
|
-
start = Time.gm(1999, 6, 11, 0, 0)
|
106
|
-
finish = Time.gm(2003, 6, 8, 0, 0)
|
107
|
-
wp.workpattern(days: :all, start: start, finish: finish, work_type: 0)
|
108
|
-
tests = [[2000, 1, 1, 0, 0, 3, 2003, 6, 9, 0, 3],
|
109
|
-
[2000, 1, 1, 23, 59, 0, 2000, 1, 1, 23, 59],
|
110
|
-
[2000, 1, 1, 23, 59, 1, 2003, 6, 9, 0, 1],
|
111
|
-
[2000, 1, 1, 23, 59, 2, 2003, 6, 9, 0, 2],
|
112
|
-
[2000, 1, 1, 9, 10, 33, 2003, 6, 9, 0, 33],
|
113
|
-
[2000, 1, 1, 9, 10, 60, 2003, 6, 9, 1, 0],
|
114
|
-
[2000, 1, 1, 9, 0, 931, 2003, 6, 9, 15, 31],
|
115
|
-
[2000, 1, 1, 0, 0, 3, 2003, 6, 9, 0, 3]]
|
116
|
-
clue = 'add minutes in a resting workpattern'
|
117
|
-
calc_test(wp, tests, clue)
|
118
|
-
end
|
119
|
-
|
120
|
-
def test_must_add_minutes_in_a_patterned_workpattern
|
121
|
-
assert true
|
122
|
-
end
|
123
|
-
|
124
|
-
def test_must_subtract_minutes_in_a_working_workpattern
|
125
|
-
name = 'mypattern'
|
126
|
-
base = 1999
|
127
|
-
span = 11
|
128
|
-
wp = Workpattern.new(name, base, span)
|
129
|
-
tests = [[2000, 1, 1, 0, 0, -3, 1999, 12, 31, 23, 57],
|
130
|
-
[2000, 1, 1, 23, 59, 0, 2000, 1, 1, 23, 59],
|
131
|
-
[2000, 1, 1, 23, 59, -1, 2000, 1, 1, 23, 58],
|
132
|
-
[2000, 1, 1, 23, 59, -2, 2000, 1, 1, 23, 57],
|
133
|
-
[2000, 1, 1, 9, 10, -33, 2000, 1, 1, 8, 37],
|
134
|
-
[2000, 1, 1, 9, 10, -60, 2000, 1, 1, 8, 10],
|
135
|
-
[2000, 1, 1, 9, 0, -931, 1999, 12, 31, 17, 29],
|
136
|
-
[2000, 1, 1, 0, 0, -3, 1999, 12, 31, 23, 57]]
|
137
|
-
clue = 'subtract minutes in a working workpattern'
|
138
|
-
calc_test(wp, tests, clue)
|
139
|
-
end
|
140
|
-
|
141
|
-
def test_must_subtract_minutes_in_a_resting_workpattern
|
142
|
-
name = 'mypattern'
|
143
|
-
base = 1999
|
144
|
-
span = 11
|
145
|
-
wp = Workpattern.new(name, base, span)
|
146
|
-
start = Time.gm(1999, 6, 11, 0, 0)
|
147
|
-
finish = Time.gm(2003, 6, 8, 0, 0)
|
148
|
-
wp.workpattern(days: :all, start: start, finish: finish, work_type: 0)
|
149
|
-
tests = [[2000, 1, 1, 0, 0, -3, 1999, 6, 10, 23, 57],
|
150
|
-
[2000, 1, 1, 23, 59, 0, 2000, 1, 1, 23, 59],
|
151
|
-
[2000, 1, 1, 23, 59, -1, 1999, 6, 10, 23, 59],
|
152
|
-
[2000, 1, 1, 23, 59, -2, 1999, 6, 10, 23, 58],
|
153
|
-
[2000, 1, 1, 9, 10, -33, 1999, 6, 10, 23, 27],
|
154
|
-
[2000, 1, 1, 9, 10, -60, 1999, 6, 10, 23, 0],
|
155
|
-
[2000, 1, 1, 9, 0, -931, 1999, 6, 10, 8, 29],
|
156
|
-
[2000, 1, 1, 0, 0, -3, 1999, 6, 10, 23, 57]]
|
157
|
-
clue = 'subtract minutes in a resting workpattern'
|
158
|
-
calc_test(wp, tests, clue)
|
159
|
-
end
|
160
|
-
|
161
|
-
def test_must_subtract_minutes_in_a_patterned_workpattern
|
162
|
-
assert true
|
163
|
-
end
|
164
|
-
|
165
|
-
def test_must_calculate_difference_between_dates_in_working_calender
|
166
|
-
name = 'mypattern'
|
167
|
-
base = 1999
|
168
|
-
span = 40
|
169
|
-
wp = Workpattern.new(name, base, span)
|
170
|
-
|
171
|
-
[[2012, 10, 1, 0, 0, 2012, 10, 1, 0, 0, 0],
|
172
|
-
[2012, 10, 1, 0, 0, 2012, 10, 1, 0, 1, 1],
|
173
|
-
[2012, 10, 1, 0, 50, 2012, 10, 1, 0, 59, 9],
|
174
|
-
[2012, 10, 1, 8, 50, 2012, 10, 1, 9, 0, 10],
|
175
|
-
[2012, 10, 1, 0, 0, 2012, 10, 1, 23, 59, 1_439],
|
176
|
-
[2012, 10, 1, 0, 0, 2012, 10, 2, 0, 0, 1_440],
|
177
|
-
[2012, 10, 1, 0, 0, 2012, 10, 2, 0, 1, 1_441],
|
178
|
-
[2012, 10, 1, 0, 0, 2013, 3, 22, 6, 11, 248_051],
|
179
|
-
[2012, 10, 1, 0, 1, 2012, 10, 1, 0, 0, 1],
|
180
|
-
[2012, 10, 1, 0, 59, 2012, 10, 1, 0, 50, 9],
|
181
|
-
[2012, 10, 1, 9, 0, 2012, 10, 1, 8, 50, 10],
|
182
|
-
[2012, 10, 1, 23, 59, 2012, 10, 1, 0, 0, 1_439],
|
183
|
-
[2012, 10, 2, 0, 0, 2012, 10, 1, 0, 0, 1_440],
|
184
|
-
[2012, 10, 2, 0, 1, 2012, 10, 1, 0, 0, 1_441],
|
185
|
-
[2013, 3, 22, 6, 11, 2012, 10, 1, 0, 0, 248_051],
|
186
|
-
[2012, 10, 2, 6, 11, 2012, 10, 4, 8, 9, 2_998]].each do
|
187
|
-
|s_year, s_month, s_day, s_hour, s_min,
|
188
|
-
f_year, f_month, f_day, f_hour, f_min,
|
189
|
-
result|
|
190
|
-
start = Time.gm(s_year, s_month, s_day, s_hour, s_min)
|
191
|
-
finish = Time.gm(f_year, f_month, f_day, f_hour, f_min)
|
192
|
-
duration, _result_date = wp.diff(start, finish)
|
193
|
-
assert_equal result, duration, "duration diff(#{start}, #{finish})"
|
194
|
-
end
|
195
|
-
end
|
196
|
-
|
197
|
-
def test_must_calculate_difference_between_minutes_in_resting_workpattern
|
198
|
-
assert true
|
199
|
-
end
|
200
|
-
|
201
|
-
def test_must_calculate_difference_between_minutes_in_pattern_workpattern
|
202
|
-
assert true
|
203
|
-
end
|
204
|
-
|
205
|
-
def test_must_follow_the_example_in_workpattern
|
206
|
-
mywp = Workpattern.new 'My Workpattern', 2011, 10
|
207
|
-
mywp.resting days: :weekend
|
208
|
-
mywp.resting days: :weekday,
|
209
|
-
from_time: Workpattern.clock(0, 0),
|
210
|
-
to_time: Workpattern.clock(8, 59)
|
211
|
-
mywp.resting days: :weekday,
|
212
|
-
from_time: Workpattern.clock(12, 0),
|
213
|
-
to_time: Workpattern.clock(12, 59)
|
214
|
-
mywp.resting days: :weekday,
|
215
|
-
from_time: Workpattern.clock(18, 0),
|
216
|
-
to_time: Workpattern.clock(23, 59)
|
217
|
-
mydate = Time.gm 2011, 9, 1, 9, 0
|
218
|
-
result_date = mywp.calc mydate, 1920 # => 6/9/11@18:00
|
219
|
-
assert_equal Time.gm(2011, 9, 6, 18, 0), result_date,
|
220
|
-
'example in workpattern'
|
221
|
-
assert_equal 1920, mywp.diff(mydate, result_date)
|
222
|
-
end
|
223
|
-
|
224
|
-
def test_must_calculate_across_week_patterns
|
225
|
-
name = 'mypattern'
|
226
|
-
base = 2011
|
227
|
-
span = 11
|
228
|
-
wp = Workpattern.new(name, base, span)
|
229
|
-
start = Time.gm(2012, 9, 24, 0, 0)
|
230
|
-
finish = Time.gm(2012, 10, 14, 0, 0)
|
231
|
-
wp.resting(days: :all, start: start, finish: finish)
|
232
|
-
wp.working(days: :mon, start: start, finish: finish,
|
233
|
-
from_time: Workpattern.clock(1, 0),
|
234
|
-
to_time: Workpattern.clock(1, 59))
|
235
|
-
wp.working(days: :tue, start: start, finish: finish,
|
236
|
-
from_time: Workpattern.clock(2, 0),
|
237
|
-
to_time: Workpattern.clock(2, 59))
|
238
|
-
wp.working(days: :wed, start: start, finish: finish,
|
239
|
-
from_time: Workpattern.clock(3, 0),
|
240
|
-
to_time: Workpattern.clock(3, 59))
|
241
|
-
wp.working(days: :thu, start: start, finish: finish,
|
242
|
-
from_time: Workpattern.clock(4, 0),
|
243
|
-
to_time: Workpattern.clock(4, 59))
|
244
|
-
wp.working(days: :fri, start: start, finish: finish,
|
245
|
-
from_time: Workpattern.clock(5, 0),
|
246
|
-
to_time: Workpattern.clock(5, 59))
|
247
|
-
wp.working(days: :sat, start: start, finish: finish,
|
248
|
-
from_time: Workpattern.clock(6, 0),
|
249
|
-
to_time: Workpattern.clock(6, 59))
|
250
|
-
wp.working(days: :sun, start: start, finish: finish,
|
251
|
-
from_time: Workpattern.clock(0, 0),
|
252
|
-
to_time: Workpattern.clock(23, 59))
|
253
|
-
|
254
|
-
# Mon Tue Wed Thu Fri Sat Sun
|
255
|
-
# 24 25 26 27 28 29 30
|
256
|
-
# 1 2 3 4 5 6 7
|
257
|
-
# 8 9 10 11 12 13 14
|
258
|
-
# Mon 01:00 - 01:59
|
259
|
-
# Tue 02:00 - 02:59
|
260
|
-
# Wed 03:00 - 03:59
|
261
|
-
# Thu 04:00 - 04:59
|
262
|
-
# Fri 05:00 - 05:59
|
263
|
-
# Sat 06:00 - 06:59
|
264
|
-
# Sun 00:00 - 23:59
|
265
|
-
#
|
266
|
-
tests = [[2012, 10, 1, 1, 0, 1, 2012, 10, 1, 1, 1],
|
267
|
-
[2012, 10, 14, 23, 59, 1, 2012, 10, 15, 0, 0],
|
268
|
-
[2012, 10, 1, 1, 0, 60 * 60 + 1, 2012, 10, 15, 0, 1],
|
269
|
-
[2012, 10, 1, 2, 0, -1, 2012, 10, 1, 1, 59],
|
270
|
-
[2012, 10, 2, 3, 0, -61, 2012, 10, 1, 1, 59],
|
271
|
-
[2012, 9, 24, 1, 1, -2, 2012, 9, 23, 23, 59],
|
272
|
-
[2012, 10, 1, 1, 59, 61, 2012, 10, 2, 3, 0],
|
273
|
-
[2012, 10, 1, 1, 1, -1, 2012, 10, 1, 1, 0],
|
274
|
-
[2012, 10, 1, 1, 0, -1, 2012, 9, 30, 23, 59]]
|
275
|
-
clue = 'calculate across week patterns'
|
276
|
-
calc_test(wp, tests, clue)
|
277
|
-
end
|
278
|
-
|
279
|
-
def test_must_know_whether_a_time_is_working_or_resting
|
280
|
-
name = 'working?'
|
281
|
-
base = 2011
|
282
|
-
span = 11
|
283
|
-
wp = Workpattern.new(name, base, span)
|
284
|
-
wp.resting(to_time: Workpattern.clock(8, 59))
|
285
|
-
assert wp.working?(Time.gm(2012, 1, 1, 9, 0))
|
286
|
-
assert !wp.working?(Time.gm(2012, 1, 1, 8, 59))
|
287
|
-
end
|
288
|
-
|
289
|
-
private
|
290
|
-
|
291
|
-
def get_week(ss)
|
292
|
-
ss.each { |obj| return obj }
|
293
|
-
end
|
294
|
-
|
295
|
-
def calc_test(wp, tests, clue)
|
296
|
-
tests.each do |y, m, d, h, n, add, yr, mr, dr, hr, nr|
|
297
|
-
start_date = Time.gm(y, m, d, h, n)
|
298
|
-
result_date = wp.calc(start_date, add)
|
299
|
-
assert_equal Time.gm(yr, mr, dr, hr, nr), result_date,
|
300
|
-
"result date calc(#{start_date}, #{add}) for #{clue}"
|
301
|
-
end
|
302
|
-
end
|
303
|
-
|
304
|
-
def clock(hour, min)
|
305
|
-
Workpattern.clock(hour, min)
|
306
|
-
end
|
307
|
-
end
|
@@ -1,88 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
-
|
3
|
-
class TestWorkpatternModule < MiniTest::Test #:nodoc:
|
4
|
-
def setup
|
5
|
-
Workpattern.clear
|
6
|
-
end
|
7
|
-
|
8
|
-
def test_must_create_workpattern_with_defaults
|
9
|
-
wp = Workpattern.new
|
10
|
-
assert_equal Workpattern::DEFAULT_WORKPATTERN_NAME, wp.name,
|
11
|
-
'not returned the default workpattern name'
|
12
|
-
assert_equal Workpattern::DEFAULT_BASE_YEAR, wp.from.year,
|
13
|
-
'not returned the default workpattern base year'
|
14
|
-
assert_equal Workpattern::DEFAULT_SPAN, wp.span,
|
15
|
-
'not returned the default workpattern span'
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_must_create_workpattern_with_given_parameters
|
19
|
-
mywp_name = 'barrie callender'
|
20
|
-
mywp_base = 1963
|
21
|
-
mywp_span = 48
|
22
|
-
mywp = Workpattern.new(mywp_name, mywp_base, mywp_span)
|
23
|
-
assert_equal mywp_name, mywp.name,
|
24
|
-
'not returned the supplied workpattern name'
|
25
|
-
assert_equal mywp_base, mywp.from.year,
|
26
|
-
'not returned the supplied workpattern base year'
|
27
|
-
assert_equal mywp_span, mywp.span,
|
28
|
-
'not returned the supplied workpattern span'
|
29
|
-
end
|
30
|
-
|
31
|
-
def test_must_raise_error_when_creating_workpattern_with_existing_name
|
32
|
-
assert_raises NameError do
|
33
|
-
mywp_name = 'duplicate'
|
34
|
-
Workpattern.new(mywp_name)
|
35
|
-
Workpattern.new(mywp_name)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
def test_must_return_an_array_of_all_known_workpattern_objects
|
40
|
-
names = %w(fred harry sally)
|
41
|
-
names.each { |name| Workpattern.new(name) }
|
42
|
-
wp_names = Workpattern.to_a
|
43
|
-
|
44
|
-
assert_equal names.size, wp_names.size, 'lists are not the same size'
|
45
|
-
|
46
|
-
wp_names.each { |name, _wp| assert names.include?(name) }
|
47
|
-
end
|
48
|
-
|
49
|
-
def test_must_return_empty_array_when_no_workpatterns_exist
|
50
|
-
assert Workpattern.to_a.empty?
|
51
|
-
end
|
52
|
-
|
53
|
-
def test_must_return_existing_workpattern
|
54
|
-
names = %w(fred harry sally)
|
55
|
-
names.each { |name| Workpattern.new(name) }
|
56
|
-
|
57
|
-
names.each do |name|
|
58
|
-
Workpattern.get(name)
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
def test_must_raise_error_when_workpattern_does_not_exist
|
63
|
-
names = %w(fred harry sally)
|
64
|
-
names.each { |name| Workpattern.new(name) }
|
65
|
-
assert_raises NameError do
|
66
|
-
Workpattern.get('missing')
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
def test_must_delete_existing_workpattern_returning_true
|
71
|
-
names = %w(fred harry sally)
|
72
|
-
names.each { |name| Workpattern.new(name) }
|
73
|
-
names.each { |name| assert Workpattern.delete(name) }
|
74
|
-
end
|
75
|
-
|
76
|
-
def test_must_return_false_deleting_workpattern_that_does_not_exist
|
77
|
-
names = %w(fred harry sally)
|
78
|
-
names.each { |name| Workpattern.new(name) }
|
79
|
-
assert !Workpattern.delete('missing')
|
80
|
-
end
|
81
|
-
|
82
|
-
def test_must_delete_all_workpatterns
|
83
|
-
names = %w(fred harry sally)
|
84
|
-
names.each { |name| Workpattern.new(name) }
|
85
|
-
Workpattern.clear
|
86
|
-
assert Workpattern.to_a.empty?
|
87
|
-
end
|
88
|
-
end
|