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.
data/test/matcher_test.rb CHANGED
@@ -2,193 +2,209 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  ###
5
- ### $Release: 1.4.0 $
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 './initialize'
10
+ require_relative './init'
11
11
  require 'set'
12
12
 
13
13
 
14
- class Matcher_TC < TC
14
+ class Matcher__Test
15
+ extend NanoTest
16
+ extend Oktest::SpecHelper
15
17
 
16
- describe '#===' do
17
- it "[!spybn] raises NotImplementedError." do
18
+ test_target 'Oktest::Matcher#===' do
19
+ test_subject "[!spybn] raises NotImplementedError." do
18
20
  errmsg = "Oktest::Matcher#===(): not implemented yet."
19
- assert_exc(NotImplementedError, errmsg) do
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
- describe '#==' do
26
- it "[!ymt1b] raises OktestError." do
28
+ test_target 'Oktest::Matcher#==' do
29
+ test_subject "[!ymt1b] raises OktestError." do
27
30
  errmsg = "JSON(): use `===` instead of `==`."
28
- assert_exc(Oktest::OktestError, errmsg) do
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
- describe '#fail()' do
35
- it "[!8qpsd] raises assertion error." do
38
+ test_target 'Oktest::Matcher#fail()' do
39
+ test_subject "[!8qpsd] raises assertion error." do
36
40
  errmsg = "<<errmsg>>"
37
- assert_exc(Oktest::FAIL_EXCEPTION, errmsg) do
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 JsonMatcher_TC < TC
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
- describe '#===' do
65
- it "[!4uf1o] raises assertion error when JSON not matched." do
66
- assert_exc(Oktest::FAIL_EXCEPTION) do
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
- it "[!0g0u4] returns true when JSON matched." do
76
+ test_subject "[!0g0u4] returns true when JSON matched." do
71
77
  result = JSON({"status": "ok"}) === {"status": "ok"}
72
- assert_eq result, true
78
+ test_eq? result, true
73
79
  end
74
- it "[!1ukbv] scalar value matches to integer, string, bool, and so son." do
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
- assert_eq result, true
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
- assert_exc(Oktest::FAIL_EXCEPTION, errmsg) do
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
- it "[!8o55d] class object matches to instance object." do
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
- assert_eq result, true
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
- assert_exc(Oktest::FAIL_EXCEPTION, errmsg) do
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
- it "[!s625d] regexp object matches to string value." do
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
- assert_eq result, true
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
- assert_exc(Oktest::FAIL_EXCEPTION, errmsg) do
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
- it "[!aqkk0] range object matches to scalar value." do
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
- assert_eq result, true
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
- assert_exc(Oktest::FAIL_EXCEPTION, errmsg) do
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
- it "[!4ymj2] fails when actual value is not matched to item class of range object." do
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
- assert_exc(Oktest::FAIL_EXCEPTION, errmsg) do
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
- it "[!a7bfs] Set object matches to enum value." do
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
- assert_eq result, true
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
- assert_exc(Oktest::FAIL_EXCEPTION, errmsg) do
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
- it "[!sh5cg] Enumerator object matches to repeat of rule." do
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
- assert_eq result, true
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
- assert_exc(Oktest::FAIL_EXCEPTION, errmsg) do
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
- it "[!ljrmc] fails when expected is an Enumerator object and actual is not an array." do
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
- assert_exc(Oktest::FAIL_EXCEPTION, errmsg) do
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
- it "[!lh6d6] compares array items recursively." do
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
- assert_eq result, true
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
- assert_exc(Oktest::FAIL_EXCEPTION, errmsg) do
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
- it "[!bz74w] fails when array lengths are different." do
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
- assert_exc(Oktest::FAIL_EXCEPTION, errmsg) do
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
- it "[!fmxyg] compares hash objects recursively." do
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
- assert_eq result, true
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
- assert_exc(Oktest::FAIL_EXCEPTION, errmsg) do
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
- it "[!rkv0z] compares two hashes with converting keys into string." do
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
- assert_eq result, true
232
+ test_eq? result, true
216
233
  #
217
234
  actual2 = {"k1"=>"A", "k2"=>"B"}
218
235
  result = JSON(actual2) === {k1: "A", k2: "B"}
219
- assert_eq result, true
236
+ test_eq? result, true
220
237
  end
221
- it "[!jbyv6] key 'aaa?' represents optional key." do
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
- assert_eq result, true
241
+ test_eq? result, true
225
242
  #
226
243
  actual2 = {"name": "alice"}
227
244
  result = JSON(actual2) === {"name": "alice", "birth?": "2000-01-01"}
228
- assert_eq result, true
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
- assert_eq result, true
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
- assert_eq result, true
253
+ test_eq? result, true
237
254
  end
238
- it "[!mpbvu] fails when unexpected key exists in actual hash." do
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
- assert_exc(Oktest::FAIL_EXCEPTION, errmsg) do
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
- it "[!4oasq] fails when expected key not exist in actual hash." do
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
- assert_exc(Oktest::FAIL_EXCEPTION, errmsg) do
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
- it "[!eqr3b] `OR()` matches to any of arguments." do
274
+ test_subject "[!eqr3b] `OR()` matches to any of arguments." do
256
275
  result = JSON({"val": 123}) === {"val": OR(String, Integer)}
257
- assert_eq result, true
276
+ test_eq? result, true
258
277
  result = JSON({"val": "123"}) === {"val": OR(String, Integer)}
259
- assert_eq result, true
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
- assert_exc(Oktest::FAIL_EXCEPTION, errmsg) do
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
- it "[!4hk96] `AND()` matches to all of arguments." do
288
+ test_subject "[!4hk96] `AND()` matches to all of arguments." do
269
289
  result = JSON({"val": "alice"}) === {"val": AND(String, /^[a-z]+$/)}
270
- assert_eq result, true
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
- assert_exc(Oktest::FAIL_EXCEPTION, errmsg) do
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
- it "[!5ybfg] `OR()` can contain `AND()`." do
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
- assert_eq result, true
303
+ test_eq? result, true
283
304
  result = JSON({"val": 123}) === expected
284
- assert_eq result, true
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
- assert_exc(Oktest::FAIL_EXCEPTION, errmsg) do
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
- assert_exc(Oktest::FAIL_EXCEPTION, errmsg) do
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
- it "[!scx22] `AND()` can contain `OR()`." do
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
- assert_eq result, true
325
+ test_eq? result, true
303
326
  result = JSON({"val": 123}) === expected
304
- assert_eq result, true
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
- assert_exc(Oktest::FAIL_EXCEPTION, errmsg) do
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
- assert_exc(Oktest::FAIL_EXCEPTION, errmsg) do
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
- it "[!uc4ag] key '*' matches to any key name." do
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
- assert_eq result, true
347
+ test_eq? result, true
323
348
  result = JSON(actual) === {"name": String, "*": ANY()}
324
- assert_eq result, true
349
+ test_eq? result, true
325
350
  end
326
351
  end
327
352
 
328
- describe '#_compare?()' do
329
- it "[!nkvqo] returns true when nothing raised." do
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
- assert_eq result, true
356
+ test_eq? result, true
332
357
  end
333
- it "[!57m2j] returns false when assertion error raised." do
358
+ test_subject "[!57m2j] returns false when assertion error raised." do
334
359
  result = JSON(nil).instance_eval { _compare?([], "abc", /^\d+$/) }
335
- assert_eq result, false
360
+ test_eq? result, false
336
361
  end
337
362
  end
338
363
 
339
364
  end
340
365
 
341
366
 
342
- class OR_TC < TC
367
+ class JsonMatcher_OR__Test
368
+ extend NanoTest
343
369
 
344
- describe '#inspect()' do
345
- it "[!2mu33] returns 'OR(...)' string." do
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
- assert_eq o.inspect(), 'OR("A", "B", "C")'
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 AND_TC < TC
380
+ class JsonMatcher_AND__Test
381
+ extend NanoTest
355
382
 
356
- describe '#inspect()' do
357
- it "[!w43ag] returns 'AND(...)' string." do
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
- assert_eq o.inspect(), 'AND("A", "B", "C")'
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 Enum_TC < TC
393
+ class JsonMatcher_Enum__Test
394
+ extend NanoTest
367
395
 
368
- describe '#inspect()' do
369
- it "[!fam11] returns 'Enum(...)' string." do
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
- assert_eq o.inspect(), 'Enum("A", "B", "C")'
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 Length_TC < TC
406
+ class JsonMatcher_Length__Test
407
+ extend NanoTest
379
408
 
380
- describe '#===' do
381
- it "[!03ozi] compares length of actual value with expected value." do
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
- assert_eq (o1 === "abc"), true
384
- assert_eq (o1 === "abcd"), false
385
- assert_eq (o1 === [1,2,3]), true
386
- assert_eq (o1 === [1, 2]), false
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
- assert_eq (o2 === "a"), true
389
- assert_eq (o2 === "abc"), true
390
- assert_eq (o2 === ""), false
391
- assert_eq (o2 === "abcd"), false
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
- describe '#inspect()' do
396
- it "[!nwv3e] returns 'Length(n)' string." do
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
- assert_eq o.inspect, "Length(1..3)"
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 Any_TC < TC
434
+ class JsonMatcher_Any__Test
435
+ extend NanoTest
406
436
 
407
- describe '#===' do
408
- it "[!mzion] returns true in any case." do
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
- assert_eq (o === nil) , true
411
- assert_eq (o === true) , true
412
- assert_eq (o === false), true
413
- assert_eq (o === 123) , true
414
- assert_eq (o === "abc"), true
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
- describe '#inspect()' do
419
- it "[!6f0yv] returns 'Any()' string." do
448
+ test_target 'Oktest::JsonMatcher::Any#inspect()' do
449
+ test_subject "[!6f0yv] returns 'Any()' string." do
420
450
  o = Oktest::JsonMatcher::Any.new()
421
- assert_eq o.inspect, "Any()"
451
+ test_eq? o.inspect, "Any()"
422
452
  end
423
453
  end
424
454