oktest 1.4.0 → 1.5.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/README.md +42 -5
- data/Rakefile.rb +1 -1
- data/lib/oktest.rb +32 -9
- data/oktest.gemspec +3 -3
- data/test/assertion_test.rb +229 -227
- data/test/filter_test.rb +122 -120
- data/test/fixture_test.rb +33 -32
- data/test/generator_test.rb +20 -19
- data/test/helper_test.rb +280 -274
- data/test/init.rb +44 -0
- data/test/mainapp_test.rb +194 -190
- data/test/matcher_test.rb +156 -126
- data/test/misc_test.rb +31 -30
- data/test/nanot.rb +307 -0
- data/test/node_test.rb +296 -252
- data/test/reporter_test.rb +249 -208
- data/test/runner_test.rb +101 -100
- data/test/util_test.rb +196 -193
- data/test/utilhelper_test.rb +35 -38
- data/test/visitor_test.rb +54 -50
- metadata +10 -10
- data/test/initialize.rb +0 -22
- data/test/tc.rb +0 -128
- /data/test/{run_all.rb → all.rb} +0 -0
data/test/matcher_test.rb
CHANGED
@@ -2,193 +2,209 @@
|
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
###
|
5
|
-
### $Release: 1.
|
5
|
+
### $Release: 1.5.0 $
|
6
6
|
### $Copyright: copyright(c) 2011-2024 kuwata-lab.com all rights reserved $
|
7
7
|
### $License: MIT License $
|
8
8
|
###
|
9
9
|
|
10
|
-
require_relative './
|
10
|
+
require_relative './init'
|
11
11
|
require 'set'
|
12
12
|
|
13
13
|
|
14
|
-
class
|
14
|
+
class Matcher__Test
|
15
|
+
extend NanoTest
|
16
|
+
extend Oktest::SpecHelper
|
15
17
|
|
16
|
-
|
17
|
-
|
18
|
+
test_target 'Oktest::Matcher#===' do
|
19
|
+
test_subject "[!spybn] raises NotImplementedError." do
|
18
20
|
errmsg = "Oktest::Matcher#===(): not implemented yet."
|
19
|
-
|
21
|
+
exc = test_exception? NotImplementedError do
|
20
22
|
Oktest::Matcher.new(nil) === nil
|
21
23
|
end
|
24
|
+
test_eq? exc.message, errmsg
|
22
25
|
end
|
23
26
|
end
|
24
27
|
|
25
|
-
|
26
|
-
|
28
|
+
test_target 'Oktest::Matcher#==' do
|
29
|
+
test_subject "[!ymt1b] raises OktestError." do
|
27
30
|
errmsg = "JSON(): use `===` instead of `==`."
|
28
|
-
|
31
|
+
exc = test_exception? Oktest::OktestError do
|
29
32
|
Oktest::Matcher.new(nil) == nil
|
30
33
|
end
|
34
|
+
test_eq? exc.message, errmsg
|
31
35
|
end
|
32
36
|
end
|
33
37
|
|
34
|
-
|
35
|
-
|
38
|
+
test_target 'Oktest::Matcher#fail()' do
|
39
|
+
test_subject "[!8qpsd] raises assertion error." do
|
36
40
|
errmsg = "<<errmsg>>"
|
37
|
-
|
41
|
+
exc = test_exception? Oktest::FAIL_EXCEPTION do
|
38
42
|
Oktest::Matcher.new(nil).fail("<<errmsg>>")
|
39
43
|
end
|
44
|
+
test_eq? exc.message, errmsg
|
40
45
|
end
|
41
46
|
end
|
42
47
|
|
43
48
|
end
|
44
49
|
|
45
50
|
|
46
|
-
class
|
51
|
+
class JsonMatcher__Test
|
52
|
+
extend NanoTest
|
47
53
|
|
48
|
-
def JSON(x)
|
54
|
+
def self.JSON(x)
|
49
55
|
return Oktest::JsonMatcher.new(x)
|
50
56
|
end
|
51
57
|
|
52
|
-
def OR(*args)
|
58
|
+
def self.OR(*args)
|
53
59
|
return Oktest::JsonMatcher::OR.new(*args)
|
54
60
|
end
|
55
61
|
|
56
|
-
def AND(*args)
|
62
|
+
def self.AND(*args)
|
57
63
|
return Oktest::JsonMatcher::AND.new(*args)
|
58
64
|
end
|
59
65
|
|
60
|
-
def ANY()
|
66
|
+
def self.ANY()
|
61
67
|
return Oktest::JsonMatcher::Any.new
|
62
68
|
end
|
63
69
|
|
64
|
-
|
65
|
-
|
66
|
-
|
70
|
+
test_target 'Oktest::JsonMatcher#===' do
|
71
|
+
test_subject "[!4uf1o] raises assertion error when JSON not matched." do
|
72
|
+
exc = test_exception? Oktest::FAIL_EXCEPTION do
|
67
73
|
JSON({"status": "ok"}) === {"status": "OK"}
|
68
74
|
end
|
69
75
|
end
|
70
|
-
|
76
|
+
test_subject "[!0g0u4] returns true when JSON matched." do
|
71
77
|
result = JSON({"status": "ok"}) === {"status": "ok"}
|
72
|
-
|
78
|
+
test_eq? result, true
|
73
79
|
end
|
74
|
-
|
80
|
+
test_subject "[!1ukbv] scalar value matches to integer, string, bool, and so son." do
|
75
81
|
actual = {"name": "Alice", "age": 20, "deleted": false}
|
76
82
|
result = JSON(actual) === {"name": "Alice", "age": 20, "deleted": false}
|
77
|
-
|
83
|
+
test_eq? result, true
|
78
84
|
#
|
79
85
|
errmsg = ("$<JSON>[\"name\"]: $<expected> === $<actual> : failed.\n"\
|
80
86
|
" $<actual>: \"Alice\"\n"\
|
81
87
|
" $<expected>: \"alice\"\n")
|
82
|
-
|
88
|
+
exc = test_exception? Oktest::FAIL_EXCEPTION do
|
83
89
|
JSON(actual) === {"name": "alice", "age": 20, "deleted": false}
|
84
90
|
end
|
91
|
+
test_eq? exc.message, errmsg
|
85
92
|
end
|
86
|
-
|
93
|
+
test_subject "[!8o55d] class object matches to instance object." do
|
87
94
|
actual = {"name": "Alice", "age": 20, "deleted": false}
|
88
95
|
result = JSON(actual) === {"name": String, "age": Integer, "deleted": FalseClass}
|
89
|
-
|
96
|
+
test_eq? result, true
|
90
97
|
#
|
91
98
|
errmsg = ("$<JSON>[\"deleted\"]: $<expected> === $<actual> : failed.\n"\
|
92
99
|
" $<actual>: false\n"\
|
93
100
|
" $<expected>: TrueClass\n")
|
94
|
-
|
101
|
+
exc = test_exception? Oktest::FAIL_EXCEPTION do
|
95
102
|
JSON(actual) === {"name": String, "age": Integer, "deleted": TrueClass}
|
96
103
|
end
|
104
|
+
test_eq? exc.message, errmsg
|
97
105
|
end
|
98
|
-
|
106
|
+
test_subject "[!s625d] regexp object matches to string value." do
|
99
107
|
actual = {"email": "alice@example.com"}
|
100
108
|
result = JSON(actual) === {"email": /^\w[-.\w]+@example\.(com|net|org)$/}
|
101
|
-
|
109
|
+
test_eq? result, true
|
102
110
|
#
|
103
111
|
errmsg = ("$<JSON>[\"email\"]: $<expected> === $<actual> : failed.\n"\
|
104
112
|
" $<actual>: \"alice@example.com\"\n"\
|
105
113
|
" $<expected>: /^\\w[-.\\w]+@example\\.org$/\n")
|
106
|
-
|
114
|
+
exc = test_exception? Oktest::FAIL_EXCEPTION do
|
107
115
|
JSON(actual) === {"email": /^\w[-.\w]+@example\.org$/}
|
108
116
|
end
|
117
|
+
test_eq? exc.message, errmsg
|
109
118
|
end
|
110
|
-
|
119
|
+
test_subject "[!aqkk0] range object matches to scalar value." do
|
111
120
|
actual = {"int": 5, "float": 3.14, "str": "abc"}
|
112
121
|
result = JSON(actual) === {"int": 1..10, "float": 3.1..3.2, "str": "aaa".."zzz"}
|
113
|
-
|
122
|
+
test_eq? result, true
|
114
123
|
#
|
115
124
|
errmsg = ("$<JSON>[\"int\"]: $<expected> === $<actual> : failed.\n"\
|
116
125
|
" $<actual>: 5\n"\
|
117
126
|
" $<expected>: 1...5\n")
|
118
|
-
|
127
|
+
exc = test_exception? Oktest::FAIL_EXCEPTION do
|
119
128
|
JSON(actual) === {"int": 1...5, "float": 3.1..3.2, "str": "aaa".."zzz"}
|
120
129
|
end
|
130
|
+
test_eq? exc.message, errmsg
|
121
131
|
end
|
122
|
-
|
132
|
+
test_subject "[!4ymj2] fails when actual value is not matched to item class of range object." do
|
123
133
|
actual = {"val": 1.5}
|
124
134
|
errmsg = ("$<JSON>[\"val\"]: expected #{1.class.name} value, but got Float value.\n"\
|
125
135
|
" $<actual>: 1.5\n"\
|
126
136
|
" $<expected>: 1..10\n")
|
127
|
-
|
137
|
+
exc = test_exception? Oktest::FAIL_EXCEPTION do
|
128
138
|
JSON(actual) === {"val": 1..10}
|
129
139
|
end
|
140
|
+
test_eq? exc.message, errmsg
|
130
141
|
end
|
131
|
-
|
142
|
+
test_subject "[!a7bfs] Set object matches to enum value." do
|
132
143
|
actual = {"gender": "female"}
|
133
144
|
result = JSON(actual) === {"gender": Set.new(["male", "female"])}
|
134
|
-
|
145
|
+
test_eq? result, true
|
135
146
|
#
|
136
147
|
errmsg = ("$<JSON>[\"gender\"]: $<expected> === $<actual> : failed.\n"\
|
137
148
|
" $<actual>: \"female\"\n"\
|
138
149
|
" $<expected>: #<Set: {\"M\", \"F\"}>\n")
|
139
|
-
|
150
|
+
exc = test_exception? Oktest::FAIL_EXCEPTION do
|
140
151
|
JSON(actual) === {"gender": Set.new(["M", "F"])}
|
141
152
|
end
|
153
|
+
test_eq? exc.message, errmsg
|
142
154
|
end
|
143
|
-
|
155
|
+
test_subject "[!sh5cg] Enumerator object matches to repeat of rule." do
|
144
156
|
actual = {"tags": ["foo", "bar", "baz"]}
|
145
157
|
result = JSON(actual) === {"tags": [String].each}
|
146
|
-
|
158
|
+
test_eq? result, true
|
147
159
|
#
|
148
160
|
errmsg = ("$<JSON>[\"tags\"][0]: $<expected> === $<actual> : failed.\n"\
|
149
161
|
" $<actual>: \"foo\"\n"\
|
150
162
|
" $<expected>: Integer\n")
|
151
|
-
|
163
|
+
exc = test_exception? Oktest::FAIL_EXCEPTION do
|
152
164
|
JSON(actual) === {"tags": [Integer].each}
|
153
165
|
end
|
166
|
+
test_eq? exc.message, errmsg
|
154
167
|
end
|
155
|
-
|
168
|
+
test_subject "[!ljrmc] fails when expected is an Enumerator object and actual is not an array." do
|
156
169
|
actual = {"tags": "foo"}
|
157
170
|
errmsg = ("$<JSON>[\"tags\"]: Array value expected but got String value.\n"\
|
158
171
|
" $<actual>: \"foo\"\n"\
|
159
172
|
" $<expected>: [String].each\n")
|
160
|
-
|
173
|
+
exc = test_exception? Oktest::FAIL_EXCEPTION do
|
161
174
|
JSON(actual) === {"tags": [String].each}
|
162
175
|
end
|
176
|
+
test_eq? exc.message, errmsg
|
163
177
|
end
|
164
|
-
|
178
|
+
test_subject "[!lh6d6] compares array items recursively." do
|
165
179
|
actual = {"items": [{"name": "Alice", "id": 101}, {"name": "Bob"}]}
|
166
180
|
result = JSON(actual) === {
|
167
181
|
"items": [{"name": String, "id?": 100..999}].each
|
168
182
|
}
|
169
|
-
|
183
|
+
test_eq? result, true
|
170
184
|
#
|
171
185
|
errmsg = ("$<JSON>[\"items\"][0][\"id\"]: $<expected> === $<actual> : failed.\n"\
|
172
186
|
" $<actual>: 101\n"\
|
173
187
|
" $<expected>: 1000..9999\n")
|
174
|
-
|
188
|
+
exc = test_exception? Oktest::FAIL_EXCEPTION do
|
175
189
|
JSON(actual) === {
|
176
190
|
"items": [{"name": String, "id?": 1000..9999}].each
|
177
191
|
}
|
192
|
+
test_es exc.message, errmsg
|
178
193
|
end
|
179
194
|
end
|
180
|
-
|
195
|
+
test_subject "[!bz74w] fails when array lengths are different." do
|
181
196
|
actual = {"arr": ["A", "B", "C"]}
|
182
197
|
errmsg = ("$<JSON>[\"arr\"]: $<actual>.length == $<expected>.length : failed.\n"\
|
183
198
|
" $<actual>.length: 3\n"\
|
184
199
|
" $<expected>.length: 4\n"\
|
185
200
|
" $<actual>: [\"A\", \"B\", \"C\"]\n"\
|
186
201
|
" $<expected>: [\"A\", \"B\", \"C\", \"D\"]\n")
|
187
|
-
|
202
|
+
exc = test_exception? Oktest::FAIL_EXCEPTION do
|
188
203
|
JSON(actual) === {"arr": ["A", "B", "C", "D"]}
|
189
204
|
end
|
205
|
+
test_eq? exc.message, errmsg
|
190
206
|
end
|
191
|
-
|
207
|
+
test_subject "[!fmxyg] compares hash objects recursively." do
|
192
208
|
actual = {
|
193
209
|
"owner": {"name": "Alice", "age": 20},
|
194
210
|
"item": {"id": 10001, "name": "Something", "price": 500},
|
@@ -197,228 +213,242 @@ class JsonMatcher_TC < TC
|
|
197
213
|
"owner": {"name": String, "age": 0..100},
|
198
214
|
"item": {"id": 1..99999, "name": String, "price?": Numeric},
|
199
215
|
}
|
200
|
-
|
216
|
+
test_eq? result, true
|
201
217
|
#
|
202
218
|
errmsg = ("$<JSON>[\"item\"][\"price\"]: $<expected> === $<actual> : failed.\n"\
|
203
219
|
" $<actual>: 500\n"\
|
204
220
|
" $<expected>: Float\n")
|
205
|
-
|
221
|
+
exc = test_exception? Oktest::FAIL_EXCEPTION do
|
206
222
|
JSON(actual) === {
|
207
223
|
"owner": {"name": String, "age": 0..100},
|
208
224
|
"item": {"id": 1..99999, "name": String, "price?": Float},
|
209
225
|
}
|
210
226
|
end
|
227
|
+
test_eq? exc.message, errmsg
|
211
228
|
end
|
212
|
-
|
229
|
+
test_subject "[!rkv0z] compares two hashes with converting keys into string." do
|
213
230
|
actual1 = {k1: "A", k2: "B"}
|
214
231
|
result = JSON(actual1) === {"k1"=>"A", "k2"=>"B"}
|
215
|
-
|
232
|
+
test_eq? result, true
|
216
233
|
#
|
217
234
|
actual2 = {"k1"=>"A", "k2"=>"B"}
|
218
235
|
result = JSON(actual2) === {k1: "A", k2: "B"}
|
219
|
-
|
236
|
+
test_eq? result, true
|
220
237
|
end
|
221
|
-
|
238
|
+
test_subject "[!jbyv6] key 'aaa?' represents optional key." do
|
222
239
|
actual1 = {"name": "alice", "birth": "2000-01-01"}
|
223
240
|
result = JSON(actual1) === {"name": "alice", "birth?": "2000-01-01"}
|
224
|
-
|
241
|
+
test_eq? result, true
|
225
242
|
#
|
226
243
|
actual2 = {"name": "alice"}
|
227
244
|
result = JSON(actual2) === {"name": "alice", "birth?": "2000-01-01"}
|
228
|
-
|
245
|
+
test_eq? result, true
|
229
246
|
#
|
230
247
|
actual3 = {"name": "alice", "birth": nil}
|
231
248
|
result = JSON(actual3) === {"name": "alice", "birth?": "2000-01-01"}
|
232
|
-
|
249
|
+
test_eq? result, true
|
233
250
|
#
|
234
251
|
actual4 = {"name": "alice", "birth?": "2000-01-01"} # TODO
|
235
252
|
result = JSON(actual4) === {"name": "alice", "birth?": "2000-01-01"}
|
236
|
-
|
253
|
+
test_eq? result, true
|
237
254
|
end
|
238
|
-
|
255
|
+
test_subject "[!mpbvu] fails when unexpected key exists in actual hash." do
|
239
256
|
actual = {"id": 101, "name": "Alice"}
|
240
257
|
errmsg = ("$<JSON>: key \"gender\" expected but not found.\n"\
|
241
258
|
" $<actual>.keys: \"id\", \"name\"\n"\
|
242
259
|
" $<expected>.keys: \"gender\", \"id\", \"name\"\n")
|
243
|
-
|
260
|
+
exc = test_exception? Oktest::FAIL_EXCEPTION do
|
244
261
|
JSON(actual) === {"id": Integer, "name": String, "gender": String}
|
245
262
|
end
|
263
|
+
test_eq? exc.message, errmsg
|
246
264
|
end
|
247
|
-
|
265
|
+
test_subject "[!4oasq] fails when expected key not exist in actual hash." do
|
248
266
|
actual = {"id": 101, "name": "Alice"}
|
249
267
|
errmsg = ("$<JSON>[\"id\"]: unexpected key.\n"\
|
250
268
|
" $<actual>: 101\n")
|
251
|
-
|
269
|
+
exc = test_exception? Oktest::FAIL_EXCEPTION do
|
252
270
|
JSON(actual) === {"name": String}
|
253
271
|
end
|
272
|
+
test_eq? exc.message, errmsg
|
254
273
|
end
|
255
|
-
|
274
|
+
test_subject "[!eqr3b] `OR()` matches to any of arguments." do
|
256
275
|
result = JSON({"val": 123}) === {"val": OR(String, Integer)}
|
257
|
-
|
276
|
+
test_eq? result, true
|
258
277
|
result = JSON({"val": "123"}) === {"val": OR(String, Integer)}
|
259
|
-
|
278
|
+
test_eq? result, true
|
260
279
|
#
|
261
280
|
errmsg = ("$<JSON>[\"val\"]: $<expected> === $<actual> : failed.\n"\
|
262
281
|
" $<actual>: 3.14\n"\
|
263
282
|
" $<expected>: OR(String, Integer)\n")
|
264
|
-
|
283
|
+
exc = test_exception? Oktest::FAIL_EXCEPTION do
|
265
284
|
JSON({"val": 3.14}) === {"val": OR(String, Integer)}
|
266
285
|
end
|
286
|
+
test_eq? exc.message, errmsg
|
267
287
|
end
|
268
|
-
|
288
|
+
test_subject "[!4hk96] `AND()` matches to all of arguments." do
|
269
289
|
result = JSON({"val": "alice"}) === {"val": AND(String, /^[a-z]+$/)}
|
270
|
-
|
290
|
+
test_eq? result, true
|
271
291
|
#
|
272
292
|
errmsg = ("$<JSON>[\"val\"]: $<expected> === $<actual> : failed.\n"\
|
273
293
|
" $<actual>: \"Alice\"\n"\
|
274
294
|
" $<expected>: AND(/^[a-z]+$/)\n")
|
275
|
-
|
295
|
+
exc = test_exception? Oktest::FAIL_EXCEPTION do
|
276
296
|
JSON({"val": "Alice"}) === {"val": AND(String, /^[a-z]+$/)}
|
277
297
|
end
|
298
|
+
test_eq? exc.message, errmsg
|
278
299
|
end
|
279
|
-
|
300
|
+
test_subject "[!5ybfg] `OR()` can contain `AND()`." do
|
280
301
|
expected = {"val": OR(AND(String, /^\d+$/), AND(Integer, 100..999))}
|
281
302
|
result = JSON({"val": "123"}) === expected
|
282
|
-
|
303
|
+
test_eq? result, true
|
283
304
|
result = JSON({"val": 123}) === expected
|
284
|
-
|
305
|
+
test_eq? result, true
|
285
306
|
#
|
286
307
|
errmsg = ("$<JSON>[\"val\"]: $<expected> === $<actual> : failed.\n"\
|
287
308
|
" $<actual>: \"abc\"\n"\
|
288
309
|
" $<expected>: OR(AND(String, /^\\d+$/), AND(Integer, 100..999))\n")
|
289
|
-
|
310
|
+
exc = test_exception? Oktest::FAIL_EXCEPTION do
|
290
311
|
JSON({"val": "abc"}) === expected
|
291
312
|
end
|
313
|
+
test_eq? exc.message, errmsg
|
292
314
|
errmsg = ("$<JSON>[\"val\"]: $<expected> === $<actual> : failed.\n"\
|
293
315
|
" $<actual>: 99\n"\
|
294
316
|
" $<expected>: OR(AND(String, /^\\d+$/), AND(Integer, 100..999))\n")
|
295
|
-
|
317
|
+
exc = test_exception? Oktest::FAIL_EXCEPTION do
|
296
318
|
JSON({"val": 99}) === expected
|
297
319
|
end
|
320
|
+
test_eq? exc.message, errmsg
|
298
321
|
end
|
299
|
-
|
322
|
+
test_subject "[!scx22] `AND()` can contain `OR()`." do
|
300
323
|
expected = {"val": AND(OR(String, Integer), OR(/^\d{3}$/, 100..999))}
|
301
324
|
result = JSON({"val": "123"}) === expected
|
302
|
-
|
325
|
+
test_eq? result, true
|
303
326
|
result = JSON({"val": 123}) === expected
|
304
|
-
|
327
|
+
test_eq? result, true
|
305
328
|
#
|
306
329
|
errmsg = ("$<JSON>[\"val\"]: $<expected> === $<actual> : failed.\n"\
|
307
330
|
" $<actual>: \"1\"\n"\
|
308
331
|
" $<expected>: AND(OR(/^\\d{3}$/, 100..999))\n")
|
309
|
-
|
332
|
+
exc = test_exception? Oktest::FAIL_EXCEPTION do
|
310
333
|
JSON({"val": "1"}) === expected
|
311
334
|
end
|
335
|
+
test_eq? exc.message, errmsg
|
312
336
|
errmsg = ("$<JSON>[\"val\"]: $<expected> === $<actual> : failed.\n"\
|
313
337
|
" $<actual>: 0\n"\
|
314
338
|
" $<expected>: AND(OR(/^\\d{3}$/, 100..999))\n")
|
315
|
-
|
339
|
+
exc = test_exception? Oktest::FAIL_EXCEPTION do
|
316
340
|
JSON({"val": 0}) === expected
|
317
341
|
end
|
342
|
+
test_eq? exc.message, errmsg
|
318
343
|
end
|
319
|
-
|
344
|
+
test_subject "[!uc4ag] key '*' matches to any key name." do
|
320
345
|
actual = {"name": "Alice", "age": 20}
|
321
346
|
result = JSON(actual) === {"name": String, "*": Integer}
|
322
|
-
|
347
|
+
test_eq? result, true
|
323
348
|
result = JSON(actual) === {"name": String, "*": ANY()}
|
324
|
-
|
349
|
+
test_eq? result, true
|
325
350
|
end
|
326
351
|
end
|
327
352
|
|
328
|
-
|
329
|
-
|
353
|
+
test_target 'Oktest::JsonMatcher#_compare?()' do
|
354
|
+
test_subject "[!nkvqo] returns true when nothing raised." do
|
330
355
|
result = JSON(nil).instance_eval { _compare?([], "abc", /^\w+$/) }
|
331
|
-
|
356
|
+
test_eq? result, true
|
332
357
|
end
|
333
|
-
|
358
|
+
test_subject "[!57m2j] returns false when assertion error raised." do
|
334
359
|
result = JSON(nil).instance_eval { _compare?([], "abc", /^\d+$/) }
|
335
|
-
|
360
|
+
test_eq? result, false
|
336
361
|
end
|
337
362
|
end
|
338
363
|
|
339
364
|
end
|
340
365
|
|
341
366
|
|
342
|
-
class
|
367
|
+
class JsonMatcher_OR__Test
|
368
|
+
extend NanoTest
|
343
369
|
|
344
|
-
|
345
|
-
|
370
|
+
test_target 'Oktest::JsonMatcher::OR#inspect()' do
|
371
|
+
test_subject "[!2mu33] returns 'OR(...)' string." do
|
346
372
|
o = Oktest::JsonMatcher::OR.new('A', 'B', 'C')
|
347
|
-
|
373
|
+
test_eq? o.inspect(), 'OR("A", "B", "C")'
|
348
374
|
end
|
349
375
|
end
|
350
376
|
|
351
377
|
end
|
352
378
|
|
353
379
|
|
354
|
-
class
|
380
|
+
class JsonMatcher_AND__Test
|
381
|
+
extend NanoTest
|
355
382
|
|
356
|
-
|
357
|
-
|
383
|
+
test_target 'Oktest::JsonMatcher::AND#inspect()' do
|
384
|
+
test_subject "[!w43ag] returns 'AND(...)' string." do
|
358
385
|
o = Oktest::JsonMatcher::AND.new('A', 'B', 'C')
|
359
|
-
|
386
|
+
test_eq? o.inspect(), 'AND("A", "B", "C")'
|
360
387
|
end
|
361
388
|
end
|
362
389
|
|
363
390
|
end
|
364
391
|
|
365
392
|
|
366
|
-
class
|
393
|
+
class JsonMatcher_Enum__Test
|
394
|
+
extend NanoTest
|
367
395
|
|
368
|
-
|
369
|
-
|
396
|
+
test_target 'Oktest::JsonMatcher::Enum#inspect()' do
|
397
|
+
test_subject "[!fam11] returns 'Enum(...)' string." do
|
370
398
|
o = Oktest::JsonMatcher::Enum.new(['A', 'B', 'C'])
|
371
|
-
|
399
|
+
test_eq? o.inspect(), 'Enum("A", "B", "C")'
|
372
400
|
end
|
373
401
|
end
|
374
402
|
|
375
403
|
end
|
376
404
|
|
377
405
|
|
378
|
-
class
|
406
|
+
class JsonMatcher_Length__Test
|
407
|
+
extend NanoTest
|
379
408
|
|
380
|
-
|
381
|
-
|
409
|
+
test_target 'Oktest::JsonMatcher::Length#===' do
|
410
|
+
test_subject "[!03ozi] compares length of actual value with expected value." do
|
382
411
|
o1 = Oktest::JsonMatcher::Length.new(3)
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
412
|
+
test_eq? (o1 === "abc"), true
|
413
|
+
test_eq? (o1 === "abcd"), false
|
414
|
+
test_eq? (o1 === [1,2,3]), true
|
415
|
+
test_eq? (o1 === [1, 2]), false
|
387
416
|
o2 = Oktest::JsonMatcher::Length.new(1..3)
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
417
|
+
test_eq? (o2 === "a"), true
|
418
|
+
test_eq? (o2 === "abc"), true
|
419
|
+
test_eq? (o2 === ""), false
|
420
|
+
test_eq? (o2 === "abcd"), false
|
392
421
|
end
|
393
422
|
end
|
394
423
|
|
395
|
-
|
396
|
-
|
424
|
+
test_target 'Oktest::JsonMatcher::Length#inspect()' do
|
425
|
+
test_subject "[!nwv3e] returns 'Length(n)' string." do
|
397
426
|
o = Oktest::JsonMatcher::Length.new(1..3)
|
398
|
-
|
427
|
+
test_eq? o.inspect, "Length(1..3)"
|
399
428
|
end
|
400
429
|
end
|
401
430
|
|
402
431
|
end
|
403
432
|
|
404
433
|
|
405
|
-
class
|
434
|
+
class JsonMatcher_Any__Test
|
435
|
+
extend NanoTest
|
406
436
|
|
407
|
-
|
408
|
-
|
437
|
+
test_target 'Oktest::JsonMatcher::Any#===' do
|
438
|
+
test_subject "[!mzion] returns true in any case." do
|
409
439
|
o = Oktest::JsonMatcher::Any.new()
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
440
|
+
test_eq? (o === nil) , true
|
441
|
+
test_eq? (o === true) , true
|
442
|
+
test_eq? (o === false), true
|
443
|
+
test_eq? (o === 123) , true
|
444
|
+
test_eq? (o === "abc"), true
|
415
445
|
end
|
416
446
|
end
|
417
447
|
|
418
|
-
|
419
|
-
|
448
|
+
test_target 'Oktest::JsonMatcher::Any#inspect()' do
|
449
|
+
test_subject "[!6f0yv] returns 'Any()' string." do
|
420
450
|
o = Oktest::JsonMatcher::Any.new()
|
421
|
-
|
451
|
+
test_eq? o.inspect, "Any()"
|
422
452
|
end
|
423
453
|
end
|
424
454
|
|