oktest 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/MIT-LICENSE +1 -1
- data/README.md +54 -48
- data/Rakefile.rb +4 -4
- data/lib/oktest.rb +49 -16
- data/oktest.gemspec +3 -3
- data/test/assertion_test.rb +105 -10
- data/test/filter_test.rb +2 -2
- data/test/fixture_test.rb +2 -2
- data/test/generator_test.rb +2 -2
- data/test/helper_test.rb +6 -6
- data/test/initialize.rb +2 -2
- data/test/mainapp_test.rb +3 -3
- data/test/matcher_test.rb +2 -2
- data/test/misc_test.rb +2 -2
- data/test/node_test.rb +2 -2
- data/test/reporter_test.rb +33 -2
- data/test/runner_test.rb +36 -2
- data/test/tc.rb +2 -2
- data/test/util_test.rb +2 -2
- data/test/utilhelper_test.rb +2 -2
- data/test/visitor_test.rb +2 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 65c65e47a706541792e7ba1e9705dc03af1c2fe46c87141472659fb811463e76
|
4
|
+
data.tar.gz: c405d466c9b63eb3897754716d220f884af655cceba5cc7c644e742caf22b465
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 496909751ed5b3035d07091c0dc362af3586e85e144177603f15035e178fa5f1d9e31c70bd1da7c60059efd8c3275c781e5876af45ac144f4d56fccf444fea20
|
7
|
+
data.tar.gz: e7d440c6dcdbccefe33e99be638dc0f70aae187ee49f0fc091ea631f55e93da822b22804bfa57d570bf9190440c248783564724fa7998df4b0e9b0a6eb0f7ed3
|
data/MIT-LICENSE
CHANGED
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
|
|
@@ -817,10 +817,15 @@ ok {pr}.raise?(NoMethodError) {|exc|
|
|
817
817
|
ok {exc.class} == NoMethodError
|
818
818
|
ok {exc.message} == "undefined method `len' for \"abc\":String"
|
819
819
|
}
|
820
|
+
## or (Oktest.rb >= 1.3)
|
821
|
+
exc = ok {pr}.raise?(NoMethodError)
|
822
|
+
ok {exc.class} == NoMethodError
|
823
|
+
ok {exc.message} == "undefined method `len' for \"abc\":String"
|
820
824
|
|
821
825
|
## assert that procedure does NOT raise any exception
|
822
|
-
ok {pr}.
|
823
|
-
|
826
|
+
ok {pr}.raise_nothing? # (>= Oktest 1.3)
|
827
|
+
ok {pr}.NOT.raise? # no exception class nor error message
|
828
|
+
not_ok {pr}.raise? # same as above
|
824
829
|
|
825
830
|
## assert that procedure throws symbol.
|
826
831
|
pr2 = proc do
|
@@ -829,8 +834,8 @@ end
|
|
829
834
|
ok {pr2}.throw?(:quit) # pass if :quit thrown, fail if other or nothing thrown
|
830
835
|
```
|
831
836
|
|
832
|
-
If procedure contains `raise "errmsg"` instead of `raise ErrorClass, "errmsg"`,
|
833
|
-
you can omit exception class
|
837
|
+
If a procedure contains `raise "errmsg"` instead of `raise ErrorClass, "errmsg"`,
|
838
|
+
you can omit exception class like `ok {pr}.raise?("errmsg")`.
|
834
839
|
|
835
840
|
<!--
|
836
841
|
test/example14b_test.rb:
|
@@ -939,7 +944,7 @@ require 'oktest'
|
|
939
944
|
|
940
945
|
Oktest::AssertionObject.class_eval do
|
941
946
|
def readable? # custom assertion: file readable?
|
942
|
-
|
947
|
+
__done()
|
943
948
|
result = File.readable?(@actual)
|
944
949
|
__assert(result == @bool) {
|
945
950
|
"File.readable?($<actual>) == #{@bool}: failed.\n" +
|
@@ -1010,15 +1015,15 @@ end
|
|
1010
1015
|
Result:
|
1011
1016
|
|
1012
1017
|
```terminal
|
1013
|
-
$ oktest -s
|
1018
|
+
$ oktest -s quiet test/example21a_test.rb
|
1014
1019
|
*** before_all() ***
|
1015
1020
|
=== before() ===
|
1016
1021
|
---- example spec #1 ----
|
1017
1022
|
=== after() ===
|
1018
|
-
|
1023
|
+
=== before() ===
|
1019
1024
|
---- example spec #2 ----
|
1020
1025
|
=== after() ===
|
1021
|
-
|
1026
|
+
*** after_all() ***
|
1022
1027
|
|
1023
1028
|
## total:2 (pass:2, fail:0, error:0, skip:0, todo:0) in 0.000s
|
1024
1029
|
```
|
@@ -1729,7 +1734,7 @@ END
|
|
1729
1734
|
If you want to change embed mark, specify 4th argument, like this:
|
1730
1735
|
|
1731
1736
|
```ruby
|
1732
|
-
partial_regexp <<-'END', '\A', '\z', '%%
|
1737
|
+
partial_regexp <<-'END', '\A', '\z', '%% %%' # !!!!!
|
1733
1738
|
* [config.date] %% \d\d\d\d-\d\d-\d\d %%
|
1734
1739
|
* [config.secret] %% [0-9a-f]+ %%
|
1735
1740
|
END
|
@@ -2160,6 +2165,24 @@ $ ruby test/example54_test.rb
|
|
2160
2165
|
```
|
2161
2166
|
|
2162
2167
|
|
2168
|
+
### `--faster` Option
|
2169
|
+
|
2170
|
+
~~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.~~
|
2171
|
+
|
2172
|
+
```terminal
|
2173
|
+
$ oktest -s quiet --faster test/ ## only for very large project
|
2174
|
+
```
|
2175
|
+
|
2176
|
+
~~Or set `Oktest::Config.ok_location = false` in your test script.~~
|
2177
|
+
|
2178
|
+
```ruby
|
2179
|
+
require 'oktest'
|
2180
|
+
Oktest::Config.ok_location = false ## only for very large project
|
2181
|
+
```
|
2182
|
+
|
2183
|
+
`--faster` option is still available but no longer recommended, because performance of `ok{}` is improved significantly since Oktest.rb 1.2.0.
|
2184
|
+
|
2185
|
+
|
2163
2186
|
### Benchmarks
|
2164
2187
|
|
2165
2188
|
Oktest.rb gem file contains benchmark script.
|
@@ -2180,42 +2203,52 @@ ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [x86_64-darwin18]
|
|
2180
2203
|
$ rake benchmark:all
|
2181
2204
|
```
|
2182
2205
|
|
2206
|
+
Summary of example result:
|
2207
|
+
|
2208
|
+
```
|
2209
|
+
Oktest: 6.815 real 6.511 user 0.257 sys
|
2210
|
+
Oktest (--faster): 6.401 real 6.123 user 0.240 sys
|
2211
|
+
RSpec: 32.062 real 27.778 user 4.383 sys
|
2212
|
+
MiniTest: 9.140 real 8.657 user 0.705 sys
|
2213
|
+
Test::Unit: 19.580 real 19.020 user 0.885 sys
|
2214
|
+
```
|
2215
|
+
|
2183
2216
|
Example result:
|
2184
2217
|
|
2185
2218
|
```
|
2186
|
-
====================
|
2219
|
+
==================== oktest ====================
|
2187
2220
|
oktest -sq run_all.rb
|
2188
2221
|
|
2189
2222
|
## total:100000 (pass:100000, fail:0, error:0, skip:0, todo:0) in 2.36s
|
2190
2223
|
|
2191
|
-
|
2224
|
+
6.815 real 6.511 user 0.257 sys
|
2192
2225
|
|
2193
|
-
====================
|
2226
|
+
==================== oktest:faster ====================
|
2194
2227
|
oktest -sq --faster run_all.rb
|
2195
2228
|
|
2196
2229
|
## total:100000 (pass:100000, fail:0, error:0, skip:0, todo:0) in 2.01s
|
2197
2230
|
|
2198
|
-
|
2231
|
+
6.401 real 6.123 user 0.240 sys
|
2199
2232
|
|
2200
|
-
====================
|
2233
|
+
==================== rspec ====================
|
2201
2234
|
rspec run_all.rb | tail -4
|
2202
2235
|
|
2203
2236
|
Finished in 15.27 seconds (files took 16.08 seconds to load)
|
2204
2237
|
100000 examples, 0 failures
|
2205
2238
|
|
2206
2239
|
|
2207
|
-
|
2240
|
+
32.062 real 27.778 user 4.383 sys
|
2208
2241
|
|
2209
|
-
====================
|
2242
|
+
==================== minitest ====================
|
2210
2243
|
ruby run_all.rb | tail -4
|
2211
2244
|
|
2212
2245
|
Finished in 5.281425s, 18934.2838 runs/s, 37868.5677 assertions/s.
|
2213
2246
|
|
2214
2247
|
100000 runs, 200000 assertions, 0 failures, 0 errors, 0 skips
|
2215
2248
|
|
2216
|
-
|
2249
|
+
9.140 real 8.657 user 0.705 sys
|
2217
2250
|
|
2218
|
-
====================
|
2251
|
+
==================== testunit ====================
|
2219
2252
|
ruby run_all.rb | tail -5
|
2220
2253
|
-------------------------------------------------------------------------------
|
2221
2254
|
100000 tests, 200000 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
|
@@ -2223,34 +2256,7 @@ ruby run_all.rb | tail -5
|
|
2223
2256
|
-------------------------------------------------------------------------------
|
2224
2257
|
7775.59 tests/s, 15551.18 assertions/s
|
2225
2258
|
|
2226
|
-
|
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
|
2259
|
+
19.580 real 19.020 user 0.885 sys
|
2254
2260
|
```
|
2255
2261
|
|
2256
2262
|
|
@@ -2264,4 +2270,4 @@ See [CHANGES.md](https://github.com/kwatch/oktest/blob/ruby/ruby/CHANGES.md).
|
|
2264
2270
|
## License and Copyright
|
2265
2271
|
|
2266
2272
|
* $License: MIT License $
|
2267
|
-
* $Copyright: copyright(c) 2011-
|
2273
|
+
* $Copyright: copyright(c) 2011-2024 kuwata-lab.com all rights reserved $
|
data/Rakefile.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
|
3
3
|
###
|
4
|
-
### $Release: 1.
|
5
|
-
### $Copyright: copyright(c) 2011-
|
4
|
+
### $Release: 1.3.0 $
|
5
|
+
### $Copyright: copyright(c) 2011-2024 kuwata-lab.com all rights reserved $
|
6
6
|
### $License: MIT License $
|
7
7
|
###
|
8
8
|
|
9
9
|
PROJECT = "oktest"
|
10
10
|
RELEASE = ENV['RELEASE'] || "0.0.0"
|
11
|
-
COPYRIGHT = "copyright(c) 2011-
|
11
|
+
COPYRIGHT = "copyright(c) 2011-2024 kuwata-lab.com all rights reserved"
|
12
12
|
LICENSE = "MIT License"
|
13
13
|
|
14
|
-
$ruby_versions ||= %w[2.4 2.5 2.6 2.7 3.0]
|
14
|
+
$ruby_versions ||= %w[2.4 2.5 2.6 2.7 3.0 3.1 3.2 3.3]
|
15
15
|
|
16
16
|
desc "show release guide"
|
17
17
|
task :guide do
|
data/lib/oktest.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
|
3
3
|
###
|
4
|
-
### $Release: 1.
|
5
|
-
### $Copyright: copyright(c) 2011-
|
4
|
+
### $Release: 1.3.0 $
|
5
|
+
### $Copyright: copyright(c) 2011-2024 kuwata-lab.com all rights reserved $
|
6
6
|
### $License: MIT License $
|
7
7
|
###
|
8
8
|
|
@@ -12,7 +12,7 @@ require 'set'
|
|
12
12
|
module Oktest
|
13
13
|
|
14
14
|
|
15
|
-
VERSION = '$Release: 1.
|
15
|
+
VERSION = '$Release: 1.3.0 $'.split()[1]
|
16
16
|
|
17
17
|
|
18
18
|
class OktestError < StandardError
|
@@ -236,14 +236,29 @@ module Oktest
|
|
236
236
|
self
|
237
237
|
end
|
238
238
|
|
239
|
-
|
239
|
+
if RUBY_VERSION >= "2.7"
|
240
|
+
def method_missing(method_name, *args, **kwargs, &b)
|
241
|
+
#; [!ttow6] raises NoMethodError when not a boolean method.
|
242
|
+
return super unless method_name.to_s =~ /\?\z/
|
243
|
+
#; [!gd3vg] supports keyword arguments on Ruby >= 2.7.
|
244
|
+
__method_missing(method_name, args, kwargs) {
|
245
|
+
@actual.__send__(method_name, *args, **kwargs, &b)
|
246
|
+
}
|
247
|
+
end
|
248
|
+
else
|
249
|
+
def method_missing(method_name, *args, &b)
|
250
|
+
return super unless method_name.to_s =~ /\?\z/
|
251
|
+
__method_missing(method_name, args, nil) {
|
252
|
+
@actual.__send__(method_name, *args, &b)
|
253
|
+
}
|
254
|
+
end
|
255
|
+
end
|
256
|
+
|
257
|
+
def __method_missing(method_name, args, kwargs)
|
240
258
|
__done()
|
241
259
|
#; [!yjnxb] enables to handle boolean methods.
|
242
|
-
#; [!ttow6] raises NoMethodError when not a boolean method.
|
243
|
-
method_name.to_s =~ /\?\z/ or
|
244
|
-
super
|
245
260
|
begin
|
246
|
-
ret =
|
261
|
+
ret = yield
|
247
262
|
rescue NoMethodError, TypeError => exc
|
248
263
|
#; [!f0ekh] skip top of backtrace when NoMethodError raised.
|
249
264
|
while !exc.backtrace.empty? && exc.backtrace[0].start_with?(__FILE__)
|
@@ -254,10 +269,11 @@ module Oktest
|
|
254
269
|
#; [!cun59] fails when boolean method failed returned false.
|
255
270
|
#; [!4objh] is available with NOT.
|
256
271
|
if ret == true || ret == false
|
272
|
+
#; [!5y9iu] reports args and kwargs in error message.
|
273
|
+
s = __inspect_args_and_kwargs(args, kwargs)
|
257
274
|
__assert(@bool == ret) {
|
258
|
-
args = args.empty? ? '' : "(#{args.collect {|x| x.inspect }.join(', ')})"
|
259
275
|
eq = @bool ? '' : ' == false'
|
260
|
-
"$<actual>.#{method_name}#{
|
276
|
+
"$<actual>.#{method_name}#{s}#{eq}: failed.\n"\
|
261
277
|
" $<actual>: #{@actual.inspect}"
|
262
278
|
}
|
263
279
|
#; [!sljta] raises TypeError when boolean method returned non-boolean value.
|
@@ -267,6 +283,17 @@ module Oktest
|
|
267
283
|
#; [!7bbrv] returns self when passed.
|
268
284
|
self
|
269
285
|
end
|
286
|
+
private :__method_missing
|
287
|
+
|
288
|
+
def __inspect_args_and_kwargs(args, kwargs)
|
289
|
+
kwargs ||= {}
|
290
|
+
arr = [
|
291
|
+
(args.empty? ? nil : args.collect {|x| x.inspect}),
|
292
|
+
(kwargs.empty? ? nil : kwargs.collect {|k, v| "#{k}: #{v.inspect}" }),
|
293
|
+
].compact.flatten
|
294
|
+
return arr.empty? ? "" : "(#{arr.join(', ')})"
|
295
|
+
end
|
296
|
+
private :__inspect_args_and_kwargs
|
270
297
|
|
271
298
|
def raise!(errcls=nil, errmsg=nil, &b)
|
272
299
|
#; [!8k6ee] compares error class by '.is_a?' instead of '=='.
|
@@ -349,8 +376,8 @@ module Oktest
|
|
349
376
|
#; [!vnc6b] sets exception object into '#exc' attribute.
|
350
377
|
(class << proc_obj; self; end).class_eval { attr_accessor :exc }
|
351
378
|
proc_obj.exc = exc
|
352
|
-
#; [!y1b28] returns
|
353
|
-
|
379
|
+
#; [!y1b28] returns exception object.
|
380
|
+
return exc
|
354
381
|
end
|
355
382
|
|
356
383
|
def throw?(expected)
|
@@ -1077,7 +1104,7 @@ END
|
|
1077
1104
|
end
|
1078
1105
|
|
1079
1106
|
attr_reader :target
|
1080
|
-
|
1107
|
+
attr_writer :_prefix
|
1081
1108
|
|
1082
1109
|
def _prefix
|
1083
1110
|
@_prefix || '*'
|
@@ -1229,7 +1256,7 @@ END
|
|
1229
1256
|
raise SkipException, reason if condition
|
1230
1257
|
end
|
1231
1258
|
|
1232
|
-
def fixture(name, *args)
|
1259
|
+
def fixture(name, *args, **kwargs)
|
1233
1260
|
#; [!zgfg9] finds fixture block in current or parent node.
|
1234
1261
|
node = self.class.__node
|
1235
1262
|
while node && (tuple = node.get_fixture_block(name)) == nil
|
@@ -1244,7 +1271,7 @@ END
|
|
1244
1271
|
#; [!m4ava] calls fixture block and returns result of it.
|
1245
1272
|
#; [!l2mcx] accepts block arguments.
|
1246
1273
|
block, _, _ = tuple
|
1247
|
-
return block.call(*args)
|
1274
|
+
return block.call(*args, **kwargs)
|
1248
1275
|
end
|
1249
1276
|
|
1250
1277
|
def TODO()
|
@@ -1913,6 +1940,12 @@ END
|
|
1913
1940
|
puts "## #{scope.filename}"
|
1914
1941
|
end
|
1915
1942
|
|
1943
|
+
def exit_scope(scope)
|
1944
|
+
#; [!ibdu7] reports errors even when no topics.
|
1945
|
+
super
|
1946
|
+
print_exceptions()
|
1947
|
+
end
|
1948
|
+
|
1916
1949
|
def enter_topic(topic, depth)
|
1917
1950
|
super
|
1918
1951
|
puts "#{' ' * (depth - 1)}#{topic._prefix} #{Color.topic(topic.target)}"
|
@@ -2304,7 +2337,7 @@ END
|
|
2304
2337
|
@os_windows = RUBY_PLATFORM =~ /mswin|mingw/i
|
2305
2338
|
@auto_run = true
|
2306
2339
|
@ok_location = true # false will make 'ok()' faster
|
2307
|
-
@color_available = ! @os_windows || ENV['COLORTERM'] =~ /color|24bit/i
|
2340
|
+
@color_available = ! @os_windows || ENV['WT_SESSION'] || ENV['COLORTERM'] =~ /color|24bit/i
|
2308
2341
|
@color_enabled = @color_available && $stdout.tty?
|
2309
2342
|
@diff_command = @os_windows ? "diff.exe -u" : "diff -u"
|
2310
2343
|
|
data/oktest.gemspec
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
|
3
3
|
###
|
4
|
-
### $Release: 1.
|
4
|
+
### $Release: 1.3.0 $
|
5
5
|
### $License: MIT License $
|
6
|
-
### $Copyright: copyright(c) 2011-
|
6
|
+
### $Copyright: copyright(c) 2011-2024 kuwata-lab.com all rights reserved $
|
7
7
|
###
|
8
8
|
|
9
9
|
require 'rubygems'
|
@@ -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.
|
16
|
+
s.version = "$Release: 1.3.0 $".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"
|
data/test/assertion_test.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
|
3
3
|
###
|
4
|
-
### $Release: 1.
|
5
|
-
### $Copyright: copyright(c) 2011-
|
4
|
+
### $Release: 1.3.0 $
|
5
|
+
### $Copyright: copyright(c) 2011-2024 kuwata-lab.com all rights reserved $
|
6
6
|
### $License: MIT License $
|
7
7
|
###
|
8
8
|
|
@@ -351,7 +351,7 @@ END
|
|
351
351
|
end
|
352
352
|
end
|
353
353
|
|
354
|
-
describe '#method_missing()' do
|
354
|
+
describe '#method_missing()' do
|
355
355
|
it "[!7bbrv] returns self when passed." do
|
356
356
|
should_return_self { ok {"file.png"}.end_with?(".png") }
|
357
357
|
end
|
@@ -365,6 +365,27 @@ describe '#method_missing()' do
|
|
365
365
|
ok {"a"}.start_with
|
366
366
|
end
|
367
367
|
end
|
368
|
+
it "[!gd3vg] supports keyword arguments on Ruby >= 2.7." do
|
369
|
+
#if RUBY_VERSION >= "2.7"
|
370
|
+
if true
|
371
|
+
eval <<-END
|
372
|
+
class Dummy392
|
373
|
+
def foo?(a, b, c: nil, d: nil)
|
374
|
+
return true
|
375
|
+
end
|
376
|
+
end
|
377
|
+
END
|
378
|
+
PASS! { ok {Dummy392.new}.foo?(123, 'abc', c: 45, d: true) }
|
379
|
+
if RUBY_VERSION >= "2.7"
|
380
|
+
errmsg = "unknown keywords: :x, :y"
|
381
|
+
else
|
382
|
+
errmsg = "unknown keywords: x, y"
|
383
|
+
end
|
384
|
+
ERROR!(ArgumentError, errmsg) do
|
385
|
+
ok {Dummy392.new}.foo?(123, 'abc', x: 45, y: true)
|
386
|
+
end
|
387
|
+
end
|
388
|
+
end
|
368
389
|
it "[!f0ekh] skip top of backtrace when NoMethodError raised." do
|
369
390
|
exc = ERROR!(NoMethodError) do
|
370
391
|
ok {[1]}.start_with?(1)
|
@@ -399,12 +420,45 @@ describe '#method_missing()' do
|
|
399
420
|
ok {s}.sos?
|
400
421
|
end
|
401
422
|
end
|
423
|
+
it "[!5y9iu] reports args and kwargs in error message." do
|
424
|
+
if RUBY_VERSION >= "2.7"
|
425
|
+
str = '123, "abc", x: "45", y: true'
|
426
|
+
else
|
427
|
+
str = '123, "abc", {:x=>"45", :y=>true}'
|
428
|
+
end
|
429
|
+
errmsg = "$<actual>.bla?(#{str}): failed.\n"\
|
430
|
+
" $<actual>: \"Blabla\""
|
431
|
+
FAIL!(errmsg) do
|
432
|
+
s = "Blabla"
|
433
|
+
def s.bla?(*a, **k); return false; end
|
434
|
+
ok {s}.bla?(123, "abc", x: "45", y: true)
|
435
|
+
end
|
436
|
+
#
|
437
|
+
obj = Oktest::AssertionObject.new(nil, true, nil)
|
438
|
+
expected = '(123, "abc", c: "45", d: true)'
|
439
|
+
actual = obj.instance_eval {
|
440
|
+
__inspect_args_and_kwargs([123, "abc"], c: "45", d: true)
|
441
|
+
}
|
442
|
+
assert_eq actual, expected
|
443
|
+
end
|
402
444
|
end
|
403
445
|
|
404
446
|
describe '#raise?' do
|
405
|
-
it "[!y1b28] returns
|
447
|
+
it "[!y1b28] returns exception object." do
|
406
448
|
pr = proc { "SOS".sos }
|
407
|
-
|
449
|
+
if RUBY_VERSION >= "3.3"
|
450
|
+
expected = "undefined method `sos' for an instance of String"
|
451
|
+
elsif RUBY_VERSION =~ /^3\.1\./
|
452
|
+
expected = "undefined method `sos' for \"SOS\":String\n"\
|
453
|
+
"\n"\
|
454
|
+
" pr = proc { \"SOS\".sos }\n"\
|
455
|
+
" ^^^^"
|
456
|
+
else
|
457
|
+
expected = "undefined method `sos' for \"SOS\":String"
|
458
|
+
end
|
459
|
+
ret = ok {pr}.raise?(NoMethodError, expected)
|
460
|
+
assert_eq ret.class, NoMethodError
|
461
|
+
assert_eq ret.message, expected
|
408
462
|
end
|
409
463
|
it "[!2rnni] 1st argument can be error message string or rexp." do
|
410
464
|
pr = proc { raise "something wrong" }
|
@@ -440,14 +494,36 @@ describe '#method_missing()' do
|
|
440
494
|
end
|
441
495
|
it "[!4n3ed] reraises if exception is not matched to specified error class." do
|
442
496
|
pr = proc { "SOS".sos }
|
443
|
-
|
497
|
+
if RUBY_VERSION >= "3.3"
|
498
|
+
errmsg = "undefined method `sos' for an instance of String"
|
499
|
+
elsif RUBY_VERSION =~ /^3\.1\./
|
500
|
+
errmsg = "undefined method `sos' for \"SOS\":String\n"\
|
501
|
+
"\n"\
|
502
|
+
" pr = proc { \"SOS\".sos }\n"\
|
503
|
+
" ^^^^"
|
504
|
+
else
|
505
|
+
errmsg = "undefined method `sos' for \"SOS\":String"
|
506
|
+
end
|
444
507
|
ERROR!(NoMethodError, errmsg) { ok {pr}.raise?(ArgumentError) }
|
445
508
|
end
|
446
509
|
it "[!tpxlv] accepts string or regexp as error message." do
|
510
|
+
if RUBY_VERSION >= "3.1"
|
511
|
+
expected = "undefined method `sos' for \"SOS\":String\n"\
|
512
|
+
"\n"\
|
513
|
+
" pr = proc { \"SOS\".sos }\n"\
|
514
|
+
" ^^^^"
|
515
|
+
else
|
516
|
+
expected = "undefined method `sos' for \"SOS\":String"
|
517
|
+
end
|
447
518
|
pr = proc { "SOS".sos }
|
448
|
-
PASS! { ok {pr}.raise?(NoMethodError,
|
519
|
+
PASS! { ok {pr}.raise?(NoMethodError, ) }
|
449
520
|
pr = proc { "SOS".sos }
|
450
|
-
|
521
|
+
if RUBY_VERSION >= "3.3"
|
522
|
+
expected = /^undefined method `sos' for an instance of String$/
|
523
|
+
else
|
524
|
+
expected = /^undefined method `sos' for "SOS":String$/
|
525
|
+
end
|
526
|
+
PASS! { ok {pr}.raise?(NoMethodError, expected) }
|
451
527
|
end
|
452
528
|
it "[!4c6x3] not check exception class when nil specified as errcls." do
|
453
529
|
pr = proc { foobar() }
|
@@ -483,7 +559,16 @@ describe '#method_missing()' do
|
|
483
559
|
end
|
484
560
|
it "[!61vtv] assertion fails when specified exception raised." do
|
485
561
|
pr = proc { "SOS".foobar }
|
486
|
-
|
562
|
+
if RUBY_VERSION >= "3.3"
|
563
|
+
errmsg = "NoMethodError should not be raised but got #<NoMethodError: undefined method `foobar' for an instance of String>."
|
564
|
+
elsif RUBY_VERSION =~ /^3\.1\./
|
565
|
+
errmsg = "NoMethodError should not be raised but got #<NoMethodError: undefined method `foobar' for \"SOS\":String\n"\
|
566
|
+
"\n"\
|
567
|
+
" pr = proc { \"SOS\".foobar }\n"\
|
568
|
+
" ^^^^^^^>."
|
569
|
+
else
|
570
|
+
errmsg = "NoMethodError should not be raised but got #<NoMethodError: undefined method `foobar' for \"SOS\":String>."
|
571
|
+
end
|
487
572
|
FAIL!(errmsg) { ok {pr}.NOT.raise?(NoMethodError) }
|
488
573
|
end
|
489
574
|
it "[!smprc] compares error class with '==' operator, not '.is_a?'." do
|
@@ -516,7 +601,17 @@ describe '#method_missing()' do
|
|
516
601
|
PASS! { ok {pr}.raise?(NoMethodError) }
|
517
602
|
assert pr.respond_to?(:exc)
|
518
603
|
assert pr.exc.is_a?(NoMethodError)
|
519
|
-
|
604
|
+
if RUBY_VERSION >= "3.3"
|
605
|
+
errmsg = "undefined method `foobar' for an instance of String"
|
606
|
+
elsif RUBY_VERSION =~ /^3\.1\./
|
607
|
+
errmsg = "undefined method `foobar' for \"SOS\":String\n"\
|
608
|
+
"\n"\
|
609
|
+
" pr = proc { \"SOS\".foobar }\n"\
|
610
|
+
" ^^^^^^^"
|
611
|
+
else
|
612
|
+
errmsg = "undefined method `foobar' for \"SOS\":String"
|
613
|
+
end
|
614
|
+
assert_eq pr.exc.message, errmsg
|
520
615
|
#
|
521
616
|
pr = proc { nil }
|
522
617
|
assert !pr.respond_to?(:exc)
|
data/test/filter_test.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
|
3
3
|
###
|
4
|
-
### $Release: 1.
|
5
|
-
### $Copyright: copyright(c) 2011-
|
4
|
+
### $Release: 1.3.0 $
|
5
|
+
### $Copyright: copyright(c) 2011-2024 kuwata-lab.com all rights reserved $
|
6
6
|
### $License: MIT License $
|
7
7
|
###
|
8
8
|
|
data/test/fixture_test.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
|
3
3
|
###
|
4
|
-
### $Release: 1.
|
5
|
-
### $Copyright: copyright(c) 2011-
|
4
|
+
### $Release: 1.3.0 $
|
5
|
+
### $Copyright: copyright(c) 2011-2024 kuwata-lab.com all rights reserved $
|
6
6
|
### $License: MIT License $
|
7
7
|
###
|
8
8
|
|
data/test/generator_test.rb
CHANGED
data/test/helper_test.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
###
|
2
|
-
### $Release: 1.
|
3
|
-
### $Copyright: copyright(c) 2011-
|
2
|
+
### $Release: 1.3.0 $
|
3
|
+
### $Copyright: copyright(c) 2011-2024 kuwata-lab.com all rights reserved $
|
4
4
|
### $License: MIT License $
|
5
5
|
###
|
6
6
|
|
@@ -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,8 +1,8 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
|
3
3
|
###
|
4
|
-
### $Release: 1.
|
5
|
-
### $Copyright: copyright(c) 2011-
|
4
|
+
### $Release: 1.3.0 $
|
5
|
+
### $Copyright: copyright(c) 2011-2024 kuwata-lab.com all rights reserved $
|
6
6
|
### $License: MIT License $
|
7
7
|
###
|
8
8
|
|
data/test/mainapp_test.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
###
|
2
|
-
### $Release: 1.
|
3
|
-
### $Copyright: copyright(c) 2011-
|
2
|
+
### $Release: 1.3.0 $
|
3
|
+
### $Copyright: copyright(c) 2011-2024 kuwata-lab.com all rights reserved $
|
4
4
|
### $License: MIT License $
|
5
5
|
###
|
6
6
|
|
@@ -257,7 +257,7 @@ END
|
|
257
257
|
end
|
258
258
|
|
259
259
|
it "[!qqizl] '--version' option prints version number." do
|
260
|
-
expected = '$Release: 1.
|
260
|
+
expected = '$Release: 1.3.0 $'.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,8 +1,8 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
|
3
3
|
###
|
4
|
-
### $Release: 1.
|
5
|
-
### $Copyright: copyright(c) 2011-
|
4
|
+
### $Release: 1.3.0 $
|
5
|
+
### $Copyright: copyright(c) 2011-2024 kuwata-lab.com all rights reserved $
|
6
6
|
### $License: MIT License $
|
7
7
|
###
|
8
8
|
|
data/test/misc_test.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
|
3
3
|
###
|
4
|
-
### $Release: 1.
|
5
|
-
### $Copyright: copyright(c) 2011-
|
4
|
+
### $Release: 1.3.0 $
|
5
|
+
### $Copyright: copyright(c) 2011-2024 kuwata-lab.com all rights reserved $
|
6
6
|
### $License: MIT License $
|
7
7
|
###
|
8
8
|
|
data/test/node_test.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
|
3
3
|
###
|
4
|
-
### $Release: 1.
|
5
|
-
### $Copyright: copyright(c) 2011-
|
4
|
+
### $Release: 1.3.0 $
|
5
|
+
### $Copyright: copyright(c) 2011-2024 kuwata-lab.com all rights reserved $
|
6
6
|
### $License: MIT License $
|
7
7
|
###
|
8
8
|
|
data/test/reporter_test.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
|
3
3
|
###
|
4
|
-
### $Release: 1.
|
5
|
-
### $Copyright: copyright(c) 2011-
|
4
|
+
### $Release: 1.3.0 $
|
5
|
+
### $Copyright: copyright(c) 2011-2024 kuwata-lab.com all rights reserved $
|
6
6
|
### $License: MIT License $
|
7
7
|
###
|
8
8
|
|
@@ -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,8 +1,8 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
|
3
3
|
###
|
4
|
-
### $Release: 1.
|
5
|
-
### $Copyright: copyright(c) 2011-
|
4
|
+
### $Release: 1.3.0 $
|
5
|
+
### $Copyright: copyright(c) 2011-2024 kuwata-lab.com all rights reserved $
|
6
6
|
### $License: MIT License $
|
7
7
|
###
|
8
8
|
|
@@ -118,7 +118,24 @@ topic: "Parent"
|
|
118
118
|
$<actual>: 2
|
119
119
|
$<expected>: 1>
|
120
120
|
spec: "spec#3"
|
121
|
+
END
|
122
|
+
if RUBY_VERSION >= "3.3"
|
123
|
+
expected += <<'END'
|
124
|
+
/spec: status=:ERROR, error=#<NoMethodError: undefined method `null?' for an instance of String>
|
125
|
+
END
|
126
|
+
elsif RUBY_VERSION =~ /^3\.1\./
|
127
|
+
expected += <<'END'
|
128
|
+
/spec: status=:ERROR, error=#<NoMethodError: undefined method `null?' for "":String
|
129
|
+
|
130
|
+
spec("spec#3") { "".null? } # error
|
131
|
+
^^^^^^>
|
132
|
+
END
|
133
|
+
else
|
134
|
+
expected += <<'END'
|
121
135
|
/spec: status=:ERROR, error=#<NoMethodError: undefined method `null?' for "":String>
|
136
|
+
END
|
137
|
+
end
|
138
|
+
expected += <<'END'
|
122
139
|
spec: "spec#4"
|
123
140
|
/spec: status=:SKIP, error=#<Oktest::SkipException: REASON>
|
124
141
|
spec: "spec#5"
|
@@ -285,7 +302,24 @@ topic: "topic#A"
|
|
285
302
|
/spec: status=:PASS
|
286
303
|
spec: "spec#2"
|
287
304
|
- at_end A2
|
305
|
+
END
|
306
|
+
if RUBY_VERSION >= "3.3"
|
307
|
+
expected += <<'END'
|
308
|
+
/spec: status=:ERROR, error=#<NoMethodError: undefined method `null?' for an instance of String>
|
309
|
+
END
|
310
|
+
elsif RUBY_VERSION =~ /^3\.1\./
|
311
|
+
expected += <<'END'
|
312
|
+
/spec: status=:ERROR, error=#<NoMethodError: undefined method `null?' for "":String
|
313
|
+
|
314
|
+
spec("spec#2") { at_end { puts " - at_end A2" }; "".null? } # raises NoMethodError
|
315
|
+
^^^^^^>
|
316
|
+
END
|
317
|
+
else
|
318
|
+
expected += <<'END'
|
288
319
|
/spec: status=:ERROR, error=#<NoMethodError: undefined method `null?' for "":String>
|
320
|
+
END
|
321
|
+
end
|
322
|
+
expected += <<'END'
|
289
323
|
/topic
|
290
324
|
/file
|
291
325
|
END
|
data/test/tc.rb
CHANGED
@@ -34,9 +34,9 @@ class TC
|
|
34
34
|
obj.instance_eval(&b)
|
35
35
|
rescue => exc
|
36
36
|
if exc.is_a?(AssertionFailed)
|
37
|
-
COUNTS[:fail] += 1; puts "
|
37
|
+
COUNTS[:fail] += 1; puts "\e[31mFAILED!\e[0m" unless ENV['TC_QUIET']
|
38
38
|
else
|
39
|
-
COUNTS[:error] += 1; puts "
|
39
|
+
COUNTS[:error] += 1; puts "\e[31mERROR!\e[0m" unless ENV['TC_QUIET']
|
40
40
|
end
|
41
41
|
puts " #{exc.class.name}: #{exc.message}"
|
42
42
|
exc.backtrace.each do |bt|
|
data/test/util_test.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
|
3
3
|
###
|
4
|
-
### $Release: 1.
|
5
|
-
### $Copyright: copyright(c) 2011-
|
4
|
+
### $Release: 1.3.0 $
|
5
|
+
### $Copyright: copyright(c) 2011-2024 kuwata-lab.com all rights reserved $
|
6
6
|
### $License: MIT License $
|
7
7
|
###
|
8
8
|
|
data/test/utilhelper_test.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
|
3
3
|
###
|
4
|
-
### $Release: 1.
|
5
|
-
### $Copyright: copyright(c) 2011-
|
4
|
+
### $Release: 1.3.0 $
|
5
|
+
### $Copyright: copyright(c) 2011-2024 kuwata-lab.com all rights reserved $
|
6
6
|
### $License: MIT License $
|
7
7
|
###
|
8
8
|
|
data/test/visitor_test.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
|
3
3
|
###
|
4
|
-
### $Release: 1.
|
5
|
-
### $Copyright: copyright(c) 2011-
|
4
|
+
### $Release: 1.3.0 $
|
5
|
+
### $Copyright: copyright(c) 2011-2024 kuwata-lab.com all rights reserved $
|
6
6
|
### $License: MIT License $
|
7
7
|
###
|
8
8
|
|
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.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kwatch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-09-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: diff-lcs
|
@@ -99,7 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
99
99
|
- !ruby/object:Gem::Version
|
100
100
|
version: '0'
|
101
101
|
requirements: []
|
102
|
-
rubygems_version: 3.
|
102
|
+
rubygems_version: 3.5.11
|
103
103
|
signing_key:
|
104
104
|
specification_version: 4
|
105
105
|
summary: new style testing library
|