assert_json 0.4.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +8 -0
- data/README.md +1 -1
- data/lib/assert_json/assert_json.rb +4 -8
- data/lib/assert_json/version.rb +1 -1
- data/test/assert_json_has_only_test.rb +4 -4
- data/test/assert_json_new_dsl_test.rb +39 -39
- data/test/assert_json_test.rb +20 -20
- metadata +6 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: adcc1cd3d4dd4ac74f94333e28f3a400a119569eb02b1fee3fa77cf90ee2dfc8
|
4
|
+
data.tar.gz: 446595a7e94a099449c85bae25c4c65b864003b71ade754136f888bc1c9f50b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d7621576448a513b6215fbf2c9f07159a5cd223eca8ba9cf0ea677c594129f6bbe5ac5218cdea001452f788a281508d5690b97104fa4a68e161ad3b96beb83f
|
7
|
+
data.tar.gz: 7b42d6311c17bddb6fa6a471daf155c30a1d58df40b571ac3dfe1d2c726d41d4f1eb5402557cde078b83b9d92f6a545230557b91b9eaaf02f0a49f1fb142a696
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
+
## 1.0.0
|
4
|
+
|
5
|
+
* breaking change: drop support for test-unit and older versions of minitest
|
6
|
+
|
7
|
+
## 0.4.1
|
8
|
+
|
9
|
+
* remove conflicts with test/unit (see [issue 10](https://github.com/alto/assert_json/issues/10) for details, thanks to [@thomasjachmann](https://github.com/thomasjachmann), for [fixing this](https://github.com/alto/assert_json/pull/11))
|
10
|
+
|
3
11
|
## 0.4.0
|
4
12
|
|
5
13
|
* add support for `size` (to test the size of arrays and hashes) (thanks to [@thomasjachmann](https://github.com/thomasjachmann), see [pull request 9](https://github.com/alto/assert_json/pull/9))
|
data/README.md
CHANGED
@@ -9,8 +9,8 @@ module AssertJson
|
|
9
9
|
@json.test_for_unexpected_keys('root')
|
10
10
|
end
|
11
11
|
|
12
|
-
def
|
13
|
-
@json.
|
12
|
+
def has_length_of(expected)
|
13
|
+
@json.has_length_of(expected)
|
14
14
|
end
|
15
15
|
|
16
16
|
def item(index, &block)
|
@@ -39,7 +39,7 @@ module AssertJson
|
|
39
39
|
@only = false
|
40
40
|
end
|
41
41
|
|
42
|
-
def
|
42
|
+
def has_length_of(expected)
|
43
43
|
raise_error("element #{@decoded_json.inspect} is not sizable") unless @decoded_json.respond_to?(:size)
|
44
44
|
return if @decoded_json.size == expected
|
45
45
|
raise_error("element #{@decoded_json.inspect} has #{@decoded_json.size} items, expected #{expected}")
|
@@ -155,11 +155,7 @@ module AssertJson
|
|
155
155
|
private
|
156
156
|
|
157
157
|
def raise_error(message)
|
158
|
-
|
159
|
-
fail MiniTest::Assertion, message
|
160
|
-
else
|
161
|
-
fail Test::Unit::AssertionFailedError, message
|
162
|
-
end
|
158
|
+
fail Minitest::Assertion, message
|
163
159
|
end
|
164
160
|
end
|
165
161
|
end
|
data/lib/assert_json/version.rb
CHANGED
@@ -14,7 +14,7 @@ class AssertJsonHasNoUnexpectedKeysTest < Minitest::Test
|
|
14
14
|
end
|
15
15
|
|
16
16
|
should "test_on_root_object_failure" do
|
17
|
-
err = assert_raises(
|
17
|
+
err = assert_raises(Minitest::Assertion) do
|
18
18
|
assert_json '{"keyA":"value","keyB":"value"}' do
|
19
19
|
has_only
|
20
20
|
has 'keyA', 'value'
|
@@ -35,7 +35,7 @@ class AssertJsonHasNoUnexpectedKeysTest < Minitest::Test
|
|
35
35
|
end
|
36
36
|
|
37
37
|
should "test_on_root_object_with_sub_object_failure" do
|
38
|
-
err = assert_raises(
|
38
|
+
err = assert_raises(Minitest::Assertion) do
|
39
39
|
assert_json '{"keyA":{"subKeyA":"value","subKeyB":"value"},"keyB":"value"}' do
|
40
40
|
has_only
|
41
41
|
has 'keyA' do
|
@@ -58,7 +58,7 @@ class AssertJsonHasNoUnexpectedKeysTest < Minitest::Test
|
|
58
58
|
end
|
59
59
|
|
60
60
|
should "test_on_sub_object_failure" do
|
61
|
-
err = assert_raises(
|
61
|
+
err = assert_raises(Minitest::Assertion) do
|
62
62
|
assert_json '{"keyA":{"subKeyA":"value","subKeyB":"value"},"keyB":"value"}' do
|
63
63
|
has 'keyA' do
|
64
64
|
has_only
|
@@ -98,7 +98,7 @@ JSON
|
|
98
98
|
end
|
99
99
|
|
100
100
|
should "test_on_root_array_of_objects_failure" do
|
101
|
-
err = assert_raises(
|
101
|
+
err = assert_raises(Minitest::Assertion) do
|
102
102
|
json = <<JSON
|
103
103
|
[
|
104
104
|
{
|
@@ -11,7 +11,7 @@ class AssertJsonNewDslTest < Minitest::Test
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
should "test_string_crosscheck" do
|
14
|
-
assert_raises(
|
14
|
+
assert_raises(Minitest::Assertion) do
|
15
15
|
assert_json '"key"' do
|
16
16
|
has 'wrong_key'
|
17
17
|
end
|
@@ -42,14 +42,14 @@ class AssertJsonNewDslTest < Minitest::Test
|
|
42
42
|
end
|
43
43
|
end
|
44
44
|
should "test_single_hash_crosscheck_for_key" do
|
45
|
-
assert_raises(
|
45
|
+
assert_raises(Minitest::Assertion) do
|
46
46
|
assert_json '{"key":"value"}' do
|
47
47
|
has 'wrong_key', 'value'
|
48
48
|
end
|
49
49
|
end
|
50
50
|
end
|
51
51
|
should "test_single_hash_crosscheck_for_value" do
|
52
|
-
assert_raises(
|
52
|
+
assert_raises(Minitest::Assertion) do
|
53
53
|
assert_json '{"key":"value"}' do
|
54
54
|
has 'key', 'wrong_value'
|
55
55
|
end
|
@@ -63,7 +63,7 @@ class AssertJsonNewDslTest < Minitest::Test
|
|
63
63
|
end
|
64
64
|
end
|
65
65
|
should "test_has_not_crosscheck" do
|
66
|
-
assert_raises(
|
66
|
+
assert_raises(Minitest::Assertion) do
|
67
67
|
assert_json '{"key":"value"}' do
|
68
68
|
has_not 'key'
|
69
69
|
end
|
@@ -87,21 +87,21 @@ class AssertJsonNewDslTest < Minitest::Test
|
|
87
87
|
end
|
88
88
|
end
|
89
89
|
should "test_array_crosscheck_order" do
|
90
|
-
assert_raises(
|
90
|
+
assert_raises(Minitest::Assertion) do
|
91
91
|
assert_json '["value1","value2","value3"]' do
|
92
92
|
has 'value2'
|
93
93
|
end
|
94
94
|
end
|
95
95
|
end
|
96
96
|
should "test_array_crosscheck_for_first_item" do
|
97
|
-
assert_raises(
|
97
|
+
assert_raises(Minitest::Assertion) do
|
98
98
|
assert_json '["value1","value2","value3"]' do
|
99
99
|
has 'wrong_value1'
|
100
100
|
end
|
101
101
|
end
|
102
102
|
end
|
103
103
|
should "test_array_crosscheck_for_second_item" do
|
104
|
-
assert_raises(
|
104
|
+
assert_raises(Minitest::Assertion) do
|
105
105
|
assert_json '["value1","value2","value3"]' do
|
106
106
|
has 'value1'
|
107
107
|
has 'wrong_value2'
|
@@ -115,37 +115,37 @@ class AssertJsonNewDslTest < Minitest::Test
|
|
115
115
|
end
|
116
116
|
end
|
117
117
|
should "test_nested_arrays_crosscheck" do
|
118
|
-
assert_raises(
|
118
|
+
assert_raises(Minitest::Assertion) do
|
119
119
|
assert_json '[[["deep","another_depp"],["second_deep"]]]' do
|
120
120
|
has [%w(deep wrong_another_depp), %w(second_deep)]
|
121
121
|
end
|
122
122
|
end
|
123
|
-
assert_raises(
|
123
|
+
assert_raises(Minitest::Assertion) do
|
124
124
|
assert_json '[[["deep","another_depp"],["second_deep"]]]' do
|
125
125
|
has [%w(deep another_depp), %w(wrong_second_deep)]
|
126
126
|
end
|
127
127
|
end
|
128
128
|
end
|
129
129
|
|
130
|
-
should "
|
130
|
+
should "test_array_has_length_of" do
|
131
131
|
assert_json '["value1","value2"]' do
|
132
|
-
|
132
|
+
has_length_of 2
|
133
133
|
end
|
134
134
|
end
|
135
135
|
|
136
|
-
should "
|
137
|
-
assert_raises(
|
136
|
+
should "test_array_has_length_of_error" do
|
137
|
+
assert_raises(Minitest::Assertion) do
|
138
138
|
assert_json '["single value"]' do
|
139
|
-
|
139
|
+
has_length_of 2
|
140
140
|
end
|
141
141
|
end
|
142
142
|
end
|
143
143
|
|
144
|
-
should "
|
144
|
+
should "test_nested_array_has_length_of" do
|
145
145
|
assert_json '["value1",["value2.1","value2.2","value3.3"]]' do
|
146
|
-
|
146
|
+
has_length_of 2
|
147
147
|
item 1 do
|
148
|
-
|
148
|
+
has_length_of 3
|
149
149
|
end
|
150
150
|
end
|
151
151
|
end
|
@@ -174,13 +174,13 @@ class AssertJsonNewDslTest < Minitest::Test
|
|
174
174
|
has 'deep'
|
175
175
|
end
|
176
176
|
item 1 do
|
177
|
-
assert_raises(
|
177
|
+
assert_raises(Minitest::Assertion) do
|
178
178
|
has 'wrong_item_value'
|
179
179
|
end
|
180
180
|
end
|
181
181
|
end
|
182
182
|
item 1 do
|
183
|
-
assert_raises(
|
183
|
+
assert_raises(Minitest::Assertion) do
|
184
184
|
has 'unknown_item_value'
|
185
185
|
end
|
186
186
|
end
|
@@ -195,21 +195,21 @@ class AssertJsonNewDslTest < Minitest::Test
|
|
195
195
|
end
|
196
196
|
end
|
197
197
|
should "test_hash_with_value_array_crosscheck_wrong_key" do
|
198
|
-
assert_raises(
|
198
|
+
assert_raises(Minitest::Assertion) do
|
199
199
|
assert_json '{"key":["value1","value2"]}' do
|
200
200
|
has 'wrong_key', %w(value1 value2)
|
201
201
|
end
|
202
202
|
end
|
203
203
|
end
|
204
204
|
should "test_hash_with_value_array_crosscheck_wrong_value1" do
|
205
|
-
assert_raises(
|
205
|
+
assert_raises(Minitest::Assertion) do
|
206
206
|
assert_json '{"key":["value1","value2"]}' do
|
207
207
|
has 'key', %w(wrong_value1 value2)
|
208
208
|
end
|
209
209
|
end
|
210
210
|
end
|
211
211
|
should "test_hash_with_value_array_crosscheck_wrong_value2" do
|
212
|
-
assert_raises(
|
212
|
+
assert_raises(Minitest::Assertion) do
|
213
213
|
assert_json '{"key":["value1","value2"]}' do
|
214
214
|
has 'key', %w(value1 wrong_value2)
|
215
215
|
end
|
@@ -225,7 +225,7 @@ class AssertJsonNewDslTest < Minitest::Test
|
|
225
225
|
end
|
226
226
|
end
|
227
227
|
should "test_hash_with_array_of_hashes_crosscheck_inner_key" do
|
228
|
-
assert_raises(
|
228
|
+
assert_raises(Minitest::Assertion) do
|
229
229
|
assert_json '{"key":[{"inner_key1":"value1"},{"inner_key2":"value2"}]}' do
|
230
230
|
has 'key' do
|
231
231
|
has 'wrong_inner_key1', 'value1'
|
@@ -234,7 +234,7 @@ class AssertJsonNewDslTest < Minitest::Test
|
|
234
234
|
end
|
235
235
|
end
|
236
236
|
should "test_hash_with_array_of_hashes_crosscheck_inner_value" do
|
237
|
-
assert_raises(
|
237
|
+
assert_raises(Minitest::Assertion) do
|
238
238
|
assert_json '{"key":[{"inner_key1":"value1"},{"inner_key2":"value2"}]}' do
|
239
239
|
has 'key' do
|
240
240
|
has 'inner_key1', 'wrong_value1'
|
@@ -275,7 +275,7 @@ JSON
|
|
275
275
|
end
|
276
276
|
end
|
277
277
|
should "test_array_with_multi_item_hashes_crosscheck" do
|
278
|
-
assert_raises(
|
278
|
+
assert_raises(Minitest::Assertion) do
|
279
279
|
json = <<JSON
|
280
280
|
[
|
281
281
|
{
|
@@ -320,13 +320,13 @@ JSON
|
|
320
320
|
end
|
321
321
|
end
|
322
322
|
should "test_array_with_two_hashes_crosscheck" do
|
323
|
-
assert_raises(
|
323
|
+
assert_raises(Minitest::Assertion) do
|
324
324
|
assert_json '[{"key1":"value1"}, {"key2":"value2"}]' do
|
325
325
|
has 'wrong_key1', 'value1'
|
326
326
|
has 'key2', 'value2'
|
327
327
|
end
|
328
328
|
end
|
329
|
-
assert_raises(
|
329
|
+
assert_raises(Minitest::Assertion) do
|
330
330
|
assert_json '[{"key1":"value1"}, {"key2":"value2"}]' do
|
331
331
|
has 'key1', 'value1'
|
332
332
|
has 'key2', 'wrong_value2'
|
@@ -346,12 +346,12 @@ JSON
|
|
346
346
|
end
|
347
347
|
end
|
348
348
|
should "test_nested_hashes_crosscheck" do
|
349
|
-
assert_raises(
|
349
|
+
assert_raises(Minitest::Assertion) do
|
350
350
|
assert_json '{"outer_key":{"key":{"inner_key":"value"}}}' do
|
351
351
|
has 'wrong_outer_key'
|
352
352
|
end
|
353
353
|
end
|
354
|
-
assert_raises(
|
354
|
+
assert_raises(Minitest::Assertion) do
|
355
355
|
assert_json '{"outer_key":{"key":{"inner_key":"value"}}}' do
|
356
356
|
has 'outer_key' do
|
357
357
|
has 'key' do
|
@@ -435,7 +435,7 @@ JSON
|
|
435
435
|
|
436
436
|
context "not enough elements" do
|
437
437
|
should "test_not_enough_hass_in_array" do
|
438
|
-
assert_raises(
|
438
|
+
assert_raises(Minitest::Assertion) do
|
439
439
|
assert_json '["one","two"]' do
|
440
440
|
has "one"
|
441
441
|
has "two"
|
@@ -445,7 +445,7 @@ JSON
|
|
445
445
|
end
|
446
446
|
|
447
447
|
should "test_not_enough_hass_in_hash_array" do
|
448
|
-
assert_raises(
|
448
|
+
assert_raises(Minitest::Assertion) do
|
449
449
|
assert_json '{"key":[{"key1":"value1"}, {"key2":"value2"}]}' do
|
450
450
|
has 'key' do
|
451
451
|
has 'key1', 'value1'
|
@@ -468,12 +468,12 @@ JSON
|
|
468
468
|
end
|
469
469
|
|
470
470
|
should "test_boolean_crosscheck" do
|
471
|
-
assert_raises(
|
471
|
+
assert_raises(Minitest::Assertion) do
|
472
472
|
assert_json '{"key": false}' do
|
473
473
|
has 'key', true
|
474
474
|
end
|
475
475
|
end
|
476
|
-
assert_raises(
|
476
|
+
assert_raises(Minitest::Assertion) do
|
477
477
|
assert_json '{"key": true}' do
|
478
478
|
has 'key', false
|
479
479
|
end
|
@@ -489,7 +489,7 @@ JSON
|
|
489
489
|
end
|
490
490
|
|
491
491
|
should "test_not_null" do
|
492
|
-
assert_raises(
|
492
|
+
assert_raises(Minitest::Assertion) do
|
493
493
|
assert_json '{"key": 1}' do
|
494
494
|
has 'key', nil
|
495
495
|
end
|
@@ -497,7 +497,7 @@ JSON
|
|
497
497
|
end
|
498
498
|
|
499
499
|
should "test_null_crosscheck" do
|
500
|
-
assert_raises(
|
500
|
+
assert_raises(Minitest::Assertion) do
|
501
501
|
assert_json '{"key": null}' do
|
502
502
|
has_not 'key'
|
503
503
|
end
|
@@ -510,7 +510,7 @@ JSON
|
|
510
510
|
assert_json '{"key": "text"}' do
|
511
511
|
has :key, :text
|
512
512
|
end
|
513
|
-
assert_raises(
|
513
|
+
assert_raises(Minitest::Assertion) do
|
514
514
|
assert_json '{"key": "badtext"}' do
|
515
515
|
has :key, :text
|
516
516
|
end
|
@@ -544,7 +544,7 @@ JSON
|
|
544
544
|
end
|
545
545
|
|
546
546
|
should "test_symbol_as_a_key_crossheck" do
|
547
|
-
assert_raises(
|
547
|
+
assert_raises(Minitest::Assertion) do
|
548
548
|
assert_json '{"text": "1"}' do
|
549
549
|
has :sym, true # this should fail
|
550
550
|
has :text, /\d+/
|
@@ -552,7 +552,7 @@ JSON
|
|
552
552
|
end
|
553
553
|
end
|
554
554
|
|
555
|
-
assert_raises(
|
555
|
+
assert_raises(Minitest::Assertion) do
|
556
556
|
assert_json '{"sym": false, "text": "abc"}' do
|
557
557
|
has :sym, false
|
558
558
|
has :text, /\d+/ # this should fail
|
@@ -560,7 +560,7 @@ JSON
|
|
560
560
|
end
|
561
561
|
end
|
562
562
|
|
563
|
-
assert_raises(
|
563
|
+
assert_raises(Minitest::Assertion) do
|
564
564
|
assert_json '{"sym": false}' do
|
565
565
|
has_not :sym
|
566
566
|
end
|
data/test/assert_json_test.rb
CHANGED
@@ -12,7 +12,7 @@ class AssertJsonTest < Minitest::Test
|
|
12
12
|
end
|
13
13
|
|
14
14
|
should "test_string_crosscheck" do
|
15
|
-
assert_raises(
|
15
|
+
assert_raises(Minitest::Assertion) do
|
16
16
|
assert_json '"key"' do |json|
|
17
17
|
json.element 'wrong_key'
|
18
18
|
end
|
@@ -40,7 +40,7 @@ class AssertJsonTest < Minitest::Test
|
|
40
40
|
end
|
41
41
|
|
42
42
|
should "test_single_hash_crosscheck_for_key" do
|
43
|
-
assert_raises(
|
43
|
+
assert_raises(Minitest::Assertion) do
|
44
44
|
assert_json '{"key":"value"}' do |json|
|
45
45
|
json.element 'wrong_key', 'value'
|
46
46
|
end
|
@@ -48,7 +48,7 @@ class AssertJsonTest < Minitest::Test
|
|
48
48
|
end
|
49
49
|
|
50
50
|
should "test_single_hash_crosscheck_for_value" do
|
51
|
-
assert_raises(
|
51
|
+
assert_raises(Minitest::Assertion) do
|
52
52
|
assert_json '{"key":"value"}' do |json|
|
53
53
|
json.element 'key', 'wrong_value'
|
54
54
|
end
|
@@ -63,7 +63,7 @@ class AssertJsonTest < Minitest::Test
|
|
63
63
|
end
|
64
64
|
|
65
65
|
should "test_not_element_crosscheck" do
|
66
|
-
assert_raises(
|
66
|
+
assert_raises(Minitest::Assertion) do
|
67
67
|
assert_json '{"key":"value"}' do |json|
|
68
68
|
json.not_element 'key'
|
69
69
|
end
|
@@ -87,21 +87,21 @@ class AssertJsonTest < Minitest::Test
|
|
87
87
|
end
|
88
88
|
end
|
89
89
|
should "test_array_crosscheck_order" do
|
90
|
-
assert_raises(
|
90
|
+
assert_raises(Minitest::Assertion) do
|
91
91
|
assert_json '["value1","value2","value3"]' do |json|
|
92
92
|
json.element 'value2'
|
93
93
|
end
|
94
94
|
end
|
95
95
|
end
|
96
96
|
should "test_array_crosscheck_for_first_item" do
|
97
|
-
assert_raises(
|
97
|
+
assert_raises(Minitest::Assertion) do
|
98
98
|
assert_json '["value1","value2","value3"]' do |json|
|
99
99
|
json.element 'wrong_value1'
|
100
100
|
end
|
101
101
|
end
|
102
102
|
end
|
103
103
|
should "test_array_crosscheck_for_second_item" do
|
104
|
-
assert_raises(
|
104
|
+
assert_raises(Minitest::Assertion) do
|
105
105
|
assert_json '["value1","value2","value3"]' do |json|
|
106
106
|
json.element 'value1'
|
107
107
|
json.element 'wrong_value2'
|
@@ -115,12 +115,12 @@ class AssertJsonTest < Minitest::Test
|
|
115
115
|
end
|
116
116
|
end
|
117
117
|
should "test_nested_arrays_crosscheck" do
|
118
|
-
assert_raises(
|
118
|
+
assert_raises(Minitest::Assertion) do
|
119
119
|
assert_json '[[["deep","another_depp"],["second_deep"]]]' do |json|
|
120
120
|
json.element [%w(deep wrong_another_depp), %w(second_deep)]
|
121
121
|
end
|
122
122
|
end
|
123
|
-
assert_raises(
|
123
|
+
assert_raises(Minitest::Assertion) do
|
124
124
|
assert_json '[[["deep","another_depp"],["second_deep"]]]' do |json|
|
125
125
|
json.element [%w(deep another_depp), %w(wrong_second_deep)]
|
126
126
|
end
|
@@ -133,21 +133,21 @@ class AssertJsonTest < Minitest::Test
|
|
133
133
|
end
|
134
134
|
end
|
135
135
|
should "test_hash_with_value_array_crosscheck_wrong_key" do
|
136
|
-
assert_raises(
|
136
|
+
assert_raises(Minitest::Assertion) do
|
137
137
|
assert_json '{"key":["value1","value2"]}' do |json|
|
138
138
|
json.element 'wrong_key', %w(value1 value2)
|
139
139
|
end
|
140
140
|
end
|
141
141
|
end
|
142
142
|
should "test_hash_with_value_array_crosscheck_wrong_value1" do
|
143
|
-
assert_raises(
|
143
|
+
assert_raises(Minitest::Assertion) do
|
144
144
|
assert_json '{"key":["value1","value2"]}' do |json|
|
145
145
|
json.element 'key', %w(wrong_value1 value2)
|
146
146
|
end
|
147
147
|
end
|
148
148
|
end
|
149
149
|
should "test_hash_with_value_array_crosscheck_wrong_value2" do
|
150
|
-
assert_raises(
|
150
|
+
assert_raises(Minitest::Assertion) do
|
151
151
|
assert_json '{"key":["value1","value2"]}' do |json|
|
152
152
|
json.element 'key', %w(value1 wrong_value2)
|
153
153
|
end
|
@@ -165,7 +165,7 @@ class AssertJsonTest < Minitest::Test
|
|
165
165
|
end
|
166
166
|
end
|
167
167
|
should "test_hash_with_array_of_hashes_crosscheck_inner_key" do
|
168
|
-
assert_raises(
|
168
|
+
assert_raises(Minitest::Assertion) do
|
169
169
|
assert_json '{"key":[{"inner_key1":"value1"},{"inner_key2":"value2"}]}' do |json|
|
170
170
|
json.element 'key' do
|
171
171
|
json.element 'wrong_inner_key1', 'value1'
|
@@ -174,7 +174,7 @@ class AssertJsonTest < Minitest::Test
|
|
174
174
|
end
|
175
175
|
end
|
176
176
|
should "test_hash_with_array_of_hashes_crosscheck_inner_value" do
|
177
|
-
assert_raises(
|
177
|
+
assert_raises(Minitest::Assertion) do
|
178
178
|
assert_json '{"key":[{"inner_key1":"value1"},{"inner_key2":"value2"}]}' do |json|
|
179
179
|
json.element 'key' do
|
180
180
|
json.element 'inner_key1', 'wrong_value1'
|
@@ -197,13 +197,13 @@ class AssertJsonTest < Minitest::Test
|
|
197
197
|
end
|
198
198
|
end
|
199
199
|
should "test_array_with_two_hashes_crosscheck" do
|
200
|
-
assert_raises(
|
200
|
+
assert_raises(Minitest::Assertion) do
|
201
201
|
assert_json '[{"key1":"value1"}, {"key2":"value2"}]' do |json|
|
202
202
|
json.element 'wrong_key1', 'value1'
|
203
203
|
json.element 'key2', 'value2'
|
204
204
|
end
|
205
205
|
end
|
206
|
-
assert_raises(
|
206
|
+
assert_raises(Minitest::Assertion) do
|
207
207
|
assert_json '[{"key1":"value1"}, {"key2":"value2"}]' do |json|
|
208
208
|
json.element 'key1', 'value1'
|
209
209
|
json.element 'key2', 'wrong_value2'
|
@@ -223,12 +223,12 @@ class AssertJsonTest < Minitest::Test
|
|
223
223
|
end
|
224
224
|
end
|
225
225
|
should "test_nested_hashes_crosscheck" do
|
226
|
-
assert_raises(
|
226
|
+
assert_raises(Minitest::Assertion) do
|
227
227
|
assert_json '{"outer_key":{"key":{"inner_key":"value"}}}' do |json|
|
228
228
|
json.element 'wrong_outer_key'
|
229
229
|
end
|
230
230
|
end
|
231
|
-
assert_raises(
|
231
|
+
assert_raises(Minitest::Assertion) do
|
232
232
|
assert_json '{"outer_key":{"key":{"inner_key":"value"}}}' do |json|
|
233
233
|
json.element 'outer_key' do
|
234
234
|
json.element 'key' do
|
@@ -267,7 +267,7 @@ JSON
|
|
267
267
|
|
268
268
|
context "not enough elements" do
|
269
269
|
should "test_not_enough_elements_in_array" do
|
270
|
-
assert_raises(
|
270
|
+
assert_raises(Minitest::Assertion) do
|
271
271
|
assert_json '["one","two"]' do |json|
|
272
272
|
json.element "one"
|
273
273
|
json.element "two"
|
@@ -277,7 +277,7 @@ JSON
|
|
277
277
|
end
|
278
278
|
|
279
279
|
should "test_not_enough_elements_in_hash_array" do
|
280
|
-
assert_raises(
|
280
|
+
assert_raises(Minitest::Assertion) do
|
281
281
|
assert_json '{"key":[{"key1":"value1"}, {"key2":"value2"}]}' do |json|
|
282
282
|
json.element 'key' do
|
283
283
|
json.element 'key1', 'value1'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: assert_json
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thorsten Böttger
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-08-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -94,7 +94,7 @@ homepage: https://github.com/alto/assert_json
|
|
94
94
|
licenses:
|
95
95
|
- MIT
|
96
96
|
metadata: {}
|
97
|
-
post_install_message:
|
97
|
+
post_install_message:
|
98
98
|
rdoc_options: []
|
99
99
|
require_paths:
|
100
100
|
- lib
|
@@ -109,9 +109,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
requirements: []
|
112
|
-
|
113
|
-
|
114
|
-
signing_key:
|
112
|
+
rubygems_version: 3.3.26
|
113
|
+
signing_key:
|
115
114
|
specification_version: 4
|
116
115
|
summary: A gem to test JSON strings.
|
117
116
|
test_files:
|