oktest 1.2.0 → 1.2.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 829638b6c9703b023e61adfdef426e7ddb206f2ba93775143b8ae39c86b0f381
4
- data.tar.gz: f4d70f1272398f74b0abaad9bd0ea027ca557a8860c44d6f11f056a60d89fc4c
3
+ metadata.gz: a67a9622ea13bcbb40bf426b2e6321619256062ab2db5d7e4e951cb51d2e5beb
4
+ data.tar.gz: 420f3f9da92864fdc96a8cd1dc53e8ae369527445b03f1d6ddcf004b5a9f60b1
5
5
  SHA512:
6
- metadata.gz: 5669eea2d32e6d0ecdfdd263a50e9a740fd6e2da081bbc0e35d433796d242507341bccc53c2c6ca7cd5a26d0b55a7c8222da5fb15eca27945a1207222c4ee32d
7
- data.tar.gz: 8cdce5238153c774972ac26bf6b389786b920a41c8d4d2069df03d17e80ebdd299be83a63d44f7840088482b3e05e35019fdf0804a57c1273e93cde14a9a547e
6
+ metadata.gz: ff57c813e8aca8c7136c0fe98850894602d49c4d38bf4d151d05281ddd5c73cd06773e275ae79103862908cdea242b82130eddc81e5f3b68391ce5d85cc5ccb9
7
+ data.tar.gz: 155d0e8d7d7f606b2ebe41643fd4fccf34f5dd4c4882b555a6c9137682f65ca37d5c701e6cb7cdce1f0679cf4a2ef0403b45780dbe9506c6d5640106d4d7d76a
data/README.md CHANGED
@@ -95,8 +95,8 @@ Oktest.rb requires Ruby 2.0 or later.
95
95
  * <a href="#testing-rack-application">Testing Rack Application</a>
96
96
  * <a href="#environment-variale-oktest_rb">Environment Variale <code>$OKTEST_RB</code></a>
97
97
  * <a href="#traverser-class">Traverser Class</a>
98
- * <a href="#benchmarks">Benchmarks</a>
99
98
  * <a href="#--faster-option"><code>--faster</code> Option</a>
99
+ * <a href="#benchmarks">Benchmarks</a>
100
100
  * <a href="#change-log">Change Log</a>
101
101
  * <a href="#license-and-copyright">License and Copyright</a>
102
102
 
@@ -1010,15 +1010,15 @@ end
1010
1010
  Result:
1011
1011
 
1012
1012
  ```terminal
1013
- $ oktest -s plain test/example21_test.rb
1013
+ $ oktest -s quiet test/example21a_test.rb
1014
1014
  *** before_all() ***
1015
1015
  === before() ===
1016
1016
  ---- example spec #1 ----
1017
1017
  === after() ===
1018
- .=== before() ===
1018
+ === before() ===
1019
1019
  ---- example spec #2 ----
1020
1020
  === after() ===
1021
- .*** after_all() ***
1021
+ *** after_all() ***
1022
1022
 
1023
1023
  ## total:2 (pass:2, fail:0, error:0, skip:0, todo:0) in 0.000s
1024
1024
  ```
@@ -1729,7 +1729,7 @@ END
1729
1729
  If you want to change embed mark, specify 4th argument, like this:
1730
1730
 
1731
1731
  ```ruby
1732
- partial_regexp <<-'END', '\A', '\z', '%%(.*?)%%' # !!!!!
1732
+ partial_regexp <<-'END', '\A', '\z', '%% %%' # !!!!!
1733
1733
  * [config.date] %% \d\d\d\d-\d\d-\d\d %%
1734
1734
  * [config.secret] %% [0-9a-f]+ %%
1735
1735
  END
@@ -2160,6 +2160,24 @@ $ ruby test/example54_test.rb
2160
2160
  ```
2161
2161
 
2162
2162
 
2163
+ ### `--faster` Option
2164
+
2165
+ ~~If you are working in very larget project and you want to run test scripts as fast as possible, try `--faster` option of `oktest` command.~~
2166
+
2167
+ ```terminal
2168
+ $ oktest -s quiet --faster test/ ## only for very large project
2169
+ ```
2170
+
2171
+ ~~Or set `Oktest::Config.ok_location = false` in your test script.~~
2172
+
2173
+ ```ruby
2174
+ require 'oktest'
2175
+ Oktest::Config.ok_location = false ## only for very large project
2176
+ ```
2177
+
2178
+ `--faster` option is still available but no longer recommended, because performance of `ok{}` is improved significantly since Oktest.rb 1.2.0.
2179
+
2180
+
2163
2181
  ### Benchmarks
2164
2182
 
2165
2183
  Oktest.rb gem file contains benchmark script.
@@ -2180,42 +2198,52 @@ ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [x86_64-darwin18]
2180
2198
  $ rake benchmark:all
2181
2199
  ```
2182
2200
 
2201
+ Summary of example result:
2202
+
2203
+ ```
2204
+ Oktest: 6.815 real 6.511 user 0.257 sys
2205
+ Oktest (--faster): 6.401 real 6.123 user 0.240 sys
2206
+ RSpec: 32.062 real 27.778 user 4.383 sys
2207
+ MiniTest: 9.140 real 8.657 user 0.705 sys
2208
+ Test::Unit: 19.580 real 19.020 user 0.885 sys
2209
+ ```
2210
+
2183
2211
  Example result:
2184
2212
 
2185
2213
  ```
2186
- ==================== {{*oktest*}} ====================
2214
+ ==================== oktest ====================
2187
2215
  oktest -sq run_all.rb
2188
2216
 
2189
2217
  ## total:100000 (pass:100000, fail:0, error:0, skip:0, todo:0) in 2.36s
2190
2218
 
2191
- {{*6.815 real*}} 6.511 user 0.257 sys
2219
+ 6.815 real 6.511 user 0.257 sys
2192
2220
 
2193
- ==================== {{*oktest:faster*}} ====================
2221
+ ==================== oktest:faster ====================
2194
2222
  oktest -sq --faster run_all.rb
2195
2223
 
2196
2224
  ## total:100000 (pass:100000, fail:0, error:0, skip:0, todo:0) in 2.01s
2197
2225
 
2198
- {{*6.401 real*}} 6.123 user 0.240 sys
2226
+ 6.401 real 6.123 user 0.240 sys
2199
2227
 
2200
- ==================== {{*rspec*}} ====================
2228
+ ==================== rspec ====================
2201
2229
  rspec run_all.rb | tail -4
2202
2230
 
2203
2231
  Finished in 15.27 seconds (files took 16.08 seconds to load)
2204
2232
  100000 examples, 0 failures
2205
2233
 
2206
2234
 
2207
- {{*32.062 real*}} 27.778 user 4.383 sys
2235
+ 32.062 real 27.778 user 4.383 sys
2208
2236
 
2209
- ==================== {{*minitest*}} ====================
2237
+ ==================== minitest ====================
2210
2238
  ruby run_all.rb | tail -4
2211
2239
 
2212
2240
  Finished in 5.281425s, 18934.2838 runs/s, 37868.5677 assertions/s.
2213
2241
 
2214
2242
  100000 runs, 200000 assertions, 0 failures, 0 errors, 0 skips
2215
2243
 
2216
- {{*9.140 real*}} 8.657 user 0.705 sys
2244
+ 9.140 real 8.657 user 0.705 sys
2217
2245
 
2218
- ==================== {{*testunit*}} ====================
2246
+ ==================== testunit ====================
2219
2247
  ruby run_all.rb | tail -5
2220
2248
  -------------------------------------------------------------------------------
2221
2249
  100000 tests, 200000 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
@@ -2223,34 +2251,7 @@ ruby run_all.rb | tail -5
2223
2251
  -------------------------------------------------------------------------------
2224
2252
  7775.59 tests/s, 15551.18 assertions/s
2225
2253
 
2226
- {{*19.580 real*}} 19.020 user 0.885 sys
2227
- ```
2228
-
2229
- Summary:
2230
-
2231
- ```
2232
- Oktest: 6.815 real 6.511 user 0.257 sys
2233
- Oktest (--fast): 6.401 real 6.123 user 0.240 sys
2234
- RSpec: 32.062 real 27.778 user 4.383 sys
2235
- MiniTest: 9.140 real 8.657 user 0.705 sys
2236
- Test::Unit: 19.580 real 19.020 user 0.885 sys
2237
- ```
2238
-
2239
-
2240
- ### `--faster` Option
2241
-
2242
- If you are working in very larget project and you want to run test scripts
2243
- as fast as possible, try `--faster` option of `oktest` command.
2244
-
2245
- ```terminal
2246
- $ oktest -s quiet --faster test/ ## only for very large project
2247
- ```
2248
-
2249
- Or set `Oktest::Config.ok_location = false` in your test script.
2250
-
2251
- ```ruby
2252
- require 'oktest'
2253
- Oktest::Config.ok_location = false ## only for very large project
2254
+ 19.580 real 19.020 user 0.885 sys
2254
2255
  ```
2255
2256
 
2256
2257
 
data/Rakefile.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
  ###
4
- ### $Release: 1.2.0 $
4
+ ### $Release: 1.2.1 $
5
5
  ### $Copyright: copyright(c) 2011-2021 kuwata-lab.com all rights reserved $
6
6
  ### $License: MIT License $
7
7
  ###
data/lib/oktest.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
  ###
4
- ### $Release: 1.2.0 $
4
+ ### $Release: 1.2.1 $
5
5
  ### $Copyright: copyright(c) 2011-2021 kuwata-lab.com all rights reserved $
6
6
  ### $License: MIT License $
7
7
  ###
@@ -12,7 +12,7 @@ require 'set'
12
12
  module Oktest
13
13
 
14
14
 
15
- VERSION = '$Release: 1.2.0 $'.split()[1]
15
+ VERSION = '$Release: 1.2.1 $'.split()[1]
16
16
 
17
17
 
18
18
  class OktestError < StandardError
@@ -1077,7 +1077,7 @@ END
1077
1077
  end
1078
1078
 
1079
1079
  attr_reader :target
1080
- attr_accessor :_prefix
1080
+ attr_writer :_prefix
1081
1081
 
1082
1082
  def _prefix
1083
1083
  @_prefix || '*'
@@ -1229,7 +1229,7 @@ END
1229
1229
  raise SkipException, reason if condition
1230
1230
  end
1231
1231
 
1232
- def fixture(name, *args)
1232
+ def fixture(name, *args, **kwargs)
1233
1233
  #; [!zgfg9] finds fixture block in current or parent node.
1234
1234
  node = self.class.__node
1235
1235
  while node && (tuple = node.get_fixture_block(name)) == nil
@@ -1244,7 +1244,7 @@ END
1244
1244
  #; [!m4ava] calls fixture block and returns result of it.
1245
1245
  #; [!l2mcx] accepts block arguments.
1246
1246
  block, _, _ = tuple
1247
- return block.call(*args)
1247
+ return block.call(*args, **kwargs)
1248
1248
  end
1249
1249
 
1250
1250
  def TODO()
@@ -1913,6 +1913,12 @@ END
1913
1913
  puts "## #{scope.filename}"
1914
1914
  end
1915
1915
 
1916
+ def exit_scope(scope)
1917
+ #; [!ibdu7] reports errors even when no topics.
1918
+ super
1919
+ print_exceptions()
1920
+ end
1921
+
1916
1922
  def enter_topic(topic, depth)
1917
1923
  super
1918
1924
  puts "#{' ' * (depth - 1)}#{topic._prefix} #{Color.topic(topic.target)}"
data/oktest.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
  ###
4
- ### $Release: 1.2.0 $
4
+ ### $Release: 1.2.1 $
5
5
  ### $License: MIT License $
6
6
  ### $Copyright: copyright(c) 2011-2021 kuwata-lab.com all rights reserved $
7
7
  ###
@@ -13,7 +13,7 @@ Gem::Specification.new do |s|
13
13
  s.name = "oktest"
14
14
  s.author = "kwatch"
15
15
  s.email = "kwatch@gmail.com"
16
- s.version = "$Release: 1.2.0 $".split()[1]
16
+ s.version = "$Release: 1.2.1 $".split()[1]
17
17
  s.license = "MIT"
18
18
  s.platform = Gem::Platform::RUBY
19
19
  s.homepage = "https://github.com/kwatch/oktest/tree/ruby"
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
  ###
4
- ### $Release: 1.2.0 $
4
+ ### $Release: 1.2.1 $
5
5
  ### $Copyright: copyright(c) 2011-2021 kuwata-lab.com all rights reserved $
6
6
  ### $License: MIT License $
7
7
  ###
data/test/filter_test.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
  ###
4
- ### $Release: 1.2.0 $
4
+ ### $Release: 1.2.1 $
5
5
  ### $Copyright: copyright(c) 2011-2021 kuwata-lab.com all rights reserved $
6
6
  ### $License: MIT License $
7
7
  ###
data/test/fixture_test.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
  ###
4
- ### $Release: 1.2.0 $
4
+ ### $Release: 1.2.1 $
5
5
  ### $Copyright: copyright(c) 2011-2021 kuwata-lab.com all rights reserved $
6
6
  ### $License: MIT License $
7
7
  ###
@@ -1,5 +1,5 @@
1
1
  ###
2
- ### $Release: 1.2.0 $
2
+ ### $Release: 1.2.1 $
3
3
  ### $Copyright: copyright(c) 2011-2021 kuwata-lab.com all rights reserved $
4
4
  ### $License: MIT License $
5
5
  ###
data/test/helper_test.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  ###
2
- ### $Release: 1.2.0 $
2
+ ### $Release: 1.2.1 $
3
3
  ### $Copyright: copyright(c) 2011-2021 kuwata-lab.com all rights reserved $
4
4
  ### $License: MIT License $
5
5
  ###
@@ -129,17 +129,17 @@ class SpecHelper_TC < TC
129
129
  it "[!l2mcx] accepts block arguments." do
130
130
  val = nil
131
131
  Oktest.scope() do
132
- fixture :foo do |x, y|
133
- {x: x, y: y}
132
+ fixture :foo do |x, y, z: 0|
133
+ {x: x, y: y, z: z}
134
134
  end
135
135
  topic 'Example' do
136
136
  spec 'sample' do
137
- val = fixture(:foo, 10, 20)
137
+ val = fixture(:foo, 10, 20, z: 30)
138
138
  end
139
139
  end
140
140
  end
141
141
  capture { Oktest.run() }
142
- assert_eq val, {x: 10, y: 20}
142
+ assert_eq val, {x: 10, y: 20, z: 30}
143
143
  end
144
144
  it "[!wxcsp] raises error when fixture not found." do
145
145
  exc = nil
data/test/initialize.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
  ###
4
- ### $Release: 1.2.0 $
4
+ ### $Release: 1.2.1 $
5
5
  ### $Copyright: copyright(c) 2011-2021 kuwata-lab.com all rights reserved $
6
6
  ### $License: MIT License $
7
7
  ###
data/test/mainapp_test.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  ###
2
- ### $Release: 1.2.0 $
2
+ ### $Release: 1.2.1 $
3
3
  ### $Copyright: copyright(c) 2011-2021 kuwata-lab.com all rights reserved $
4
4
  ### $License: MIT License $
5
5
  ###
@@ -257,7 +257,7 @@ END
257
257
  end
258
258
 
259
259
  it "[!qqizl] '--version' option prints version number." do
260
- expected = '$Release: 1.2.0 $'.split()[1] + "\n"
260
+ expected = '$Release: 1.2.1 $'.split()[1] + "\n"
261
261
  #
262
262
  ret, sout, serr = run("--version")
263
263
  assert_eq ret, 0
data/test/matcher_test.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
  ###
4
- ### $Release: 1.2.0 $
4
+ ### $Release: 1.2.1 $
5
5
  ### $Copyright: copyright(c) 2011-2021 kuwata-lab.com all rights reserved $
6
6
  ### $License: MIT License $
7
7
  ###
data/test/misc_test.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
  ###
4
- ### $Release: 1.2.0 $
4
+ ### $Release: 1.2.1 $
5
5
  ### $Copyright: copyright(c) 2011-2021 kuwata-lab.com all rights reserved $
6
6
  ### $License: MIT License $
7
7
  ###
data/test/node_test.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
  ###
4
- ### $Release: 1.2.0 $
4
+ ### $Release: 1.2.1 $
5
5
  ### $Copyright: copyright(c) 2011-2021 kuwata-lab.com all rights reserved $
6
6
  ### $License: MIT License $
7
7
  ###
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
  ###
4
- ### $Release: 1.2.0 $
4
+ ### $Release: 1.2.1 $
5
5
  ### $Copyright: copyright(c) 2011-2021 kuwata-lab.com all rights reserved $
6
6
  ### $License: MIT License $
7
7
  ###
@@ -527,6 +527,37 @@ class VerboseReporter_TC < Reporter_TC
527
527
  assert_eq serr, ""
528
528
  end
529
529
 
530
+ it "[!ibdu7] reports errors even when no topics." do
531
+ input = <<'END'
532
+ require 'oktest'
533
+ Oktest.scope do
534
+ spec "example" do
535
+ ok {1-1} == 2
536
+ end
537
+ end
538
+ END
539
+ File.write(@filename, input)
540
+ #
541
+ expected = <<'END'
542
+ ## _test.tmp
543
+ - [<R>Fail</R>] example
544
+ ----------------------------------------------------------------------
545
+ [<R>Fail</R>] <b>example</b>
546
+ _test.tmp:4:in `block (2 levels) in <top (required)>'
547
+ ok {1-1} == 2
548
+ %%%
549
+ <R>$<actual> == $<expected>: failed.</R>
550
+ $<actual>: 0
551
+ $<expected>: 2
552
+ ----------------------------------------------------------------------
553
+ ## total:1 (pass:0, <R>fail:1</R>, error:0, skip:0, todo:0) in 0.000s
554
+ END
555
+ #
556
+ sout, serr = run("-sv", @filename)
557
+ assert_eq edit_actual(sout), edit_expected(expected)
558
+ assert_eq serr, ""
559
+ end
560
+
530
561
  end
531
562
 
532
563
 
data/test/runner_test.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
  ###
4
- ### $Release: 1.2.0 $
4
+ ### $Release: 1.2.1 $
5
5
  ### $Copyright: copyright(c) 2011-2021 kuwata-lab.com all rights reserved $
6
6
  ### $License: MIT License $
7
7
  ###
data/test/util_test.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
  ###
4
- ### $Release: 1.2.0 $
4
+ ### $Release: 1.2.1 $
5
5
  ### $Copyright: copyright(c) 2011-2021 kuwata-lab.com all rights reserved $
6
6
  ### $License: MIT License $
7
7
  ###
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
  ###
4
- ### $Release: 1.2.0 $
4
+ ### $Release: 1.2.1 $
5
5
  ### $Copyright: copyright(c) 2011-2021 kuwata-lab.com all rights reserved $
6
6
  ### $License: MIT License $
7
7
  ###
data/test/visitor_test.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
  ###
4
- ### $Release: 1.2.0 $
4
+ ### $Release: 1.2.1 $
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.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - kwatch
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-17 00:00:00.000000000 Z
11
+ date: 2021-11-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: diff-lcs