oktest 1.4.0 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,24 +2,24 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  ###
5
- ### $Release: 1.4.0 $
5
+ ### $Release: 1.5.0 $
6
6
  ### $Copyright: copyright(c) 2011-2024 kuwata-lab.com all rights reserved $
7
7
  ### $License: MIT License $
8
8
  ###
9
9
 
10
- require_relative './initialize'
10
+ require_relative './init'
11
11
 
12
12
 
13
- class AssertionObject_TC < TC
14
- #include Test::Unit::Assertions
15
- include Oktest::SpecHelper
13
+ class AssertionObject__Test
14
+ extend NanoTest
15
+ extend Oktest::SpecHelper
16
16
 
17
- def FAIL!(errmsg, &b)
17
+ def self.FAIL!(errmsg, &b)
18
18
  failmsg = "expected to be failed, but succeeded unexpectedly."
19
19
  return ERROR!(Oktest::FAIL_EXCEPTION, errmsg, failmsg, &b)
20
20
  end
21
21
 
22
- def ERROR!(errcls, errmsg=nil, _failmsg=nil, &b)
22
+ def self.ERROR!(errcls, errmsg=nil, _failmsg=nil, &b)
23
23
  exc = nil
24
24
  begin
25
25
  yield
@@ -29,92 +29,92 @@ class AssertionObject_TC < TC
29
29
  raise
30
30
  else
31
31
  _failmsg ||= "#{errcls} expected to be raised, but nothing raised."
32
- assert false, _failmsg
32
+ test_ok? false, _failmsg
33
33
  end
34
34
  #
35
35
  if errmsg
36
- assert errmsg === exc.message,
37
- ("unexpected error message:\n"\
38
- " expected: #{errmsg}\n"\
39
- " actual: #{exc.message}")
36
+ test_ok? errmsg === exc.message,
37
+ msg: ("unexpected error message:\n"\
38
+ " expected: #{errmsg}\n"\
39
+ " actual: #{exc.message}")
40
40
  end
41
41
  #
42
42
  return exc
43
43
  end
44
44
 
45
- def PASS!()
45
+ def self.PASS!(&b)
46
46
  yield
47
47
  end
48
48
 
49
- def should_return_self
49
+ def self.should_return_self(&b)
50
50
  obj = yield
51
- assert obj.class == Oktest::AssertionObject
51
+ test_ok? obj.class == Oktest::AssertionObject
52
52
  end
53
53
 
54
54
 
55
- describe '.report_not_yet()' do
56
- it "[!3nksf] reports if 'ok{}' called but assertion not performed." do
57
- assert Oktest::AssertionObject::NOT_YET.empty?, "should be empty"
58
- sout, serr = capture do
55
+ test_target 'Oktest::AssertionObject.report_not_yet()' do
56
+ test_subject "[!3nksf] reports if 'ok{}' called but assertion not performed." do
57
+ test_ok? Oktest::AssertionObject::NOT_YET.empty?, msg: "should be empty"
58
+ sout, serr = capture_output! do
59
59
  Oktest::AssertionObject.report_not_yet()
60
60
  end
61
- assert_eq sout, ""
62
- assert_eq serr, ""
61
+ test_eq? sout, ""
62
+ test_eq? serr, ""
63
63
  #
64
64
  lineno = __LINE__ + 1
65
65
  ok {1+1}
66
- assert ! Oktest::AssertionObject::NOT_YET.empty?, "should not be empty"
67
- sout, serr = capture { Oktest::AssertionObject.report_not_yet() }
66
+ test_ok? ! Oktest::AssertionObject::NOT_YET.empty?, msg: "should not be empty"
67
+ sout, serr = capture_output! { Oktest::AssertionObject.report_not_yet() }
68
68
  expected = "** warning: ok() is called but not tested yet (at #{__FILE__}:#{lineno}:in"
69
- assert_eq sout, ""
70
- assert serr.start_with?(expected), "not matched"
69
+ test_eq? sout, ""
70
+ test_ok? serr.start_with?(expected), msg: "not matched"
71
71
  end
72
- it "[!f92q4] clears remained objects." do
72
+ test_subject "[!f92q4] clears remained objects." do
73
73
  ok {1+1}
74
- assert ! Oktest::AssertionObject::NOT_YET.empty?, "should not be empty"
75
- sout, serr = capture { Oktest::AssertionObject.report_not_yet() }
76
- assert Oktest::AssertionObject::NOT_YET.empty?, "should be empty"
74
+ test_ok? ! Oktest::AssertionObject::NOT_YET.empty?, msg: "should not be empty"
75
+ sout, serr = capture_output! { Oktest::AssertionObject.report_not_yet() }
76
+ test_ok? Oktest::AssertionObject::NOT_YET.empty?, msg: "should be empty"
77
77
  end
78
78
  end
79
79
 
80
- describe '.NOT()' do
81
- it "[!g775v] returns self." do
80
+ test_target 'Oktest::AssertionObject.NOT()' do
81
+ test_subject "[!g775v] returns self." do
82
82
  begin
83
83
  should_return_self { ok {1+1}.NOT }
84
84
  ensure
85
85
  Oktest::AssertionObject::NOT_YET.clear()
86
86
  end
87
87
  end
88
- it "[!63dde] toggles internal boolean." do
88
+ test_subject "[!63dde] toggles internal boolean." do
89
89
  begin
90
90
  x = ok {1+1}
91
- assert_eq x.bool, true
91
+ test_eq? x.bool, true
92
92
  x.NOT
93
- assert_eq x.bool, false
93
+ test_eq? x.bool, false
94
94
  ensure
95
95
  Oktest::AssertionObject::NOT_YET.clear()
96
96
  end
97
97
  end
98
98
  end
99
99
 
100
- describe '#==' do
101
- it "[!c6p0e] returns self when passed." do
100
+ test_target 'Oktest::AssertionObject#==' do
101
+ test_subject "[!c6p0e] returns self when passed." do
102
102
  should_return_self { ok {1+1} == 2 }
103
103
  end
104
- it "[!1iun4] raises assertion error when failed." do
104
+ test_subject "[!1iun4] raises assertion error when failed." do
105
105
  errmsg = "$<actual> == $<expected>: failed.\n"\
106
106
  " $<actual>: 2\n"\
107
107
  " $<expected>: 3"
108
108
  FAIL!(errmsg) { ok {1+1} == 3 }
109
109
  end
110
- it "[!eyslp] is avaialbe with NOT." do
110
+ test_subject "[!eyslp] is avaialbe with NOT." do
111
111
  PASS! { ok {1+1}.NOT == 3 }
112
112
  errmsg = "$<actual> != $<expected>: failed.\n"\
113
113
  " $<actual>: 2\n"\
114
114
  " $<expected>: 2"
115
115
  FAIL!(errmsg) { ok {1+1}.NOT == 2 }
116
116
  end
117
- it "[!3xnqv] shows context diff when both actual and expected are text." do
117
+ test_subject "[!3xnqv] shows context diff when both actual and expected are text." do
118
118
  expected = "Haruhi\nMikuru\nYuki\n"
119
119
  actual = "Haruhi\nMichiru\nYuki\n"
120
120
  errmsg = <<'END'
@@ -133,18 +133,18 @@ END
133
133
  end
134
134
  end
135
135
 
136
- describe '#!=' do
137
- it "[!iakbb] returns self when passed." do
136
+ test_target 'Oktest::AssertionObject#!=' do
137
+ test_subject "[!iakbb] returns self when passed." do
138
138
  should_return_self { ok {1+1} != 3 }
139
139
  end
140
- it "[!90tfb] raises assertion error when failed." do
140
+ test_subject "[!90tfb] raises assertion error when failed." do
141
141
  #errmsg = "<2> expected to be != to\n<2>."
142
142
  errmsg = "$<actual> != $<expected>: failed.\n"\
143
143
  " $<actual>: 2\n"\
144
144
  " $<expected>: 2"
145
145
  FAIL!(errmsg) { ok {1+1} != 2 }
146
146
  end
147
- it "[!l6afg] is avaialbe with NOT." do
147
+ test_subject "[!l6afg] is avaialbe with NOT." do
148
148
  PASS! { ok {1+1}.NOT != 2 }
149
149
  #errmsg = "<3> expected but was\n<2>."
150
150
  errmsg = "$<actual> == $<expected>: failed.\n"\
@@ -154,39 +154,41 @@ END
154
154
  end
155
155
  end #if RUBY_VERSION >= "1.9"
156
156
 
157
- describe '#===' do
158
- it "[!uh8bm] returns self when passed." do
157
+ test_target 'Oktest::AssertionObject#===' do
158
+ test_subject "[!uh8bm] returns self when passed." do
159
159
  should_return_self { ok {String} === 'str' }
160
160
  end
161
- it "[!42f6a] raises assertion error when failed." do
161
+ test_subject "[!42f6a] raises assertion error when failed." do
162
162
  errmsg = "$<actual> === $<expected>: failed.\n"\
163
163
  " $<actual>: Integer\n"\
164
164
  " $<expected>: \"str\""
165
165
  FAIL!(errmsg) { ok {Integer} === 'str' }
166
166
  end
167
- it "[!vhvyu] is avaialbe with NOT." do
167
+ test_subject "[!vhvyu] is avaialbe with NOT." do
168
168
  PASS! { ok {Integer}.NOT === 'str' }
169
169
  errmsg = "!($<actual> === $<expected>): failed.\n"\
170
170
  " $<actual>: String\n"\
171
171
  " $<expected>: \"str\""
172
172
  FAIL!(errmsg) { ok {String}.NOT === 'str' }
173
173
  end
174
- it "[!mjh4d] raises error when combination of 'not_ok()' and matcher object." do
174
+ test_subject "[!mjh4d] raises error when combination of 'not_ok()' and matcher object." do
175
175
  errmsg = "negative `===` is not available with matcher object."
176
- assert_exc(Oktest::OktestError, errmsg) do
176
+ exc = test_exception? Oktest::OktestError do
177
177
  not_ok {Oktest::JsonMatcher.new({})} === {}
178
178
  end
179
- assert_exc(Oktest::OktestError, errmsg) do
179
+ test_eq? errmsg, exc.message
180
+ exc = test_exception? Oktest::OktestError do
180
181
  ok {Oktest::JsonMatcher.new({})}.NOT === {}
181
182
  end
183
+ test_eq? errmsg, exc.message
182
184
  end
183
185
  end
184
186
 
185
- describe '>' do
186
- it "[!3j7ty] returns self when passed." do
187
+ test_target 'Oktest::AssertionObject>' do
188
+ test_subject "[!3j7ty] returns self when passed." do
187
189
  should_return_self { ok {2} > 1 }
188
190
  end
189
- it "[!vjjuq] raises assertion error when failed." do
191
+ test_subject "[!vjjuq] raises assertion error when failed." do
190
192
  #errmsg = "Expected 2 to be > 2."
191
193
  errmsg = "2 > 2: failed."
192
194
  FAIL!(errmsg) { ok {2} > 2 }
@@ -196,7 +198,7 @@ END
196
198
  errmsg = "\"aaa\" > \"bbb\": failed."
197
199
  FAIL!(errmsg) { ok {'aaa'} > 'bbb' }
198
200
  end
199
- it "[!73a0t] is avaialbe with NOT." do
201
+ test_subject "[!73a0t] is avaialbe with NOT." do
200
202
  PASS! { ok {2}.NOT > 2 }
201
203
  #errmsg = "Expected 2 to be <= 1."
202
204
  errmsg = "2 <= 1: failed."
@@ -204,12 +206,12 @@ END
204
206
  end
205
207
  end
206
208
 
207
- describe '>=' do
208
- it "[!75iqw] returns self when passed." do
209
+ test_target 'Oktest::AssertionObject>=' do
210
+ test_subject "[!75iqw] returns self when passed." do
209
211
  should_return_self { ok {2} >= 2 }
210
212
  should_return_self { ok {2} >= 1 }
211
213
  end
212
- it "[!isdfc] raises assertion error when failed." do
214
+ test_subject "[!isdfc] raises assertion error when failed." do
213
215
  #errmsg = "Expected 1 to be >= 2."
214
216
  errmsg = "1 >= 2: failed."
215
217
  FAIL!(errmsg) { ok {1} >= 2 }
@@ -217,7 +219,7 @@ END
217
219
  errmsg = "\"aaa\" >= \"bbb\": failed."
218
220
  FAIL!(errmsg) { ok {'aaa'} >= 'bbb' }
219
221
  end
220
- it "[!3dgmh] is avaialbe with NOT." do
222
+ test_subject "[!3dgmh] is avaialbe with NOT." do
221
223
  PASS! { ok {1}.NOT >= 2 }
222
224
  #errmsg = "Expected 2 to be < 2."
223
225
  errmsg = "2 < 2: failed."
@@ -225,11 +227,11 @@ END
225
227
  end
226
228
  end
227
229
 
228
- describe '<' do
229
- it "[!vkwcc] returns self when passed." do
230
+ test_target 'Oktest::AssertionObject<' do
231
+ test_subject "[!vkwcc] returns self when passed." do
230
232
  should_return_self { ok {1} < 2 }
231
233
  end
232
- it "[!ukqa0] raises assertion error when failed." do
234
+ test_subject "[!ukqa0] raises assertion error when failed." do
233
235
  #errmsg = "Expected 2 to be < 2."
234
236
  errmsg = "2 < 2: failed."
235
237
  FAIL!(errmsg) { ok {2} < 2 }
@@ -239,7 +241,7 @@ END
239
241
  errmsg = "\"bbb\" < \"aaa\": failed."
240
242
  FAIL!(errmsg) { ok {'bbb'} < 'aaa' }
241
243
  end
242
- it "[!gwvdl] is avaialbe with NOT." do
244
+ test_subject "[!gwvdl] is avaialbe with NOT." do
243
245
  PASS! { ok {2}.NOT < 2 }
244
246
  #errmsg = "Expected 1 to be >= 2."
245
247
  errmsg = "1 >= 2: failed."
@@ -247,12 +249,12 @@ END
247
249
  end
248
250
  end
249
251
 
250
- describe '<=' do
251
- it "[!yk7t2] returns self when passed." do
252
+ test_target 'Oktest::AssertionObject<=' do
253
+ test_subject "[!yk7t2] returns self when passed." do
252
254
  should_return_self { ok {1} <= 2 }
253
255
  should_return_self { ok {1} <= 1 }
254
256
  end
255
- it "[!ordwe] raises assertion error when failed." do
257
+ test_subject "[!ordwe] raises assertion error when failed." do
256
258
  #errmsg = "Expected 2 to be <= 1."
257
259
  errmsg = "2 <= 1: failed."
258
260
  FAIL!(errmsg) { ok {2} <= 1 }
@@ -260,7 +262,7 @@ END
260
262
  errmsg = "\"bbb\" <= \"aaa\": failed."
261
263
  FAIL!(errmsg) { ok {'bbb'} <= 'aaa' }
262
264
  end
263
- it "[!mcb9w] is avaialbe with NOT." do
265
+ test_subject "[!mcb9w] is avaialbe with NOT." do
264
266
  PASS! { ok {2}.NOT <= 1 }
265
267
  #errmsg = "Expected 1 to be > 2."
266
268
  errmsg = "1 > 2: failed."
@@ -268,11 +270,11 @@ END
268
270
  end
269
271
  end
270
272
 
271
- describe '=~' do
272
- it "[!acypf] returns self when passed." do
273
+ test_target 'Oktest::AssertionObject=~' do
274
+ test_subject "[!acypf] returns self when passed." do
273
275
  should_return_self { ok {'SOS'} =~ /^[A-Z]+$/ }
274
276
  end
275
- it "[!xkldu] raises assertion error when failed." do
277
+ test_subject "[!xkldu] raises assertion error when failed." do
276
278
  #errmsg = 'Expected /^\\d+$/ to match "SOS".'
277
279
  errmsg = "$<actual> =~ $<expected>: failed.\n"\
278
280
  " $<expected>: /^\\d+$/\n"\
@@ -281,7 +283,7 @@ END
281
283
  "END\n"
282
284
  FAIL!(errmsg) { ok {"SOS\n"} =~ /^\d+$/ }
283
285
  end
284
- it "[!2aa6f] is avaialbe with NOT." do
286
+ test_subject "[!2aa6f] is avaialbe with NOT." do
285
287
  PASS! { ok {'SOS'}.NOT =~ /^\d+$/ }
286
288
  #errmsg = "</\\w+/> expected to not match\n<\"SOS\">."
287
289
  errmsg = "$<actual> !~ $<expected>: failed.\n"\
@@ -291,18 +293,18 @@ END
291
293
  end if false
292
294
  end
293
295
 
294
- describe '!~' do
295
- it "[!xywdr] returns self when passed." do
296
+ test_target 'Oktest::AssertionObject!~' do
297
+ test_subject "[!xywdr] returns self when passed." do
296
298
  should_return_self { ok {'SOS'} !~ /^\d+$/ }
297
299
  end
298
- it "[!58udu] raises assertion error when failed." do
300
+ test_subject "[!58udu] raises assertion error when failed." do
299
301
  #errmsg = "</^\\w+$/> expected to not match\n<\"SOS\">."
300
302
  errmsg = "$<actual> !~ $<expected>: failed.\n"\
301
303
  " $<expected>: /^\\w+$/\n"\
302
304
  " $<actual>: \"SOS\"\n"
303
305
  FAIL!(errmsg) { ok {'SOS'} !~ /^\w+$/ }
304
306
  end
305
- it "[!iuf5j] is avaialbe with NOT." do
307
+ test_subject "[!iuf5j] is avaialbe with NOT." do
306
308
  PASS! { ok {'SOS'}.NOT !~ /^\w+$/ }
307
309
  #errmsg = "Expected /\\d+/ to match \"SOS\"."
308
310
  errmsg = "$<actual> =~ $<expected>: failed.\n"\
@@ -312,18 +314,18 @@ END
312
314
  end
313
315
  end #if RUBY_VERSION >= "1.9"
314
316
 
315
- describe '#in_delta?' do
316
- it "[!m0791] returns self when passed." do
317
+ test_target 'Oktest::AssertionObject#in_delta?' do
318
+ test_subject "[!m0791] returns self when passed." do
317
319
  should_return_self { ok {3.14159}.in_delta?(3.141, 0.001) }
318
320
  end
319
- it "[!f3zui] raises assertion error when failed." do
321
+ test_subject "[!f3zui] raises assertion error when failed." do
320
322
  errmsg = "($<actual> - $<expected>).abs < #{0.1}: failed.\n"\
321
323
  " $<actual>: 1.375\n"\
322
324
  " $<expected>: 1.5\n"\
323
325
  " ($<actual> - $<expected>).abs: #{0.125}"
324
326
  FAIL!(errmsg) { ok {1.375}.in_delta?(1.5, 0.1) }
325
327
  end
326
- it "[!t7liw] is avaialbe with NOT." do
328
+ test_subject "[!t7liw] is avaialbe with NOT." do
327
329
  PASS! { ok {1.375}.NOT.in_delta?(1.5, 0.1) }
328
330
  errmsg = "($<actual> - $<expected>).abs < #{0.2} == false: failed.\n"\
329
331
  " $<actual>: 1.375\n"\
@@ -333,17 +335,17 @@ END
333
335
  end
334
336
  end
335
337
 
336
- describe '#same?' do
337
- it "[!yk7zo] returns self when passed." do
338
+ test_target 'Oktest::AssertionObject#same?' do
339
+ test_subject "[!yk7zo] returns self when passed." do
338
340
  should_return_self { ok {:SOS}.same?(:SOS) }
339
341
  end
340
- it "[!ozbf4] raises assertion error when failed." do
342
+ test_subject "[!ozbf4] raises assertion error when failed." do
341
343
  errmsg = "$<actual>.equal?($<expected>): failed.\n"\
342
344
  " $<actual>: \"SOS\"\n"\
343
345
  " $<expected>: \"SOS\"\n"
344
346
  FAIL!(errmsg) { ok {'SOS'.dup}.same?('SOS') }
345
347
  end
346
- it "[!dwtig] is avaialbe with NOT." do
348
+ test_subject "[!dwtig] is avaialbe with NOT." do
347
349
  PASS! { ok {'SOS'.dup}.NOT.same? 'SOS' }
348
350
  errmsg = "$<actual>.equal?($<expected>) == false: failed.\n"\
349
351
  " $<actual>: :SOS\n"\
@@ -352,21 +354,21 @@ END
352
354
  end
353
355
  end
354
356
 
355
- describe '#method_missing()' do
356
- it "[!7bbrv] returns self when passed." do
357
+ test_target 'Oktest::AssertionObject#method_missing()' do
358
+ test_subject "[!7bbrv] returns self when passed." do
357
359
  should_return_self { ok {"file.png"}.end_with?(".png") }
358
360
  end
359
- it "[!yjnxb] enables to handle boolean methods." do
361
+ test_subject "[!yjnxb] enables to handle boolean methods." do
360
362
  PASS! { ok {""}.empty? }
361
363
  PASS! { ok {nil}.nil? }
362
364
  PASS! { ok {1}.is_a?(Integer) }
363
365
  end
364
- it "[!ttow6] raises NoMethodError when not a boolean method." do
366
+ test_subject "[!ttow6] raises NoMethodError when not a boolean method." do
365
367
  ERROR!(NoMethodError) do
366
368
  ok {"a"}.start_with
367
369
  end
368
370
  end
369
- it "[!gd3vg] supports keyword arguments on Ruby >= 2.7." do
371
+ test_subject "[!gd3vg] supports keyword arguments on Ruby >= 2.7." do
370
372
  #if RUBY_VERSION >= "2.7"
371
373
  if true
372
374
  eval <<-END
@@ -387,14 +389,14 @@ END
387
389
  end
388
390
  end
389
391
  end
390
- it "[!f0ekh] skip top of backtrace when NoMethodError raised." do
392
+ test_subject "[!f0ekh] skip top of backtrace when NoMethodError raised." do
391
393
  exc = ERROR!(NoMethodError) do
392
394
  ok {[1]}.start_with?(1)
393
395
  end
394
- assert exc.backtrace[0] !~ /\/oktest\.rbc?:/, "backtrace not skipped"
395
- assert exc.backtrace[0].start_with?(__FILE__), "backtrace not skipped"
396
+ test_ok? exc.backtrace[0] !~ /\/oktest\.rbc?:/, msg: "backtrace not skipped"
397
+ test_ok? exc.backtrace[0].start_with?(__FILE__), msg: "backtrace not skipped"
396
398
  end
397
- it "[!cun59] fails when boolean method failed returned false." do
399
+ test_subject "[!cun59] fails when boolean method failed returned false." do
398
400
  errmsg = "$<actual>.empty?: failed.\n $<actual>: \"SOS\""
399
401
  FAIL!(errmsg) { ok {"SOS"}.empty? }
400
402
  errmsg = "$<actual>.nil?: failed.\n $<actual>: \"\""
@@ -402,7 +404,7 @@ END
402
404
  errmsg = "$<actual>.is_a?(Integer): failed.\n $<actual>: 3.14"
403
405
  FAIL!(errmsg) { ok {3.14}.is_a?(Integer) }
404
406
  end
405
- it "[!4objh] is available with NOT." do
407
+ test_subject "[!4objh] is available with NOT." do
406
408
  ok {"SOS"}.NOT.empty?
407
409
  ok {"SOS"}.NOT.nil?
408
410
  ok {"SOS"}.NOT.is_a?(Integer)
@@ -413,7 +415,7 @@ END
413
415
  errmsg = "$<actual>.is_a?(Integer) == false: failed.\n $<actual>: 1"
414
416
  FAIL!(errmsg) { ok {1}.NOT.is_a?(Integer) }
415
417
  end
416
- it "[!sljta] raises TypeError when boolean method returned non-boolean value." do
418
+ test_subject "[!sljta] raises TypeError when boolean method returned non-boolean value." do
417
419
  errmsg = "ok(): String#sos?() expected to return true or false, but got 1."
418
420
  ERROR!(TypeError, errmsg) do
419
421
  s = "SOS".dup
@@ -421,7 +423,7 @@ END
421
423
  ok {s}.sos?
422
424
  end
423
425
  end
424
- it "[!5y9iu] reports args and kwargs in error message." do
426
+ test_subject "[!5y9iu] reports args and kwargs in error message." do
425
427
  if RUBY_VERSION >= "2.7"
426
428
  str = '123, "abc", x: "45", y: true'
427
429
  else
@@ -440,12 +442,12 @@ END
440
442
  actual = obj.instance_eval {
441
443
  __inspect_args_and_kwargs([123, "abc"], c: "45", d: true)
442
444
  }
443
- assert_eq actual, expected
445
+ test_eq? actual, expected
444
446
  end
445
447
  end
446
448
 
447
- describe '#raise?' do
448
- it "[!y1b28] returns exception object." do
449
+ test_target 'Oktest::AssertionObject#raise?' do
450
+ test_subject "[!y1b28] returns exception object." do
449
451
  pr = proc { "SOS".sos }
450
452
  if RUBY_VERSION >= "3.3"
451
453
  expected = "undefined method `sos' for an instance of String"
@@ -458,10 +460,10 @@ END
458
460
  expected = "undefined method `sos' for \"SOS\":String"
459
461
  end
460
462
  ret = ok {pr}.raise?(NoMethodError, expected)
461
- assert_eq ret.class, NoMethodError
462
- assert_eq ret.message, expected
463
+ test_eq? ret.class, NoMethodError
464
+ test_eq? ret.message, expected
463
465
  end
464
- it "[!2rnni] 1st argument can be error message string or rexp." do
466
+ test_subject "[!2rnni] 1st argument can be error message string or rexp." do
465
467
  pr = proc { raise "something wrong" }
466
468
  PASS! { ok {pr}.raise?("something wrong") }
467
469
  PASS! { ok {pr}.raise?(/something wrong/) }
@@ -469,31 +471,31 @@ END
469
471
  pr = proc { raise StandardError, "something wrong" }
470
472
  ERROR!(StandardError, "something wrong") { ok {pr}.raise?("something wrong") }
471
473
  end
472
- describe '[!dpv5g] when `ok{}` called...' do
473
- it "[!yps62] assertion passes when expected exception raised." do
474
+ test_target 'Oktest::AssertionObject[!dpv5g] when `ok{}` called...' do
475
+ test_subject "[!yps62] assertion passes when expected exception raised." do
474
476
  pr = proc { "SOS".sub() }
475
477
  PASS! { ok {pr}.raise?(ArgumentError) }
476
478
  pr = proc { 1/0 }
477
479
  PASS! { ok {pr}.raise?(ZeroDivisionError) }
478
480
  end
479
- it "[!wbwdo] raises assertion error when nothing raised." do
481
+ test_subject "[!wbwdo] raises assertion error when nothing raised." do
480
482
  pr = proc { nil }
481
483
  errmsg = "Expected ArgumentError to be raised but nothing raised."
482
484
  FAIL!(errmsg) { ok {pr}.raise?(ArgumentError) }
483
485
  end
484
- it "[!lq6jv] compares error class with '==' operator, not '.is_a?'." do
486
+ test_subject "[!lq6jv] compares error class with '==' operator, not '.is_a?'." do
485
487
  pr = proc { "SOS".foobar }
486
488
  PASS! { ok {pr}.raise?(NoMethodError) }
487
- assert NoMethodError < NameError, "NoMethodError extends NameError"
489
+ test_ok? NoMethodError < NameError, msg: "NoMethodError extends NameError"
488
490
  ERROR!(NoMethodError, /foobar/) { ok {pr}.raise?(NameError) }
489
491
  end
490
- it "[!hwg0z] compares error class with '.is_a?' if '_subclass: true' specified." do
492
+ test_subject "[!hwg0z] compares error class with '.is_a?' if '_subclass: true' specified." do
491
493
  pr = proc { "SOS".foobar }
492
494
  PASS! { ok {pr}.raise?(NoMethodError, nil) }
493
- assert NoMethodError < NameError, "NoMethodError extends NameError"
495
+ test_ok? NoMethodError < NameError, msg: "NoMethodError extends NameError"
494
496
  PASS! { ok {pr}.raise?(NameError, nil, _subclass: true) }
495
497
  end
496
- it "[!4n3ed] reraises if exception is not matched to specified error class." do
498
+ test_subject "[!4n3ed] reraises if exception is not matched to specified error class." do
497
499
  pr = proc { "SOS".sos }
498
500
  if RUBY_VERSION >= "3.3"
499
501
  errmsg = "undefined method `sos' for an instance of String"
@@ -507,7 +509,7 @@ END
507
509
  end
508
510
  ERROR!(NoMethodError, errmsg) { ok {pr}.raise?(ArgumentError) }
509
511
  end
510
- it "[!tpxlv] accepts string or regexp as error message." do
512
+ test_subject "[!tpxlv] accepts string or regexp as error message." do
511
513
  if RUBY_VERSION >= "3.1"
512
514
  expected = "undefined method `sos' for \"SOS\":String\n"\
513
515
  "\n"\
@@ -526,7 +528,7 @@ END
526
528
  end
527
529
  PASS! { ok {pr}.raise?(NoMethodError, expected) }
528
530
  end
529
- it "[!4c6x3] not check exception class when nil specified as errcls." do
531
+ test_subject "[!4c6x3] not check exception class when nil specified as errcls." do
530
532
  pr = proc { foobar() }
531
533
  PASS! { ok {pr}.raise?(nil, /undefined method `foobar'/) }
532
534
  pr = proc { 1/0 }
@@ -534,31 +536,31 @@ END
534
536
  pr = proc { 1/0 }
535
537
  PASS! { ok {pr}.raise?(nil) }
536
538
  end
537
- it "[!dq97o] if block given, call it with exception object." do
539
+ test_subject "[!dq97o] if block given, call test_subject with exception object." do
538
540
  pr = proc { "SOS".foobar }
539
541
  exc1 = nil
540
542
  ok {pr}.raise?(NoMethodError) do |exc2|
541
543
  exc1 = exc2
542
544
  end
543
- assert exc1 != nil
544
- assert exc1.equal?(pr.exc)
545
+ test_ok? exc1 != nil
546
+ test_ok? exc1.equal?(pr.exc)
545
547
  end
546
548
  end
547
- describe '[!qkr3h] when `ok{}.NOT` called...' do
548
- it "[!cownv] not support error message." do
549
+ test_target 'Oktest::AssertionObject[!qkr3h] when `ok{}.NOT` called...' do
550
+ test_subject "[!cownv] not support error message." do
549
551
  pr = proc { raise "some error" }
550
552
  errmsg = "\"some error\": NOT.raise?() can't take errmsg."
551
553
  ERROR!(ArgumentError, errmsg) { ok {pr}.NOT.raise?(Exception, "some error") }
552
554
  end
553
- it "[!spzy2] is available with NOT." do
555
+ test_subject "[!spzy2] is available with NOT." do
554
556
  pr = proc { "SOS".length }
555
557
  PASS! { ok {pr}.NOT.raise? }
556
558
  end
557
- it "[!a1a40] assertion passes when nothing raised." do
559
+ test_subject "[!a1a40] assertion passes when nothing raised." do
558
560
  pr = proc { nil }
559
561
  PASS! { ok {pr}.NOT.raise? }
560
562
  end
561
- it "[!61vtv] assertion fails when specified exception raised." do
563
+ test_subject "[!61vtv] assertion fails when specified exception raised." do
562
564
  pr = proc { "SOS".foobar }
563
565
  if RUBY_VERSION >= "3.3"
564
566
  errmsg = "NoMethodError should not be raised but got #<NoMethodError: undefined method `foobar' for an instance of String>."
@@ -572,36 +574,36 @@ END
572
574
  end
573
575
  FAIL!(errmsg) { ok {pr}.NOT.raise?(NoMethodError) }
574
576
  end
575
- it "[!smprc] compares error class with '==' operator, not '.is_a?'." do
577
+ test_subject "[!smprc] compares error class with '==' operator, not '.is_a?'." do
576
578
  pr = proc { "SOS".foobar }
577
579
  FAIL!(/foobar/) { ok {pr}.NOT.raise?(NoMethodError) }
578
- assert NoMethodError < NameError, "NoMethodError extends NameError"
580
+ test_ok? NoMethodError < NameError, msg: "NoMethodError extends NameError"
579
581
  ERROR!(NoMethodError) { ok {pr}.NOT.raise?(NameError) }
580
582
  end
581
- it "[!34nd8] compares error class with '.is_a?' if '_subclass: true' specified." do
583
+ test_subject "[!34nd8] compares error class with '.is_a?' if '_subclass: true' specified." do
582
584
  pr = proc { "SOS".foobar }
583
585
  FAIL!(/foobar/) { ok {pr}.NOT.raise?(NoMethodError, nil) }
584
- assert NoMethodError < NameError, "NoMethodError extends NameError"
586
+ test_ok? NoMethodError < NameError, msg: "NoMethodError extends NameError"
585
587
  FAIL!(/foobar/) { ok {pr}.NOT.raise?(NameError, nil, _subclass: true) }
586
588
  end
587
- it "[!shxne] reraises exception if different from specified error class." do
589
+ test_subject "[!shxne] reraises exception if different from specified error class." do
588
590
  pr = proc { 1/0 }
589
591
  errmsg = "divided by 0"
590
592
  ERROR!(ZeroDivisionError, errmsg) { ok {pr}.NOT.raise?(NoMethodError) }
591
593
  end
592
- it "[!36032] re-raises exception when errcls is nil." do
594
+ test_subject "[!36032] re-raises exception when errcls is nil." do
593
595
  pr = proc { foobar() }
594
596
  ERROR!(NoMethodError) { ok {pr}.NOT.raise?(nil) }
595
597
  pr = proc { 1/0 }
596
598
  ERROR!(ZeroDivisionError) { ok {pr}.NOT.raise?(nil) }
597
599
  end
598
600
  end
599
- it "[!vnc6b] sets exception object into '#exc' attribute." do
601
+ test_subject "[!vnc6b] sets exception object into '#exc' attribute." do
600
602
  pr = proc { "SOS".foobar }
601
- assert !pr.respond_to?(:exc)
603
+ test_ok? !pr.respond_to?(:exc)
602
604
  PASS! { ok {pr}.raise?(NoMethodError) }
603
- assert pr.respond_to?(:exc)
604
- assert pr.exc.is_a?(NoMethodError)
605
+ test_ok? pr.respond_to?(:exc)
606
+ test_ok? pr.exc.is_a?(NoMethodError)
605
607
  if RUBY_VERSION >= "3.3"
606
608
  errmsg = "undefined method `foobar' for an instance of String"
607
609
  elsif RUBY_VERSION =~ /^3\.1\./
@@ -612,18 +614,18 @@ END
612
614
  else
613
615
  errmsg = "undefined method `foobar' for \"SOS\":String"
614
616
  end
615
- assert_eq pr.exc.message, errmsg
617
+ test_eq? pr.exc.message, errmsg
616
618
  #
617
619
  pr = proc { nil }
618
- assert !pr.respond_to?(:exc)
620
+ test_ok? !pr.respond_to?(:exc)
619
621
  PASS! { ok {pr}.NOT.raise?(NoMethodError) }
620
- assert pr.respond_to?(:exc)
621
- assert_eq pr.exc, nil
622
+ test_ok? pr.respond_to?(:exc)
623
+ test_eq? pr.exc, nil
622
624
  end
623
625
  end
624
626
 
625
- describe '#raise!' do
626
- it "[!8k6ee] compares error class by '.is_a?' instead of '=='." do
627
+ test_target 'Oktest::AssertionObject#raise!' do
628
+ test_subject "[!8k6ee] compares error class by '.is_a?' instead of '=='." do
627
629
  pr = proc { "SOS".foobar }
628
630
  PASS! { ok {pr}.raise!(NoMethodError) }
629
631
  PASS! { ok {pr}.raise!(NameError) }
@@ -631,59 +633,59 @@ END
631
633
  end
632
634
  end
633
635
 
634
- describe '#raise_nothing?' do
635
- it "[!leqey] do nothing without calling proc object." do
636
+ test_target 'Oktest::AssertionObject#raise_nothing?' do
637
+ test_subject "[!leqey] do nothing without calling proc object." do
636
638
  pr = proc { 1/0 }
637
639
  ERROR!(ZeroDivisionError) { ok {pr}.raise_nothing? }
638
640
  end
639
- it "[!a61b7] not available with `.NOT`." do
641
+ test_subject "[!a61b7] not available with `.NOT`." do
640
642
  pr = proc { nil }
641
643
  errmsg = "`raise_nothing?()` is not available with `.NOT`."
642
644
  ERROR!(Oktest::OktestError, errmsg) { ok {pr}.NOT.raise_nothing? }
643
645
  end
644
646
  end
645
647
 
646
- describe '#thrown?' do
647
- it "[!w7935] raises ArgumentError when arg of 'thrown?()' is nil." do
648
+ test_target 'Oktest::AssertionObject#thrown?' do
649
+ test_subject "[!w7935] raises ArgumentError when arg of 'thrown?()' is nil." do
648
650
  ERROR!(ArgumentError, "throw?(nil): expected tag required.") do
649
651
  pr = proc { throw :sym1 }
650
652
  ok {pr}.throw?(nil)
651
653
  end
652
654
  end
653
- it "[!lglzr] assertion passes when expected symbol thrown." do
655
+ test_subject "[!lglzr] assertion passes when expected symbol thrown." do
654
656
  pr = proc { throw :sym2 }
655
657
  ok {pr}.throw?(:sym2)
656
- assert true, "ok"
658
+ test_ok? true, msg: "ok"
657
659
  end
658
- it "[!gf9nx] assertion fails when thrown tag is equal to but not same as expected." do
660
+ test_subject "[!gf9nx] assertion fails when thrown tag is equal to but not same as expected." do
659
661
  pr = proc { throw "sym" }
660
662
  expected = ("Thrown tag \"sym\" is equal to but not same as expected.\n"\
661
663
  " (`\"sym\".equal?(\"sym\")` should be true but not.)")
662
664
  FAIL!(expected) { ok {pr}.throw?("sym".dup) }
663
665
  end
664
- it "[!flgwy] assertion fails when thrown tag is different from expectd." do
666
+ test_subject "[!flgwy] assertion fails when thrown tag is different from expectd." do
665
667
  FAIL!(":sym4 should be thrown but actually :sym9 thrown.") do
666
668
  pr = proc { throw :sym9 }
667
669
  ok {pr}.throw?(:sym4)
668
670
  end
669
671
  end
670
- it "[!9ik3x] assertion fails when nothing thrown." do
672
+ test_subject "[!9ik3x] assertion fails when nothing thrown." do
671
673
  pr = proc { nil }
672
674
  expected = ":sym5 should be thrown but nothing thrown."
673
675
  FAIL!(expected) { ok {pr}.throw?(:sym5) }
674
676
  end
675
- it "[!m03vq] raises ArgumentError when non-nil arg passed to 'NOT.thrown?()'." do
677
+ test_subject "[!m03vq] raises ArgumentError when non-nil arg passed to 'NOT.thrown?()'." do
676
678
  ERROR!(ArgumentError, "NOT.throw?(:sym6): argument should be nil.") do
677
679
  pr = proc { nil }
678
680
  ok {pr}.NOT.throw?(:sym6)
679
681
  end
680
682
  end
681
- it "[!kxizg] assertion fails when something thrown in 'NOT.throw?()'." do
683
+ test_subject "[!kxizg] assertion fails when something thrown in 'NOT.throw?()'." do
682
684
  pr = proc { throw :sym7 }
683
685
  expected = "Nothing should be thrown but :sym7 thrown."
684
686
  FAIL!(expected) { ok {pr}.NOT.throw?(nil) }
685
687
  end
686
- it "[!zq9h6] returns self when passed." do
688
+ test_subject "[!zq9h6] returns self when passed." do
687
689
  pr = proc { throw :sym8 }
688
690
  should_return_self { ok {pr}.throw?(:sym8) }
689
691
  #
@@ -692,17 +694,17 @@ END
692
694
  end
693
695
  end
694
696
 
695
- describe '#in?' do
696
- it "[!jzoxg] returns self when passed." do
697
+ test_target 'Oktest::AssertionObject#in?' do
698
+ test_subject "[!jzoxg] returns self when passed." do
697
699
  should_return_self { ok {3}.in?(1..5) }
698
700
  end
699
- it "[!9rm8g] raises assertion error when failed." do
701
+ test_subject "[!9rm8g] raises assertion error when failed." do
700
702
  errmsg = "$<expected>.include?($<actual>): failed.\n"\
701
703
  " $<actual>: 3\n"\
702
704
  " $<expected>: 1..2"
703
705
  FAIL!(errmsg) { ok {3}.in?(1..2) }
704
706
  end
705
- it "[!singl] is available with NOT." do
707
+ test_subject "[!singl] is available with NOT." do
706
708
  PASS! { ok {3}.NOT.in?(1..2) }
707
709
  errmsg = "$<expected>.include?($<actual>) == false: failed.\n"\
708
710
  " $<actual>: 3\n"\
@@ -711,17 +713,17 @@ END
711
713
  end
712
714
  end
713
715
 
714
- describe '#attr()' do
715
- it "[!lz3lb] returns self when passed." do
716
+ test_target 'Oktest::AssertionObject#attr()' do
717
+ test_subject "[!lz3lb] returns self when passed." do
716
718
  should_return_self { ok {"SOS"}.attr(:length, 3) }
717
719
  end
718
- it "[!79tgn] raises assertion error when failed." do
720
+ test_subject "[!79tgn] raises assertion error when failed." do
719
721
  errmsg = "$<actual>.size == $<expected>: failed.\n"\
720
722
  " $<actual>.size: 3\n"\
721
723
  " $<expected>: 2"
722
724
  FAIL!(errmsg) { ok {"SOS"}.attr(:size, 2) }
723
725
  end
724
- it "[!cqnu3] is available with NOT." do
726
+ test_subject "[!cqnu3] is available with NOT." do
725
727
  PASS! { ok {"SOS"}.NOT.attr(:length, 2) }
726
728
  errmsg = "$<actual>.size != $<expected>: failed.\n"\
727
729
  " $<actual>.size: 3\n"\
@@ -730,17 +732,17 @@ END
730
732
  end
731
733
  end
732
734
 
733
- describe '#attrs()' do
734
- it "[!rtq9f] returns self when passed." do
735
+ test_target 'Oktest::AssertionObject#attrs()' do
736
+ test_subject "[!rtq9f] returns self when passed." do
735
737
  should_return_self { ok {"SOS"}.attrs(:length=>3, :size=>3) }
736
738
  end
737
- it "[!7ta0s] raises assertion error when failed." do
739
+ test_subject "[!7ta0s] raises assertion error when failed." do
738
740
  errmsg = "$<actual>.size == $<expected>: failed.\n"\
739
741
  " $<actual>.size: 3\n"\
740
742
  " $<expected>: 2"
741
743
  FAIL!(errmsg) { ok {"SOS"}.attrs(:size=>2) }
742
744
  end
743
- it "[!s0pnk] is available with NOT." do
745
+ test_subject "[!s0pnk] is available with NOT." do
744
746
  PASS! { ok {"SOS"}.NOT.attrs(:length=>2) }
745
747
  errmsg = "$<actual>.size != $<expected>: failed.\n"\
746
748
  " $<actual>.size: 3\n"\
@@ -749,19 +751,19 @@ END
749
751
  end
750
752
  end
751
753
 
752
- describe '#keyval()' do
753
- it "[!byebv] returns self when passed." do
754
+ test_target 'Oktest::AssertionObject#keyval()' do
755
+ test_subject "[!byebv] returns self when passed." do
754
756
  d = {'a'=>1}
755
757
  should_return_self { ok {d}.keyval('a', 1) }
756
758
  end
757
- it "[!vtrlz] raises assertion error when failed." do
759
+ test_subject "[!vtrlz] raises assertion error when failed." do
758
760
  d = {'a'=>1}
759
761
  errmsg = "$<actual>[\"a\"] == $<expected>: failed.\n"\
760
762
  " $<actual>[\"a\"]: 1\n"\
761
763
  " $<expected>: \"1\""
762
764
  FAIL!(errmsg) { ok {d}.keyval('a', '1') }
763
765
  end
764
- it "[!mmpwz] is available with NOT." do
766
+ test_subject "[!mmpwz] is available with NOT." do
765
767
  d = {'a'=>1}
766
768
  PASS! { ok {d}.NOT.keyval('a', '1') }
767
769
  errmsg = "$<actual>[\"a\"] != $<expected>: failed.\n"\
@@ -771,19 +773,19 @@ END
771
773
  end
772
774
  end
773
775
 
774
- describe '#keyvals()' do
775
- it "[!vtw22] returns self when passed." do
776
+ test_target 'Oktest::AssertionObject#keyvals()' do
777
+ test_subject "[!vtw22] returns self when passed." do
776
778
  d = {'a'=>1, 'b'=>2}
777
779
  should_return_self { ok {d}.keyvals('a'=>1, 'b'=>2) }
778
780
  end
779
- it "[!fyvmn] raises assertion error when failed." do
781
+ test_subject "[!fyvmn] raises assertion error when failed." do
780
782
  d = {'a'=>1, 'b'=>2}
781
783
  errmsg = "$<actual>[\"a\"] == $<expected>: failed.\n"\
782
784
  " $<actual>[\"a\"]: 1\n"\
783
785
  " $<expected>: \"1\""
784
786
  FAIL!(errmsg) { ok {d}.keyvals('a'=>'1', 'b'=>2) }
785
787
  end
786
- it "[!js2j2] is available with NOT." do
788
+ test_subject "[!js2j2] is available with NOT." do
787
789
  d = {'a'=>1, 'b'=>2}
788
790
  PASS! { ok {d}.NOT.keyvals('a'=>'1') }
789
791
  errmsg = "$<actual>[\"a\"] != $<expected>: failed.\n"\
@@ -793,17 +795,17 @@ END
793
795
  end
794
796
  end
795
797
 
796
- describe '#length' do
797
- it "[!l9vnv] returns self when passed." do
798
+ test_target 'Oktest::AssertionObject#length' do
799
+ test_subject "[!l9vnv] returns self when passed." do
798
800
  should_return_self { ok {"SOS"}.length(3) }
799
801
  end
800
- it "[!1y787] raises assertion error when failed." do
802
+ test_subject "[!1y787] raises assertion error when failed." do
801
803
  errmsg = "$<actual>.length == 5: failed.\n"\
802
804
  " $<actual>.length: 3\n"\
803
805
  " $<actual>: \"SOS\""
804
806
  FAIL!(errmsg) { ok {"SOS"}.length(5) }
805
807
  end
806
- it "[!kryx2] is available with NOT." do
808
+ test_subject "[!kryx2] is available with NOT." do
807
809
  PASS! { ok {"SOS"}.NOT.length(5) }
808
810
  errmsg = "$<actual>.length != 3: failed.\n"\
809
811
  " $<actual>.length: 3\n"\
@@ -812,16 +814,16 @@ END
812
814
  end
813
815
  end
814
816
 
815
- describe '#truthy?' do
816
- it "[!nhmuk] returns self when passed." do
817
+ test_target 'Oktest::AssertionObject#truthy?' do
818
+ test_subject "[!nhmuk] returns self when passed." do
817
819
  should_return_self { ok {""}.truthy? }
818
820
  end
819
- it "[!3d94h] raises assertion error when failed." do
821
+ test_subject "[!3d94h] raises assertion error when failed." do
820
822
  errmsg = "!!$<actual> == true: failed.\n"\
821
823
  " $<actual>: nil"
822
824
  FAIL!(errmsg) { ok {nil}.truthy? }
823
825
  end
824
- it "[!8rmgp] is available with NOT." do
826
+ test_subject "[!8rmgp] is available with NOT." do
825
827
  PASS! { ok {nil}.NOT.truthy? }
826
828
  errmsg = "!!$<actual> != true: failed.\n"\
827
829
  " $<actual>: 0"
@@ -829,16 +831,16 @@ END
829
831
  end
830
832
  end
831
833
 
832
- describe '#falsy?' do
833
- it "[!w1vm6] returns self when passed." do
834
+ test_target 'Oktest::AssertionObject#falsy?' do
835
+ test_subject "[!w1vm6] returns self when passed." do
834
836
  should_return_self { ok {nil}.falsy? }
835
837
  end
836
- it "[!7o48g] raises assertion error when failed." do
838
+ test_subject "[!7o48g] raises assertion error when failed." do
837
839
  errmsg = "!!$<actual> == false: failed.\n"\
838
840
  " $<actual>: 0"
839
841
  FAIL!(errmsg) { ok {0}.falsy? }
840
842
  end
841
- it "[!i44q6] is available with NOT." do
843
+ test_subject "[!i44q6] is available with NOT." do
842
844
  PASS! { ok {0}.NOT.falsy? }
843
845
  errmsg = "!!$<actual> != false: failed.\n"\
844
846
  " $<actual>: nil"
@@ -846,16 +848,16 @@ END
846
848
  end
847
849
  end
848
850
 
849
- describe '#file_exist?' do
850
- it "[!6bcpp] returns self when passed." do
851
+ test_target 'Oktest::AssertionObject#file_exist?' do
852
+ test_subject "[!6bcpp] returns self when passed." do
851
853
  should_return_self { ok {__FILE__}.file_exist? }
852
854
  end
853
- it "[!69bs0] raises assertion error when failed." do
855
+ test_subject "[!69bs0] raises assertion error when failed." do
854
856
  errmsg = "File.file?($<actual>): failed.\n"\
855
857
  " $<actual>: \".\""
856
858
  FAIL!(errmsg) { ok {'.'}.file_exist? }
857
859
  end
858
- it "[!r1mze] is available with NOT." do
860
+ test_subject "[!r1mze] is available with NOT." do
859
861
  PASS! { ok {'.'}.NOT.file_exist? }
860
862
  errmsg = "File.file?($<actual>) == false: failed.\n"\
861
863
  " $<actual>: \"#{__FILE__}\""
@@ -863,16 +865,16 @@ END
863
865
  end
864
866
  end
865
867
 
866
- describe '#dir_exist?' do
867
- it "[!8qe7u] returns self when passed." do
868
+ test_target 'Oktest::AssertionObject#dir_exist?' do
869
+ test_subject "[!8qe7u] returns self when passed." do
868
870
  should_return_self { ok {'.'}.dir_exist? }
869
871
  end
870
- it "[!vfh7a] raises assertion error when failed." do
872
+ test_subject "[!vfh7a] raises assertion error when failed." do
871
873
  errmsg = "File.directory?($<actual>): failed.\n"\
872
874
  " $<actual>: \"#{__FILE__}\""
873
875
  FAIL!(errmsg) { ok {__FILE__}.dir_exist? }
874
876
  end
875
- it "[!qtllp] is available with NOT." do
877
+ test_subject "[!qtllp] is available with NOT." do
876
878
  PASS! { ok {__FILE__}.NOT.dir_exist? }
877
879
  errmsg = "File.directory?($<actual>) == false: failed.\n"\
878
880
  " $<actual>: \".\""
@@ -880,20 +882,20 @@ END
880
882
  end
881
883
  end
882
884
 
883
- describe '#symlink_exist?' do
884
- def with_symlink
885
+ test_target 'Oktest::AssertionObject#symlink_exist?' do
886
+ def self.with_symlink(&b)
885
887
  linkname = "_sym_#{rand().to_s[2...7]}"
886
888
  File.symlink(__FILE__, linkname)
887
- yield linkname
889
+ b.call linkname
888
890
  ensure
889
891
  File.unlink(linkname)
890
892
  end
891
- it "[!ugfi3] returns self when passed." do
893
+ test_subject "[!ugfi3] returns self when passed." do
892
894
  with_symlink do |linkname|
893
895
  should_return_self { ok {linkname}.symlink_exist? }
894
896
  end
895
897
  end
896
- it "[!qwngl] raises assertion error when failed." do
898
+ test_subject "[!qwngl] raises assertion error when failed." do
897
899
  with_symlink do |linkname|
898
900
  errmsg = "File.symlink?($<actual>): failed.\n"\
899
901
  " $<actual>: \"_not_exist\""
@@ -903,7 +905,7 @@ END
903
905
  FAIL!(errmsg) { ok {'.'}.symlink_exist? }
904
906
  end
905
907
  end
906
- it "[!cgpbt] is available with NOT." do
908
+ test_subject "[!cgpbt] is available with NOT." do
907
909
  with_symlink do |linkname|
908
910
  PASS! { ok {'_not_exist'}.NOT.symlink_exist? }
909
911
  PASS! { ok {'.'}.NOT.symlink_exist? }
@@ -914,16 +916,16 @@ END
914
916
  end
915
917
  end
916
918
 
917
- describe '#not_exist?' do
918
- it "[!1ujag] returns self when passed." do
919
+ test_target 'Oktest::AssertionObject#not_exist?' do
920
+ test_subject "[!1ujag] returns self when passed." do
919
921
  should_return_self { ok {'_not_exist'}.not_exist? }
920
922
  end
921
- it "[!ja84s] raises assertion error when failed." do
923
+ test_subject "[!ja84s] raises assertion error when failed." do
922
924
  errmsg = "File.exist?($<actual>) == false: failed.\n"\
923
925
  " $<actual>: \".\""
924
926
  FAIL!(errmsg) { ok {'.'}.not_exist? }
925
927
  end
926
- it "[!to5z3] is available with NOT." do
928
+ test_subject "[!to5z3] is available with NOT." do
927
929
  PASS! { ok {'.'}.NOT.not_exist? }
928
930
  errmsg = "File.exist?($<actual>): failed.\n"\
929
931
  " $<actual>: \"_not_exist\""
@@ -931,59 +933,59 @@ END
931
933
  end
932
934
  end
933
935
 
934
- describe '#JSON()' do
935
- it "[!n0k03] creates JsonMatcher object." do
936
+ test_target 'Oktest::AssertionObject#JSON()' do
937
+ test_subject "[!n0k03] creates JsonMatcher object." do
936
938
  o = JSON({})
937
- assert_eq o.class, Oktest::JsonMatcher
939
+ test_eq? o.class, Oktest::JsonMatcher
938
940
  end
939
941
  end
940
942
 
941
- describe '#Enum()' do
942
- it "[!fbfr0] creates Enum object which is a subclass of Set." do
943
+ test_target 'Oktest::AssertionObject#Enum()' do
944
+ test_subject "[!fbfr0] creates Enum object which is a subclass of Set." do
943
945
  o = Enum("a", "b", "c")
944
- assert_eq o.class, Oktest::JsonMatcher::Enum
945
- assert o.class < Set
946
- assert_eq (o === "a"), true
947
- assert_eq (o === "b"), true
948
- assert_eq (o === "c"), true
949
- assert_eq (o === "d"), false
946
+ test_eq? o.class, Oktest::JsonMatcher::Enum
947
+ test_ok? o.class < Set
948
+ test_eq? (o === "a"), true
949
+ test_eq? (o === "b"), true
950
+ test_eq? (o === "c"), true
951
+ test_eq? (o === "d"), false
950
952
  end
951
953
  end
952
954
 
953
- describe '#Bool()' do
954
- it "[!vub5j] creates a set of true and false." do
955
- assert_eq Bool().class, Oktest::JsonMatcher::Enum
956
- assert Bool() === true
957
- assert Bool() === false
958
- assert_eq (Bool() === 1), false
959
- assert_eq (Bool() === 0), false
955
+ test_target 'Oktest::AssertionObject#Bool()' do
956
+ test_subject "[!vub5j] creates a set of true and false." do
957
+ test_eq? Bool().class, Oktest::JsonMatcher::Enum
958
+ test_ok? Bool() === true
959
+ test_ok? Bool() === false
960
+ test_eq? (Bool() === 1), false
961
+ test_eq? (Bool() === 0), false
960
962
  end
961
963
  end
962
964
 
963
- describe '#OR()' do
964
- it "[!9e8im] creates `OR` object." do
965
+ test_target 'Oktest::AssertionObject#OR()' do
966
+ test_subject "[!9e8im] creates `OR` object." do
965
967
  o = OR(1, 2, 3)
966
- assert_eq o.class, Oktest::JsonMatcher::OR
968
+ test_eq? o.class, Oktest::JsonMatcher::OR
967
969
  end
968
970
  end
969
971
 
970
- describe '#AND()' do
971
- it "[!38jln] creates `AND` object." do
972
+ test_target 'Oktest::AssertionObject#AND()' do
973
+ test_subject "[!38jln] creates `AND` object." do
972
974
  o = AND(4, 5, 6)
973
- assert_eq o.class, Oktest::JsonMatcher::AND
975
+ test_eq? o.class, Oktest::JsonMatcher::AND
974
976
  end
975
977
  end
976
978
 
977
- describe '#Length()' do
978
- it "[!qqas3] creates Length object." do
979
+ test_target 'Oktest::AssertionObject#Length()' do
980
+ test_subject "[!qqas3] creates Length object." do
979
981
  o = Length(3)
980
- assert_eq o.class, Oktest::JsonMatcher::Length
982
+ test_eq? o.class, Oktest::JsonMatcher::Length
981
983
  end
982
984
  end
983
985
 
984
- describe '#Any()' do
985
- it "[!dlo1o] creates an 'Any' object." do
986
- assert_eq Any().class, Oktest::JsonMatcher::Any
986
+ test_target 'Oktest::AssertionObject#Any()' do
987
+ test_subject "[!dlo1o] creates an 'Any' object." do
988
+ test_eq? Any().class, Oktest::JsonMatcher::Any
987
989
  end
988
990
  end
989
991