oktest 1.0.1 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
  ###
4
- ### $Release: 1.0.1 $
4
+ ### $Release: 1.2.0 $
5
5
  ### $Copyright: copyright(c) 2011-2021 kuwata-lab.com all rights reserved $
6
6
  ### $License: MIT License $
7
7
  ###
@@ -11,15 +11,6 @@ require_relative './initialize'
11
11
 
12
12
  module ReporterTestHelper
13
13
 
14
- def plain2colored(str)
15
- str = str.gsub(/<R>(.*?)<\/R>/) { Oktest::Color.red($1) }
16
- str = str.gsub(/<G>(.*?)<\/G>/) { Oktest::Color.green($1) }
17
- str = str.gsub(/<B>(.*?)<\/B>/) { Oktest::Color.blue($1) }
18
- str = str.gsub(/<Y>(.*?)<\/Y>/) { Oktest::Color.yellow($1) }
19
- str = str.gsub(/<b>(.*?)<\/b>/) { Oktest::Color.bold($1) }
20
- return str
21
- end
22
-
23
14
  def edit_actual(output)
24
15
  bkup = output.dup
25
16
  output = output.gsub(/^.*\r/, '')
@@ -145,7 +136,11 @@ class BaseReporter_TC < TC
145
136
  sout, serr = capture do
146
137
  r.__send__(:print_exc_message, exc, :FAIL)
147
138
  end
148
- assert_eq sout, errmsg
139
+ assert_eq sout, plain2colored(<<END)
140
+ <R>something failed</R>
141
+ expect: foo
142
+ actual: bar
143
+ END
149
144
  assert_eq serr, ""
150
145
  end
151
146
  it "[!pd41p] prints detail of exception." do
@@ -155,7 +150,11 @@ class BaseReporter_TC < TC
155
150
  sout, serr = capture do
156
151
  r.__send__(:print_exc_message, exc, :ERROR)
157
152
  end
158
- assert_eq sout, "Oktest::AssertionFailed: "+errmsg
153
+ assert_eq sout, plain2colored(<<END)
154
+ <R>Oktest::AssertionFailed: something failed</R>
155
+ expect: foo
156
+ actual: bar
157
+ END
159
158
  assert_eq serr, ""
160
159
  end
161
160
  end
@@ -246,7 +245,7 @@ END
246
245
  end
247
246
  #
248
247
  expected = <<END
249
- [<R>ERROR</R>] <b>Example > Array > When some condition > 1+1 shoould be 2.</b>
248
+ [<E>ERROR</E>] <b>Example > Array > When some condition > 1+1 shoould be 2.</b>
250
249
  #{__FILE__}:#{lineno}:in `/'
251
250
  1/0
252
251
  END
@@ -283,7 +282,7 @@ END
283
282
  r = new_reporter_with_exceptions(exc)
284
283
  sep = "----------------------------------------------------------------------\n"
285
284
  expected1 = "[<R>Fail</R>] <b>Example > Array > When some condition > 1+1 shoould be 2.</b>\n"
286
- expected2 = "[<R>ERROR</R>] <b>Example > Array > When some condition > 1+1 shoould be 2.</b>\n"
285
+ expected2 = "[<E>ERROR</E>] <b>Example > Array > When some condition > 1+1 shoould be 2.</b>\n"
287
286
  #
288
287
  sout, serr = capture { r.__send__(:print_exceptions) }
289
288
  assert sout.start_with?(sep + plain2colored(expected1)), "not matched"
@@ -349,7 +348,7 @@ END
349
348
  end
350
349
 
351
350
  it "[!gx0n2] builds footer line." do
352
- expected = "## total:15 (<B>pass:5</B>, <R>fail:4</R>, <R>error:3</R>, <Y>skip:2</Y>, <Y>todo:1</Y>) in 0.500s"
351
+ expected = "## total:15 (<C>pass:5</C>, <R>fail:4</R>, <E>error:3</E>, <Y>skip:2</Y>, <Y>todo:1</Y>) in 0.500s"
353
352
  assert new_footer(), plain2colored(expected)
354
353
  end
355
354
  end
@@ -418,6 +417,10 @@ Oktest.scope do
418
417
  end
419
418
  end
420
419
 
420
+ spec "last spec" do
421
+ ok {1+1} == 2
422
+ end
423
+
421
424
  end
422
425
 
423
426
  end
@@ -430,54 +433,67 @@ END
430
433
  _test.tmp:18:in `block (4 levels) in <top (required)>'
431
434
  ok {1*1} == 2
432
435
  %%%
433
- $<actual> == $<expected>: failed.
436
+ <R>$<actual> == $<expected>: failed.</R>
434
437
  $<actual>: 1
435
438
  $<expected>: 2
436
439
  ----------------------------------------------------------------------
437
- [<R>ERROR</R>] <b>Parent > Child2 > 1/1 should be 1</b>
440
+ [<E>ERROR</E>] <b>Parent > Child2 > 1/1 should be 1</b>
438
441
  _test.tmp:21:in `/'
439
442
  ok {1/0} == 1
440
443
  %%%
441
- ZeroDivisionError: divided by 0
444
+ <R>ZeroDivisionError: divided by 0</R>
442
445
  ----------------------------------------------------------------------
443
446
  END
444
447
 
445
448
  FOOTER = <<'END'
446
- ## total:8 (<B>pass:4</B>, <R>fail:1</R>, <R>error:1</R>, <Y>skip:1</Y>, <Y>todo:1</Y>) in 0.000s
449
+ ## total:9 (<C>pass:5</C>, <R>fail:1</R>, <E>error:1</E>, <Y>skip:1</Y>, <Y>todo:1</Y>) in 0.000s
447
450
  END
448
451
 
449
452
  VERBOSE_PART = <<'END'
453
+ ## _test.tmp
450
454
  * <b>Parent</b>
451
455
  * <b>Child1</b>
452
- - [<B>pass</B>] 1+1 should be 2
453
- - [<B>pass</B>] 1-1 should be 0
456
+ - [<C>pass</C>] 1+1 should be 2
457
+ - [<C>pass</C>] 1-1 should be 0
454
458
  * <b>Child2</b>
455
459
  - [<R>Fail</R>] 1*1 should be 1
456
- - [<R>ERROR</R>] 1/1 should be 1
460
+ - [<E>ERROR</E>] 1/1 should be 1
457
461
  END
458
462
  VERBOSE_PART2 = <<'END'
459
463
  * <b>Child3</b>
460
464
  - [<Y>Skip</Y>] skip example <Y>(reason: a certain condition)</Y>
461
465
  - [<Y>TODO</Y>] todo example
462
466
  - <b>When x is negative</b>
463
- - [<B>pass</B>] x*x is positive.
467
+ - [<C>pass</C>] x*x is positive.
464
468
  - <b>Else</b>
465
- - [<B>pass</B>] x*x is also positive.
469
+ - [<C>pass</C>] x*x is also positive.
470
+ - [<C>pass</C>] last spec
466
471
  END
467
472
  VERBOSE_OUTPUT = VERBOSE_PART + ERROR_PART + VERBOSE_PART2 + FOOTER
468
473
 
469
474
  SIMPLE_PART = <<'END'
470
- _test.tmp: <B>.</B><B>.</B><R>f</R><R>E</R><Y>s</Y><Y>t</Y><B>.</B><B>.</B>
475
+ ## _test.tmp
476
+ * <b>Parent</b>: <C>.</C><C>.</C><C>.</C>
477
+ * <b>Child1</b>: <C>.</C><C>.</C>
478
+ * <b>Child2</b>: <R>f</R><E>E</E>
479
+ END
480
+ SIMPLE_PART2 = <<'END'
481
+ * <b>Child3</b>: <Y>s</Y><Y>t</Y>
482
+ END
483
+ SIMPLE_OUTPUT = SIMPLE_PART + ERROR_PART + SIMPLE_PART2 + FOOTER
484
+
485
+ COMPACT_PART = <<'END'
486
+ _test.tmp: <C>.</C><C>.</C><R>f</R><E>E</E><Y>s</Y><Y>t</Y><C>.</C><C>.</C><C>.</C>
471
487
  END
472
- SIMPLE_OUTPUT = SIMPLE_PART + ERROR_PART + FOOTER
488
+ COMPACT_OUTPUT = COMPACT_PART + ERROR_PART + FOOTER
473
489
 
474
490
  PLAIN_PART = <<'END'
475
- <B>.</B><B>.</B><R>f</R><R>E</R><Y>s</Y><Y>t</Y><B>.</B><B>.</B>
491
+ <C>.</C><C>.</C><R>f</R><E>E</E><Y>s</Y><Y>t</Y><C>.</C><C>.</C><C>.</C>
476
492
  END
477
493
  PLAIN_OUTPUT = PLAIN_PART + ERROR_PART + FOOTER
478
494
 
479
495
  QUIET_PART = <<'END'
480
- <R>f</R><R>E</R><Y>s</Y><Y>t</Y>
496
+ <R>f</R><E>E</E><Y>s</Y><Y>t</Y>
481
497
  END
482
498
  QUIET_OUTPUT = QUIET_PART + ERROR_PART + FOOTER
483
499
 
@@ -516,7 +532,7 @@ end
516
532
 
517
533
  class SimpleReporter_TC < Reporter_TC
518
534
 
519
- it "[!xfd5o] reports filename." do
535
+ it "[!jxa1b] reports topics and progress." do
520
536
  sout, serr = run("-ss", @filename)
521
537
  assert_eq edit_actual(sout), edit_expected(SIMPLE_OUTPUT)
522
538
  assert_eq serr, ""
@@ -525,6 +541,17 @@ class SimpleReporter_TC < Reporter_TC
525
541
  end
526
542
 
527
543
 
544
+ class CompactReporter_TC < Reporter_TC
545
+
546
+ it "[!xfd5o] reports filename." do
547
+ sout, serr = run("-sc", @filename)
548
+ assert_eq edit_actual(sout), edit_expected(COMPACT_OUTPUT)
549
+ assert_eq serr, ""
550
+ end
551
+
552
+ end
553
+
554
+
528
555
  class PlainReporter_TC < Reporter_TC
529
556
 
530
557
  it "[!w842j] reports progress." do
data/test/runner_test.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
  ###
4
- ### $Release: 1.0.1 $
4
+ ### $Release: 1.2.0 $
5
5
  ### $Copyright: copyright(c) 2011-2021 kuwata-lab.com all rights reserved $
6
6
  ### $License: MIT License $
7
7
  ###
@@ -44,6 +44,10 @@ class Runner_TC < TC
44
44
  def counts; {}; end
45
45
  end
46
46
 
47
+ class DummyReporter2 < DummyReporter
48
+ def order_policy; :spec_first; end
49
+ end
50
+
47
51
  describe "#start()" do
48
52
  build_topics = proc {
49
53
  Oktest.scope do
@@ -389,6 +393,47 @@ topic: "Parent"
389
393
  /topic
390
394
  [all] after_all
391
395
  /file
396
+ END
397
+ assert_eq sout, expected
398
+ assert_eq serr, ""
399
+ end
400
+ it "[!p3a5o] run specs and case_when in advance of specs and topics when SimpleReporter." do
401
+ sout, serr = capture do
402
+ Oktest.scope do
403
+ topic "T1" do
404
+ topic "T2" do
405
+ spec("S1") { ok {1+1} == 2 }
406
+ end
407
+ spec("S2") { ok {1+1} == 2 }
408
+ topic "T3" do
409
+ spec("S3") { ok {1+1} == 2 }
410
+ end
411
+ case_when "T4" do
412
+ spec("S4") { ok {1+1} == 2 }
413
+ end
414
+ end
415
+ end
416
+ Oktest::Runner.new(DummyReporter2.new).start()
417
+ end
418
+ expected = <<'END'
419
+ file: "test/runner_test.rb"
420
+ topic: "T1"
421
+ spec: "S2"
422
+ /spec: status=:PASS
423
+ topic: "When T4"
424
+ spec: "S4"
425
+ /spec: status=:PASS
426
+ /topic
427
+ topic: "T2"
428
+ spec: "S1"
429
+ /spec: status=:PASS
430
+ /topic
431
+ topic: "T3"
432
+ spec: "S3"
433
+ /spec: status=:PASS
434
+ /topic
435
+ /topic
436
+ /file
392
437
  END
393
438
  assert_eq sout, expected
394
439
  assert_eq serr, ""
@@ -417,6 +462,46 @@ file: "test/runner_test.rb"
417
462
  [all] before_all#2
418
463
  [all] after_all#2
419
464
  /file
465
+ END
466
+ assert_eq sout, expected
467
+ assert_eq serr, ""
468
+ end
469
+ it "[!c5cw0] run specs and case_when in advance of specs and topics when SimpleReporter." do
470
+ sout, serr = capture do
471
+ Oktest.scope do
472
+ topic "T1" do
473
+ spec("S1") { ok {1+1} == 2 }
474
+ end
475
+ spec("S2") { ok {1+1} == 2 }
476
+ case_when "T2" do
477
+ spec("S3") { ok {1+1} == 2 }
478
+ end
479
+ topic "T3" do
480
+ spec("S4") { ok {1+1} == 2 }
481
+ end
482
+ spec("S5") { ok {1+1} == 2 }
483
+ end
484
+ Oktest::Runner.new(DummyReporter2.new).start()
485
+ end
486
+ expected = <<'END'
487
+ file: "test/runner_test.rb"
488
+ spec: "S2"
489
+ /spec: status=:PASS
490
+ topic: "When T2"
491
+ spec: "S3"
492
+ /spec: status=:PASS
493
+ /topic
494
+ spec: "S5"
495
+ /spec: status=:PASS
496
+ topic: "T1"
497
+ spec: "S1"
498
+ /spec: status=:PASS
499
+ /topic
500
+ topic: "T3"
501
+ spec: "S4"
502
+ /spec: status=:PASS
503
+ /topic
504
+ /file
420
505
  END
421
506
  assert_eq sout, expected
422
507
  assert_eq serr, ""
@@ -436,15 +521,6 @@ class RunnerFunctions_TC < TC
436
521
  Oktest::THE_GLOBAL_SCOPE.clear_children()
437
522
  end
438
523
 
439
- def plain2colored(str)
440
- str = str.gsub(/<R>(.*?)<\/R>/) { Oktest::Color.red($1) }
441
- str = str.gsub(/<G>(.*?)<\/G>/) { Oktest::Color.green($1) }
442
- str = str.gsub(/<B>(.*?)<\/B>/) { Oktest::Color.blue($1) }
443
- str = str.gsub(/<Y>(.*?)<\/Y>/) { Oktest::Color.yellow($1) }
444
- str = str.gsub(/<b>(.*?)<\/b>/) { Oktest::Color.bold($1) }
445
- return str
446
- end
447
-
448
524
  def edit_actual(output)
449
525
  bkup = output.dup
450
526
  output = output.gsub(/^.*\r/, '')
@@ -474,18 +550,19 @@ class RunnerFunctions_TC < TC
474
550
  end
475
551
 
476
552
  VERBOSE_OUTPUT = <<'END'
553
+ ## test/runner_test.rb
477
554
  * <b>Example</b>
478
- - [<B>pass</B>] 1+1 should be 2
479
- - [<B>pass</B>] 1-1 should be 0
480
- ## total:2 (<B>pass:2</B>, fail:0, error:0, skip:0, todo:0) in 0.000s
555
+ - [<C>pass</C>] 1+1 should be 2
556
+ - [<C>pass</C>] 1-1 should be 0
557
+ ## total:2 (<C>pass:2</C>, fail:0, error:0, skip:0, todo:0) in 0.000s
481
558
  END
482
- SIMPLE_OUTPUT = <<'END'
483
- test/runner_test.rb: <B>.</B><B>.</B>
484
- ## total:2 (<B>pass:2</B>, fail:0, error:0, skip:0, todo:0) in 0.000s
559
+ COMPACT_OUTPUT = <<'END'
560
+ test/runner_test.rb: <C>.</C><C>.</C>
561
+ ## total:2 (<C>pass:2</C>, fail:0, error:0, skip:0, todo:0) in 0.000s
485
562
  END
486
563
  PLAIN_OUTPUT = <<'END'
487
- <B>.</B><B>.</B>
488
- ## total:2 (<B>pass:2</B>, fail:0, error:0, skip:0, todo:0) in 0.000s
564
+ <C>.</C><C>.</C>
565
+ ## total:2 (<C>pass:2</C>, fail:0, error:0, skip:0, todo:0) in 0.000s
489
566
  END
490
567
 
491
568
 
@@ -497,11 +574,6 @@ END
497
574
  assert_eq edit_actual(sout), edit_expected(expected)
498
575
  assert_eq serr, ""
499
576
  end
500
- it "[!kfi8b] do nothing when 'Oktest.scope()' not called." do
501
- sout, serr = capture { Oktest.run() }
502
- assert_eq sout, ""
503
- assert_eq serr, ""
504
- end
505
577
  it "[!6xn3t] creates reporter object according to 'style:' keyword arg." do
506
578
  expected = VERBOSE_OUTPUT
507
579
  prepare()
@@ -509,9 +581,9 @@ END
509
581
  assert_eq edit_actual(sout), edit_expected(expected)
510
582
  assert_eq serr, ""
511
583
  #
512
- expected = SIMPLE_OUTPUT
584
+ expected = COMPACT_OUTPUT
513
585
  prepare()
514
- sout, serr = capture { Oktest.run(:style=>"simple") }
586
+ sout, serr = capture { Oktest.run(:style=>"compact") }
515
587
  assert_eq edit_actual(sout), edit_expected(expected)
516
588
  assert_eq serr, ""
517
589
  #
data/test/tc.rb CHANGED
@@ -109,6 +109,18 @@ class TC
109
109
  $stdin, $stdout, $stderr = stdin, stdout, stderr
110
110
  end
111
111
 
112
+ def plain2colored(str)
113
+ str = str.gsub(/<R>(.*?)<\/R>/) { Oktest::Color.red($1) }
114
+ str = str.gsub(/<G>(.*?)<\/G>/) { Oktest::Color.green($1) }
115
+ str = str.gsub(/<B>(.*?)<\/B>/) { Oktest::Color.blue($1) }
116
+ str = str.gsub(/<C>(.*?)<\/C>/) { Oktest::Color.cyan($1) }
117
+ str = str.gsub(/<M>(.*?)<\/M>/) { Oktest::Color.magenta($1) }
118
+ str = str.gsub(/<Y>(.*?)<\/Y>/) { Oktest::Color.yellow($1) }
119
+ str = str.gsub(/<b>(.*?)<\/b>/) { Oktest::Color.bold($1) }
120
+ str = str.gsub(/<E>(.*?)<\/E>/) { Oktest::Color.red_b($1) }
121
+ return str
122
+ end
123
+
112
124
  end
113
125
 
114
126
 
data/test/util_test.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
  ###
4
- ### $Release: 1.0.1 $
4
+ ### $Release: 1.2.0 $
5
5
  ### $Copyright: copyright(c) 2011-2021 kuwata-lab.com all rights reserved $
6
6
  ### $License: MIT License $
7
7
  ###
@@ -74,6 +74,15 @@ END
74
74
  end
75
75
  end
76
76
 
77
+ describe '.keyword_param_names_of_block()' do
78
+ it "[!p6qqp] returns keyword param names of proc object." do
79
+ pr = proc {|a, b=nil, c: nil, d: 1| nil }
80
+ assert_eq keyword_param_names_of_block(pr), [:c, :d]
81
+ pr = proc {|a, b=nil| nil }
82
+ assert_eq keyword_param_names_of_block(pr), []
83
+ end
84
+ end
85
+
77
86
  describe '.strfold()' do
78
87
  it "[!wb7m8] returns string as it is if string is not long." do
79
88
  s = "*" * 79
@@ -253,6 +262,67 @@ END
253
262
  end
254
263
  end
255
264
 
265
+ describe '.partial_regexp!()' do
266
+ it "[!peyu4] returns PartialRegexp object which inspect string is function call styel." do
267
+ pattern_str = <<'HEREDOC'
268
+ * [Date] {== \d\d\d\d-\d\d-\d\d ==}
269
+ * [Secret] {== [0-9a-f]{8} ==}
270
+ HEREDOC
271
+ prexp = Oktest::Util.partial_regexp!(pattern_str)
272
+ assert_eq prexp.class, Oktest::Util::PartialRegexp
273
+ assert_eq prexp.pattern_string, pattern_str
274
+ end
275
+ end
276
+
277
+ describe '.partial_regexp()' do
278
+ it "[!ostkw] raises error if mark has no space or has more than two spaces." do
279
+ assert_exc(ArgumentError, "\"{====}\": mark should contain only one space (ex: `{== ==}`).") do
280
+ Oktest::Util.partial_regexp("xxx", '\A', '\z', "{====}")
281
+ end
282
+ assert_exc(ArgumentError, "\"{= == =}\": mark should contain only one space (ex: `{== ==}`).") do
283
+ Oktest::Util.partial_regexp("xxx", '', '', "{= == =}")
284
+ end
285
+ end
286
+ it "[!wn524] returns PartialRegexp object which inspect string is regexp literal style." do
287
+ pattern_str = <<'HEREDOC'
288
+ * [Date] {== \d\d\d\d-\d\d-\d\d ==}
289
+ * [Secret] {== [0-9a-f]{8} ==}
290
+ HEREDOC
291
+ prexp = Oktest::Util.partial_regexp(pattern_str)
292
+ assert_eq prexp.class, Oktest::Util::PartialRegexp
293
+ assert_eq prexp.pattern_string, nil
294
+ end
295
+ end
296
+
297
+ end
298
+
299
+ describe Oktest::Util::PartialRegexp do
300
+ describe '#inspect()' do
301
+ it "[!uyh31] returns function call style string if @pattern_string is set." do
302
+ prexp = Oktest::Util.partial_regexp!(<<'HEREHERE')
303
+ * [Date] {== \d\d\d\d-\d\d-\d\d ==}
304
+ * [Secret] {== [0-9a-f]{8} ==}
305
+ HEREHERE
306
+ assert_eq prexp.inspect, <<'HEREHERE'
307
+ partial_regexp(<<PREXP, '\A', '\z')
308
+ * [Date] {== \d\d\d\d-\d\d-\d\d ==}
309
+ * [Secret] {== [0-9a-f]{8} ==}
310
+ PREXP
311
+ HEREHERE
312
+ end
313
+ it "[!ts9v4] returns regexp literal style string if @pattern_string is not set." do
314
+ prexp = Oktest::Util.partial_regexp(<<'HEREHERE')
315
+ * [Date] {== \d\d\d\d-\d\d-\d\d ==}
316
+ * [Secret] {== [0-9a-f]{8} ==}
317
+ HEREHERE
318
+ assert_eq prexp.inspect, <<'HEREHERE'.chomp
319
+ /\A
320
+ \*\ \[Date\]\ \ \ \ \d\d\d\d-\d\d-\d\d\n
321
+ \*\ \[Secret\]\ \ [0-9a-f]{8}\n
322
+ \z/x
323
+ HEREHERE
324
+ end
325
+ end
256
326
  end
257
327
 
258
328
  end
@@ -0,0 +1,84 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ ###
4
+ ### $Release: 1.2.0 $
5
+ ### $Copyright: copyright(c) 2011-2021 kuwata-lab.com all rights reserved $
6
+ ### $License: MIT License $
7
+ ###
8
+
9
+ require_relative './initialize'
10
+
11
+
12
+ class UtilHelper_TC < TC
13
+
14
+ describe Oktest::UtilHelper do
15
+
16
+ describe '#partial_regexp!()' do
17
+ pat = <<'END'
18
+ * [Date] {== \d\d\d\d-\d\d-\d\d ==}
19
+ * [Secret] {== [0-9a-f]{12} ==}
20
+ END
21
+ it "[!9drtn] is available in both topic and spec blocks." do
22
+ r1 = nil; r2 = nil
23
+ Oktest.scope do
24
+ topic "topic" do
25
+ r1 = partial_regexp!(pat, '\A', '\z')
26
+ spec "spec" do
27
+ r2 = partial_regexp!(pat, "", "")
28
+ end
29
+ end
30
+ end
31
+ capture { Oktest.run() }
32
+ assert_eq r1.class, Oktest::Util::PartialRegexp
33
+ assert_eq r2.class, Oktest::Util::PartialRegexp
34
+ assert_eq r1.inspect, <<'END'
35
+ partial_regexp(<<PREXP, '\A', '\z')
36
+ * [Date] {== \d\d\d\d-\d\d-\d\d ==}
37
+ * [Secret] {== [0-9a-f]{12} ==}
38
+ PREXP
39
+ END
40
+ assert_eq r2.inspect, <<'END'
41
+ partial_regexp(<<PREXP, "", "")
42
+ * [Date] {== \d\d\d\d-\d\d-\d\d ==}
43
+ * [Secret] {== [0-9a-f]{12} ==}
44
+ PREXP
45
+ END
46
+ end
47
+ end
48
+
49
+ describe '#partial_regexp()' do
50
+ it "[!wo4hp] is available in both topic and spec blocks." do
51
+ pat = <<'END'
52
+ * [Date] {== \d\d\d\d-\d\d-\d\d ==}
53
+ * [Secret] {== [0-9a-f]{12} ==}
54
+ END
55
+ r1 = nil; r2 = nil
56
+ Oktest.scope do
57
+ topic "topic" do
58
+ r1 = partial_regexp(pat, '\A', '\z')
59
+ spec "spec" do
60
+ r2 = partial_regexp(pat, "", "")
61
+ end
62
+ end
63
+ end
64
+ capture { Oktest.run() }
65
+ assert_eq r1.class, Oktest::Util::PartialRegexp
66
+ assert_eq r2.class, Oktest::Util::PartialRegexp
67
+ assert_eq r1.inspect, <<'END'.chomp
68
+ /\A
69
+ \*\ \[Date\]\ \ \ \ \d\d\d\d-\d\d-\d\d\n
70
+ \*\ \[Secret\]\ \ [0-9a-f]{12}\n
71
+ \z/x
72
+ END
73
+ assert_eq r2.inspect, <<'END'.chomp
74
+ /
75
+ \*\ \[Date\]\ \ \ \ \d\d\d\d-\d\d-\d\d\n
76
+ \*\ \[Secret\]\ \ [0-9a-f]{12}\n
77
+ /x
78
+ END
79
+ end
80
+ end
81
+
82
+ end
83
+
84
+ end
data/test/visitor_test.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
  ###
4
- ### $Release: 1.0.1 $
4
+ ### $Release: 1.2.0 $
5
5
  ### $Copyright: copyright(c) 2011-2021 kuwata-lab.com all rights reserved $
6
6
  ### $License: MIT License $
7
7
  ###
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oktest
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - kwatch
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-04 00:00:00.000000000 Z
11
+ date: 2021-11-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: diff-lcs
@@ -70,6 +70,7 @@ files:
70
70
  - test/helper_test.rb
71
71
  - test/initialize.rb
72
72
  - test/mainapp_test.rb
73
+ - test/matcher_test.rb
73
74
  - test/misc_test.rb
74
75
  - test/node_test.rb
75
76
  - test/reporter_test.rb
@@ -77,12 +78,13 @@ files:
77
78
  - test/runner_test.rb
78
79
  - test/tc.rb
79
80
  - test/util_test.rb
81
+ - test/utilhelper_test.rb
80
82
  - test/visitor_test.rb
81
83
  homepage: https://github.com/kwatch/oktest/tree/ruby
82
84
  licenses:
83
85
  - MIT
84
86
  metadata: {}
85
- post_install_message:
87
+ post_install_message:
86
88
  rdoc_options: []
87
89
  require_paths:
88
90
  - lib
@@ -90,16 +92,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
90
92
  requirements:
91
93
  - - ">="
92
94
  - !ruby/object:Gem::Version
93
- version: '2.3'
95
+ version: '2.0'
94
96
  required_rubygems_version: !ruby/object:Gem::Requirement
95
97
  requirements:
96
98
  - - ">="
97
99
  - !ruby/object:Gem::Version
98
100
  version: '0'
99
101
  requirements: []
100
- rubyforge_project:
101
- rubygems_version: 2.5.2.3
102
- signing_key:
102
+ rubygems_version: 3.2.22
103
+ signing_key:
103
104
  specification_version: 4
104
105
  summary: new style testing library
105
106
  test_files: