oktest 1.3.1 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +156 -18
- data/Rakefile.rb +1 -1
- data/benchmark/run_all.rb +1 -0
- data/bin/oktest +3 -0
- data/lib/oktest.rb +253 -143
- data/oktest.gemspec +4 -3
- data/test/{run_all.rb → all.rb} +1 -0
- data/test/assertion_test.rb +244 -229
- data/test/filter_test.rb +123 -120
- data/test/fixture_test.rb +34 -32
- data/test/generator_test.rb +26 -22
- data/test/helper_test.rb +382 -204
- data/test/init.rb +44 -0
- data/test/mainapp_test.rb +249 -199
- data/test/matcher_test.rb +157 -126
- data/test/misc_test.rb +32 -30
- data/test/nanot.rb +307 -0
- data/test/node_test.rb +321 -242
- data/test/reporter_test.rb +250 -208
- data/test/runner_test.rb +102 -100
- data/test/util_test.rb +197 -193
- data/test/utilhelper_test.rb +36 -38
- data/test/visitor_test.rb +55 -50
- metadata +21 -7
- data/test/initialize.rb +0 -21
- data/test/tc.rb +0 -127
data/test/filter_test.rb
CHANGED
@@ -1,166 +1,169 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
###
|
4
|
-
### $Release: 1.
|
5
|
+
### $Release: 1.5.0 $
|
5
6
|
### $Copyright: copyright(c) 2011-2024 kuwata-lab.com all rights reserved $
|
6
7
|
### $License: MIT License $
|
7
8
|
###
|
8
9
|
|
9
|
-
require_relative './
|
10
|
+
require_relative './init'
|
10
11
|
|
11
12
|
|
12
|
-
|
13
|
+
Object.new.instance_eval do # Oktest::Filter
|
14
|
+
extend NanoTest
|
13
15
|
|
14
|
-
|
15
|
-
def parse_filter_str(str)
|
16
|
+
test_target 'Oktest::Filter.create_from()' do
|
17
|
+
def self.parse_filter_str(str)
|
16
18
|
return Oktest::Filter.create_from(str)
|
17
19
|
end
|
18
|
-
def filter_attrs(ft)
|
20
|
+
def self.filter_attrs(ft)
|
19
21
|
#return ft.topic_pattern, ft.spec_pattern, ft.tag_pattern, ft.negative
|
20
22
|
return ft.instance_eval {
|
21
23
|
[@topic_pattern, @spec_pattern, @tag_pattern, @negative]
|
22
24
|
}
|
23
25
|
end
|
24
26
|
#
|
25
|
-
|
27
|
+
test_subject "[!9dzmg] returns filter object." do
|
26
28
|
ft = parse_filter_str("topic=*pat*")
|
27
|
-
|
29
|
+
test_ok? ft.is_a?(Oktest::Filter), msg: "should be a filter object."
|
28
30
|
end
|
29
|
-
|
31
|
+
test_subject "[!xt364] parses 'topic=...' as filter pattern for topic." do
|
30
32
|
ft = parse_filter_str("topic=*pat*")
|
31
|
-
|
33
|
+
test_eq? filter_attrs(ft), ['*pat*', nil, nil, false]
|
32
34
|
end
|
33
|
-
|
35
|
+
test_subject "[!53ega] parses 'spec=...' as filter pattern for spec." do
|
34
36
|
ft = parse_filter_str("spec=*pat*")
|
35
|
-
|
37
|
+
test_eq? filter_attrs(ft), [nil, '*pat*', nil, false]
|
36
38
|
end
|
37
|
-
|
39
|
+
test_subject "[!go6us] parses 'tag=...' as filter pattern for tag." do
|
38
40
|
ft = parse_filter_str("tag={exp,old}")
|
39
|
-
|
41
|
+
test_eq? filter_attrs(ft), [nil, nil, '{exp,old}', false]
|
40
42
|
end
|
41
|
-
|
43
|
+
test_subject "[!gtpt1] parses 'sid=...' as filter pattern for spec." do
|
42
44
|
ft = parse_filter_str("sid=abc123")
|
43
|
-
|
45
|
+
test_eq? filter_attrs(ft), [nil, '\[!abc123\]*', nil, false]
|
44
46
|
end
|
45
|
-
|
46
|
-
|
47
|
+
test_subject "[!cmp6e] raises ArgumentError when invalid argument." do
|
48
|
+
exc = test_exception? ArgumentError do
|
47
49
|
parse_filter_str("abc123")
|
48
50
|
end
|
51
|
+
test_eq? exc.message, '"abc123": unexpected pattern string.'
|
49
52
|
end
|
50
|
-
|
53
|
+
test_subject "[!5hl7z] parses 'xxx!=...' as negative filter pattern." do
|
51
54
|
ft = parse_filter_str("topic!=*pat*")
|
52
|
-
|
55
|
+
test_eq? filter_attrs(ft), ['*pat*', nil, nil, true]
|
53
56
|
ft = parse_filter_str("spec!=*pat*")
|
54
|
-
|
57
|
+
test_eq? filter_attrs(ft), [nil, '*pat*', nil, true]
|
55
58
|
ft = parse_filter_str("tag!={exp,old}")
|
56
|
-
|
59
|
+
test_eq? filter_attrs(ft), [nil, nil, '{exp,old}', true]
|
57
60
|
ft = parse_filter_str("sid!=abc123")
|
58
|
-
|
61
|
+
test_eq? filter_attrs(ft), [nil, '\[!abc123\]*', nil, true]
|
59
62
|
end
|
60
63
|
end
|
61
64
|
|
62
|
-
def new_filter(topic_pat=nil, spec_pat=nil, tag_pat=nil, negative: false)
|
65
|
+
def self.new_filter(topic_pat=nil, spec_pat=nil, tag_pat=nil, negative: false)
|
63
66
|
ft = Oktest::Filter.new(topic_pat, spec_pat, tag_pat, negative: negative)
|
64
67
|
return ft
|
65
68
|
end
|
66
69
|
|
67
|
-
|
68
|
-
|
70
|
+
test_target 'Oktest::Filter#_match?()' do
|
71
|
+
test_subject "[!h90x3] returns true if str matched to pattern." do
|
69
72
|
ft = new_filter()
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
73
|
+
test_eq? ft.instance_eval { _match?('foo', 'foo') }, true
|
74
|
+
test_eq? ft.instance_eval { _match?('foo', 'f*') }, true
|
75
|
+
test_eq? ft.instance_eval { _match?('foo', '*o*') }, true
|
76
|
+
test_eq? ft.instance_eval { _match?('foo', '{foo,bar}') }, true
|
74
77
|
#
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
78
|
+
test_eq? ft.instance_eval { _match?('foo', 'bar') }, false
|
79
|
+
test_eq? ft.instance_eval { _match?('foo', 'F*') }, false
|
80
|
+
test_eq? ft.instance_eval { _match?('foo', '*x*') }, false
|
81
|
+
test_eq? ft.instance_eval { _match?('foo', '{x,y}') }, false
|
79
82
|
end
|
80
83
|
end
|
81
84
|
|
82
|
-
|
83
|
-
|
85
|
+
test_target 'Oktest::Filter#_match_tag?()' do
|
86
|
+
test_subject "[!lyo18] returns false if tag is nil." do
|
84
87
|
ft = new_filter()
|
85
|
-
|
88
|
+
test_eq? ft.instance_eval { _match_tag?(nil, '*') }, false
|
86
89
|
end
|
87
|
-
|
90
|
+
test_subject "[!8lxin] returns true if tag matched to pattern." do
|
88
91
|
ft = new_filter()
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
92
|
+
test_eq? ft.instance_eval { _match_tag?('foo', 'foo') }, true
|
93
|
+
test_eq? ft.instance_eval { _match_tag?('foo', 'f*') }, true
|
94
|
+
test_eq? ft.instance_eval { _match_tag?('foo', '*o*') }, true
|
95
|
+
test_eq? ft.instance_eval { _match_tag?('foo', '{foo,bar}') }, true
|
93
96
|
#
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
97
|
+
test_eq? ft.instance_eval { _match_tag?('foo', 'bar') }, false
|
98
|
+
test_eq? ft.instance_eval { _match_tag?('foo', 'F*') }, false
|
99
|
+
test_eq? ft.instance_eval { _match_tag?('foo', '*x*') }, false
|
100
|
+
test_eq? ft.instance_eval { _match_tag?('foo', '{x,y}') }, false
|
98
101
|
end
|
99
|
-
|
102
|
+
test_subject "[!7wxmh] supports multiple tag names." do
|
100
103
|
ft = new_filter()
|
101
104
|
tag = ['foo', 'bar']
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
105
|
+
test_eq? ft.instance_eval { _match_tag?(tag, 'foo') }, true
|
106
|
+
test_eq? ft.instance_eval { _match_tag?(tag, 'f*') }, true
|
107
|
+
test_eq? ft.instance_eval { _match_tag?(tag, '*o*') }, true
|
108
|
+
test_eq? ft.instance_eval { _match_tag?(tag, '{fooooo,bar,baz}') }, true
|
106
109
|
#
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
110
|
+
test_eq? ft.instance_eval { _match_tag?(tag, 'foooo') }, false
|
111
|
+
test_eq? ft.instance_eval { _match_tag?(tag, 'F*') }, false
|
112
|
+
test_eq? ft.instance_eval { _match_tag?(tag, '*x*') }, false
|
113
|
+
test_eq? ft.instance_eval { _match_tag?(tag, '{x,y}') }, false
|
111
114
|
end
|
112
115
|
end
|
113
116
|
|
114
|
-
|
115
|
-
|
117
|
+
test_target 'Oktest::Filter#scope_match?()' do
|
118
|
+
test_subject "[!zkq6r] returns true only if tag name matched to pattern." do
|
116
119
|
sc = Oktest::ScopeNode.new(nil, 'file.rb', tag: 'foo')
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
+
test_eq? new_filter('*', '*', 'foo').scope_match?(sc), true
|
121
|
+
test_eq? new_filter('*', '*', 'f*' ).scope_match?(sc), true
|
122
|
+
test_eq? new_filter('*', '*', 'x*' ).scope_match?(sc), false
|
120
123
|
#
|
121
124
|
sc = Oktest::ScopeNode.new(nil, 'file.rb', tag: nil)
|
122
|
-
|
123
|
-
|
125
|
+
test_eq? new_filter('*', '*', 'foo').scope_match?(sc), false
|
126
|
+
test_eq? new_filter('*', '*', '*' ).scope_match?(sc), false
|
124
127
|
end
|
125
128
|
end
|
126
129
|
|
127
|
-
|
128
|
-
|
130
|
+
test_target 'Oktest::Filter#topic_match?()' do
|
131
|
+
test_subject "[!jpycj] returns true if topic target name matched to pattern." do
|
129
132
|
to = Oktest::TopicNode.new(nil, Time)
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
+
test_eq? new_filter('Time' , nil, nil).topic_match?(to), true
|
134
|
+
test_eq? new_filter('*ime*', nil, nil).topic_match?(to), true
|
135
|
+
test_eq? new_filter('*xy*' , nil, nil).topic_match?(to), false
|
133
136
|
end
|
134
|
-
|
137
|
+
test_subject "[!6lfp1] returns true if tag name matched to pattern." do
|
135
138
|
to = Oktest::TopicNode.new(nil, Time, tag: 'foo')
|
136
139
|
[nil, '*bar*'].each do |pat|
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
140
|
+
test_eq? new_filter(pat, nil, 'foo' ).topic_match?(to), true
|
141
|
+
test_eq? new_filter(pat, nil, 'f*' ).topic_match?(to), true
|
142
|
+
test_eq? new_filter(pat, nil, '{foo,bar}').topic_match?(to), true
|
143
|
+
test_eq? new_filter(pat, nil, 'fooooo' ).topic_match?(to), false
|
141
144
|
end
|
142
145
|
end
|
143
146
|
end
|
144
147
|
|
145
|
-
|
146
|
-
|
148
|
+
test_target 'Oktest::Filter#spec_match?()' do
|
149
|
+
test_subject "[!k45p3] returns true if spec description matched to pattern." do
|
147
150
|
sp = Oktest::SpecLeaf.new(nil, "sample", tag: 'foo')
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
+
test_eq? new_filter(nil, 'sample', nil).spec_match?(sp), true
|
152
|
+
test_eq? new_filter(nil, '*samp*', nil).spec_match?(sp), true
|
153
|
+
test_eq? new_filter(nil, '*abc*' , nil).spec_match?(sp), false
|
151
154
|
end
|
152
|
-
|
155
|
+
test_subject "[!li3pd] returns true if tag name matched to pattern." do
|
153
156
|
sp = Oktest::SpecLeaf.new(nil, "sample", tag: 'foo')
|
154
157
|
[nil, '*bar*'].each do |pat|
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
158
|
+
test_eq? new_filter(nil, pat, 'foo' ).spec_match?(sp), true
|
159
|
+
test_eq? new_filter(nil, pat, 'f*' ).spec_match?(sp), true
|
160
|
+
test_eq? new_filter(nil, pat, '{foo,bar}').spec_match?(sp), true
|
161
|
+
test_eq? new_filter(nil, pat, 'fooooo' ).spec_match?(sp), false
|
159
162
|
end
|
160
163
|
end
|
161
164
|
end
|
162
165
|
|
163
|
-
def prepare()
|
166
|
+
def self.prepare()
|
164
167
|
Oktest.scope do
|
165
168
|
topic 'Hello' do
|
166
169
|
spec "hello spec", tag: 'new' do ok {"hello"} == "hello" end
|
@@ -179,32 +182,32 @@ class Filter_TC < TC
|
|
179
182
|
end
|
180
183
|
end
|
181
184
|
|
182
|
-
def run_filter(topic_pattern, spec_pattern, tag_pattern, negative: false)
|
183
|
-
prepare()
|
185
|
+
def self.run_filter(topic_pattern, spec_pattern, tag_pattern, negative: false)
|
186
|
+
self.prepare()
|
184
187
|
filter = Oktest::Filter.new(topic_pattern, spec_pattern, tag_pattern, negative: negative)
|
185
188
|
Oktest.filter(filter)
|
186
189
|
reporter = Oktest::VerboseReporter.new()
|
187
|
-
sout, serr =
|
190
|
+
sout, serr = capture_output! '', tty: false do
|
188
191
|
Oktest::Runner.new(reporter).start()
|
189
192
|
end
|
190
|
-
|
191
|
-
return sout.sub(/^## total:.*\n/, '').sub(/^## test
|
193
|
+
test_eq? serr, ""
|
194
|
+
return sout.sub(/^## total:.*\n/, '').sub(/^## test\d?\/filter_test\.rb\n/, '')
|
192
195
|
end
|
193
196
|
|
194
|
-
def uncolor(s)
|
195
|
-
return s.gsub(/\
|
197
|
+
def self.uncolor(s)
|
198
|
+
return s.gsub(/\e\[.*?m/, '')
|
196
199
|
end
|
197
200
|
|
198
|
-
|
199
|
-
|
201
|
+
test_target 'Oktest::Filter#filter_children!()' do
|
202
|
+
test_subject "[!osoq2] can filter topics by full name." do
|
200
203
|
expected = <<END
|
201
204
|
* Hello
|
202
205
|
- [pass] hello spec
|
203
206
|
END
|
204
207
|
sout = run_filter('Hello', nil, nil)
|
205
|
-
|
208
|
+
test_eq? uncolor(sout), expected
|
206
209
|
end
|
207
|
-
|
210
|
+
test_subject "[!wzcco] can filter topics by pattern." do
|
208
211
|
expected = <<END
|
209
212
|
* Topic 832795
|
210
213
|
* Integer
|
@@ -216,9 +219,9 @@ END
|
|
216
219
|
- [pass] spec example #5
|
217
220
|
END
|
218
221
|
sout = run_filter('*832795*', nil, nil)
|
219
|
-
|
222
|
+
test_eq? uncolor(sout), expected
|
220
223
|
end
|
221
|
-
|
224
|
+
test_subject "[!mz6id] can filter nested topics." do
|
222
225
|
expected = <<END
|
223
226
|
* Topic 832795
|
224
227
|
* Float
|
@@ -226,23 +229,23 @@ END
|
|
226
229
|
- [pass] spec example #4
|
227
230
|
END
|
228
231
|
sout = run_filter('*loat*', nil, nil)
|
229
|
-
|
232
|
+
test_eq? uncolor(sout), expected
|
230
233
|
end
|
231
|
-
|
234
|
+
test_subject "[!0kw9c] can filter specs by full name." do
|
232
235
|
expected = <<END
|
233
236
|
* Hello
|
234
237
|
- [pass] hello spec
|
235
238
|
END
|
236
239
|
sout = run_filter(nil, 'hello spec', nil)
|
237
|
-
|
240
|
+
test_eq? uncolor(sout), expected
|
238
241
|
end
|
239
|
-
|
242
|
+
test_subject "[!fd8wt] can filter specs by pattern." do
|
240
243
|
expected = <<END
|
241
244
|
* Topic 832795
|
242
245
|
- [pass] spec example #5
|
243
246
|
END
|
244
247
|
sout = run_filter(nil, '*#5', nil)
|
245
|
-
|
248
|
+
test_eq? uncolor(sout), expected
|
246
249
|
#
|
247
250
|
expected = <<END
|
248
251
|
* Topic 832795
|
@@ -255,18 +258,18 @@ END
|
|
255
258
|
- [pass] spec example #5
|
256
259
|
END
|
257
260
|
sout = run_filter(nil, 'spec example*', nil)
|
258
|
-
|
261
|
+
test_eq? uncolor(sout), expected
|
259
262
|
end
|
260
|
-
|
263
|
+
test_subject "[!1jphf] can filter specs from nested topics." do
|
261
264
|
expected = <<END
|
262
265
|
* Topic 832795
|
263
266
|
* Float
|
264
267
|
- [pass] spec example #4
|
265
268
|
END
|
266
269
|
sout = run_filter(nil, '*#4', nil)
|
267
|
-
|
270
|
+
test_eq? uncolor(sout), expected
|
268
271
|
end
|
269
|
-
|
272
|
+
test_subject "[!eirmu] can filter topics by tag name." do
|
270
273
|
expected = <<END
|
271
274
|
* Topic 832795
|
272
275
|
* Float
|
@@ -275,9 +278,9 @@ END
|
|
275
278
|
- [pass] spec example #5
|
276
279
|
END
|
277
280
|
sout = run_filter(nil, nil, 'exp')
|
278
|
-
|
281
|
+
test_eq? uncolor(sout), expected
|
279
282
|
end
|
280
|
-
|
283
|
+
test_subject "[!6sq7g] can filter specs by tag name." do
|
281
284
|
expected = <<END
|
282
285
|
* Hello
|
283
286
|
- [pass] hello spec
|
@@ -287,9 +290,9 @@ END
|
|
287
290
|
- [pass] spec example #5
|
288
291
|
END
|
289
292
|
sout = run_filter(nil, nil, 'new')
|
290
|
-
|
293
|
+
test_eq? uncolor(sout), expected
|
291
294
|
end
|
292
|
-
|
295
|
+
test_subject "[!6to6n] can filter by multiple tag name." do
|
293
296
|
expected = <<END
|
294
297
|
* Hello
|
295
298
|
- [pass] hello spec
|
@@ -302,15 +305,15 @@ END
|
|
302
305
|
- [pass] spec example #5
|
303
306
|
END
|
304
307
|
sout = run_filter(nil, nil, '{new,exp}')
|
305
|
-
|
308
|
+
test_eq? uncolor(sout), expected
|
306
309
|
end
|
307
|
-
|
310
|
+
test_subject "[!r6g6a] supports negative filter by topic." do
|
308
311
|
expected = <<END
|
309
312
|
* Hello
|
310
313
|
- [pass] hello spec
|
311
314
|
END
|
312
315
|
sout = run_filter('Topic 832795', nil, nil, negative: true)
|
313
|
-
|
316
|
+
test_eq? uncolor(sout), expected
|
314
317
|
#
|
315
318
|
expected = <<END
|
316
319
|
* Hello
|
@@ -319,9 +322,9 @@ END
|
|
319
322
|
- [pass] spec example #5
|
320
323
|
END
|
321
324
|
sout = run_filter('{Integer,Float}', nil, nil, negative: true)
|
322
|
-
|
325
|
+
test_eq? uncolor(sout), expected
|
323
326
|
end
|
324
|
-
|
327
|
+
test_subject "[!doozg] supports negative filter by spec." do
|
325
328
|
expected = <<END
|
326
329
|
* Topic 832795
|
327
330
|
* Integer
|
@@ -333,16 +336,16 @@ END
|
|
333
336
|
- [pass] spec example #5
|
334
337
|
END
|
335
338
|
sout = run_filter(nil, '*hello*', nil, negative: true)
|
336
|
-
|
339
|
+
test_eq? uncolor(sout), expected
|
337
340
|
#
|
338
341
|
expected = <<END
|
339
342
|
* Hello
|
340
343
|
- [pass] hello spec
|
341
344
|
END
|
342
345
|
sout = run_filter(nil, 'spec example #[1-5]', nil, negative: true)
|
343
|
-
|
346
|
+
test_eq? uncolor(sout), expected
|
344
347
|
end
|
345
|
-
|
348
|
+
test_subject "[!ntv44] supports negative filter by tag name." do
|
346
349
|
expected = <<END
|
347
350
|
* Topic 832795
|
348
351
|
* Integer
|
@@ -352,7 +355,7 @@ END
|
|
352
355
|
- [pass] spec example #4
|
353
356
|
END
|
354
357
|
sout = run_filter(nil, nil, 'new', negative: true)
|
355
|
-
|
358
|
+
test_eq? uncolor(sout), expected
|
356
359
|
#
|
357
360
|
expected = <<END
|
358
361
|
* Hello
|
@@ -363,7 +366,7 @@ END
|
|
363
366
|
- [pass] spec example #2
|
364
367
|
END
|
365
368
|
sout = run_filter(nil, nil, 'exp', negative: true)
|
366
|
-
|
369
|
+
test_eq? uncolor(sout), expected
|
367
370
|
#
|
368
371
|
expected = <<END
|
369
372
|
* Topic 832795
|
@@ -371,7 +374,7 @@ END
|
|
371
374
|
- [pass] spec example #1
|
372
375
|
END
|
373
376
|
sout = run_filter(nil, nil, '{exp,new}', negative: true)
|
374
|
-
|
377
|
+
test_eq? uncolor(sout), expected
|
375
378
|
end
|
376
379
|
|
377
380
|
end
|
data/test/fixture_test.rb
CHANGED
@@ -1,34 +1,36 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
###
|
4
|
-
### $Release: 1.
|
5
|
+
### $Release: 1.5.0 $
|
5
6
|
### $Copyright: copyright(c) 2011-2024 kuwata-lab.com all rights reserved $
|
6
7
|
### $License: MIT License $
|
7
8
|
###
|
8
9
|
|
9
|
-
require_relative './
|
10
|
+
require_relative './init'
|
10
11
|
|
11
12
|
|
12
|
-
class
|
13
|
+
class FixtureManager__Test
|
14
|
+
extend NanoTest
|
13
15
|
|
14
|
-
class
|
16
|
+
class DummyReporter5 < Oktest::Reporter
|
15
17
|
def exit_spec(spec, depth, status, error, parent)
|
16
18
|
puts error.inspect if error
|
17
19
|
end
|
18
20
|
end
|
19
21
|
|
20
|
-
def run_all(dummy: false)
|
21
|
-
reporter = dummy ?
|
22
|
-
sout, serr =
|
22
|
+
def self.run_all(dummy: false)
|
23
|
+
reporter = dummy ? DummyReporter5.new : Oktest::Reporter.new
|
24
|
+
sout, serr = capture_output! do
|
23
25
|
Oktest::Runner.new(reporter).start()
|
24
26
|
end
|
25
|
-
|
27
|
+
test_eq? serr, ""
|
26
28
|
return sout
|
27
29
|
end
|
28
30
|
|
29
|
-
|
31
|
+
test_target 'Oktest::FixtureManager#get_fixture_values()' do
|
30
32
|
|
31
|
-
|
33
|
+
test_subject "[!v587k] resolves fixtures." do
|
32
34
|
Oktest.scope do
|
33
35
|
fixture(:x) { 10 }
|
34
36
|
topic "Parent" do
|
@@ -43,10 +45,10 @@ class FixtureManager_TC < TC
|
|
43
45
|
end
|
44
46
|
expected = "[10, 20, 30]\n"
|
45
47
|
sout = run_all()
|
46
|
-
|
48
|
+
test_eq? sout, expected
|
47
49
|
end
|
48
50
|
|
49
|
-
|
51
|
+
test_subject "[!ja2ew] resolves 'this_spec' fixture name as description of current spec." do
|
50
52
|
Oktest.scope do
|
51
53
|
topic Integer do
|
52
54
|
spec "1+1 should be 2." do |this_spec|
|
@@ -55,10 +57,10 @@ class FixtureManager_TC < TC
|
|
55
57
|
end
|
56
58
|
end
|
57
59
|
sout = run_all()
|
58
|
-
|
60
|
+
test_eq? sout, "this_spec=\"1+1 should be 2.\"\n"
|
59
61
|
end
|
60
62
|
|
61
|
-
|
63
|
+
test_subject "[!w6ffs] resolves 'this_topic' fixture name as target objec of current topic." do
|
62
64
|
Oktest.scope do
|
63
65
|
topic Integer do
|
64
66
|
spec "1+1 should be 2." do |this_topic|
|
@@ -67,10 +69,10 @@ class FixtureManager_TC < TC
|
|
67
69
|
end
|
68
70
|
end
|
69
71
|
sout = run_all()
|
70
|
-
|
72
|
+
test_eq? sout, "this_topic=Integer\n"
|
71
73
|
end
|
72
74
|
|
73
|
-
|
75
|
+
test_subject "[!np4p9] raises error when loop exists in dependency." do
|
74
76
|
Oktest.scope do
|
75
77
|
topic "Parent" do
|
76
78
|
fixture(:a) {|b| nil }
|
@@ -84,14 +86,14 @@ class FixtureManager_TC < TC
|
|
84
86
|
end
|
85
87
|
expected = "\#<Oktest::LoopedDependencyError: fixture dependency is looped: a->b=>c=>d=>b>\n"
|
86
88
|
sout = run_all(dummy: true)
|
87
|
-
|
89
|
+
test_eq? sout, expected
|
88
90
|
end
|
89
91
|
|
90
92
|
end
|
91
93
|
|
92
|
-
|
94
|
+
test_target 'Oktest::FixtureManager#get_fixture_value()' do
|
93
95
|
|
94
|
-
|
96
|
+
test_subject "[!2esaf] resolves fixture dependencies." do
|
95
97
|
Oktest.scope do
|
96
98
|
topic "Parent" do
|
97
99
|
fixture(:a) {|b, c| ["A"] + b + c }
|
@@ -113,10 +115,10 @@ class FixtureManager_TC < TC
|
|
113
115
|
["A", "B", "C", "D"]
|
114
116
|
END
|
115
117
|
sout = run_all()
|
116
|
-
|
118
|
+
test_eq? sout, expected
|
117
119
|
end
|
118
120
|
|
119
|
-
|
121
|
+
test_subject "[!gyyst] overwrites keyword params by fixture values." do
|
120
122
|
Oktest.scope do
|
121
123
|
topic "topic#1" do
|
122
124
|
fixture(:x) {|y, z: 3| {y: y, z: z} }
|
@@ -126,10 +128,10 @@ END
|
|
126
128
|
end
|
127
129
|
end
|
128
130
|
sout = run_all()
|
129
|
-
|
131
|
+
test_eq? sout, "{:y=>2, :z=>3}\n{:y=>4, :z=>5}\n"
|
130
132
|
end
|
131
133
|
|
132
|
-
|
134
|
+
test_subject "[!4xghy] calls fixture block with context object as self." do
|
133
135
|
Oktest.scope do
|
134
136
|
topic "Parent" do
|
135
137
|
fixture(:x) { @x = 10; 20 }
|
@@ -140,10 +142,10 @@ END
|
|
140
142
|
10
|
141
143
|
END
|
142
144
|
sout = run_all()
|
143
|
-
|
145
|
+
test_eq? sout, expected
|
144
146
|
end
|
145
147
|
|
146
|
-
|
148
|
+
test_subject "[!8t3ul] caches fixture value to call fixture block only once per spec." do
|
147
149
|
Oktest.scope do
|
148
150
|
topic "Parent" do
|
149
151
|
fixture(:x) { puts "** x called."; 10 }
|
@@ -161,10 +163,10 @@ END
|
|
161
163
|
12
|
162
164
|
END
|
163
165
|
sout = run_all()
|
164
|
-
|
166
|
+
test_eq? sout, expected
|
165
167
|
end
|
166
168
|
|
167
|
-
|
169
|
+
test_subject "[!4chb9] traverses parent topics if fixture not found in current topic." do
|
168
170
|
Oktest.scope do
|
169
171
|
topic 'Parent' do
|
170
172
|
fixture(:x) { 10 }
|
@@ -178,10 +180,10 @@ END
|
|
178
180
|
end
|
179
181
|
end
|
180
182
|
sout = run_all()
|
181
|
-
|
183
|
+
test_eq? sout, "\"x=10, y=11, z=12\"\n"
|
182
184
|
end
|
183
185
|
|
184
|
-
|
186
|
+
test_subject "[!wt3qk] suports global scope." do
|
185
187
|
Oktest.global_scope do
|
186
188
|
fixture :gf1592 do {id: "gf1592"} end
|
187
189
|
fixture :gf6535 do |gf1592| {id: "gf6535", parent: gf1592} end
|
@@ -196,10 +198,10 @@ END
|
|
196
198
|
end
|
197
199
|
end
|
198
200
|
_ = run_all()
|
199
|
-
|
201
|
+
test_eq? data, {:id=>"gf8979", :parent=>{:id=>"gf6535", :parent=>{:id=>"gf1592"}}}
|
200
202
|
end
|
201
203
|
|
202
|
-
|
204
|
+
test_subject "[!nr79z] raises error when fixture not found." do
|
203
205
|
Oktest.scope do
|
204
206
|
topic "Parent" do
|
205
207
|
fixture(:x) { 10 }
|
@@ -210,7 +212,7 @@ END
|
|
210
212
|
end
|
211
213
|
expected = "#<Oktest::FixtureNotFoundError: y: fixture not found. (spec: spec#1)>\n"
|
212
214
|
sout = run_all(dummy: true)
|
213
|
-
|
215
|
+
test_eq? sout, expected
|
214
216
|
end
|
215
217
|
|
216
218
|
end
|