emery 0.0.2 → 0.0.8

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/enum_test.rb CHANGED
@@ -1,47 +1,43 @@
1
1
  require "test/unit/runner/junitxml"
2
2
 
3
- require 'emery/type'
4
- require 'emery/enum'
5
- require 'emery/jsoner'
6
-
7
- module Emery
8
- class TypeCheckEnum < Test::Unit::TestCase
9
- def test_success
10
- assert_equal SomeEnum::one, T.check(SomeEnum, SomeEnum::one), "Plain enum type should pass type check"
11
- end
3
+ require 'emery'
12
4
 
13
- def test_fail
14
- assert_raise TypeError do
15
- T.check(SomeEnum, "non existing")
16
- end
17
- end
5
+ class TypeCheckEnum < Test::Unit::TestCase
6
+ def test_success
7
+ assert_equal SomeEnum::one, T.check(SomeEnum, SomeEnum::one), "Plain enum type should pass type check"
18
8
  end
19
9
 
20
- class EnumDeserialization < Test::Unit::TestCase
21
- def test_deserialize_enum
22
- data = Jsoner.from_json(SomeEnum, '"two"')
23
- T.check(SomeEnum, data)
24
- assert_equal SomeEnum::two, data, "Enum should be parsable from JSON"
10
+ def test_fail
11
+ assert_raise TypeError do
12
+ T.check(SomeEnum, "non existing")
25
13
  end
14
+ end
15
+ end
26
16
 
27
- def test_deserialize_enum_non_existing_item
28
- assert_raise JsonerError do
29
- Jsoner.from_json(SomeEnum, '"non_existing"')
30
- end
31
- end
17
+ class EnumDeserialization < Test::Unit::TestCase
18
+ def test_deserialize_enum
19
+ data = Jsoner.from_json(SomeEnum, '"two"')
20
+ T.check(SomeEnum, data)
21
+ assert_equal SomeEnum::two, data, "Enum should be parsable from JSON"
32
22
  end
33
23
 
34
- class EnumSerialization < Test::Unit::TestCase
35
- def test_serialize_enum
36
- json_str = Jsoner.to_json(SomeEnum, SomeEnum::two)
37
- assert_equal '"two"', json_str, "Enum should be serializable to JSON"
24
+ def test_deserialize_enum_non_existing_item
25
+ assert_raise JsonerError do
26
+ Jsoner.from_json(SomeEnum, '"non_existing"')
38
27
  end
39
28
  end
29
+ end
40
30
 
41
- class SomeEnum
42
- include Enum
43
-
44
- define :one, 'one'
45
- define :two, 'two'
31
+ class EnumSerialization < Test::Unit::TestCase
32
+ def test_serialize_enum
33
+ json_str = Jsoner.to_json(SomeEnum, SomeEnum::two)
34
+ assert_equal '"two"', json_str, "Enum should be serializable to JSON"
46
35
  end
36
+ end
37
+
38
+ class SomeEnum
39
+ include Enum
40
+
41
+ define :one, 'one'
42
+ define :two, 'two'
47
43
  end
data/test/jsoner_test.rb CHANGED
@@ -1,260 +1,285 @@
1
1
  require "test/unit/runner/junitxml"
2
2
 
3
- require 'emery/type'
4
- require 'emery/jsoner'
5
-
6
- module Emery
7
- class PlainTypesDeserialization < Test::Unit::TestCase
8
- def test_deserialize_integer
9
- data = Jsoner.from_json(Integer, '123')
10
- T.check(Integer, data)
11
- assert_equal 123, data, "Integer should be parsable from JSON"
12
- end
3
+ require 'emery'
13
4
 
14
- def test_deserialize_integer_fail
15
- assert_raise JsonerError do
16
- Jsoner.from_json(Integer, '"abc"')
17
- end
18
- end
5
+ class PlainTypesDeserialization < Test::Unit::TestCase
6
+ def test_deserialize_integer
7
+ data = Jsoner.from_json(Integer, '123')
8
+ T.check(Integer, data)
9
+ assert_equal 123, data, "Integer should be parsable from JSON"
10
+ end
19
11
 
20
- def test_deserialize_float
21
- data = Jsoner.from_json(Float, '1.23')
22
- T.check(Float, data)
23
- assert_equal 1.23, data, "Float should be parsable from JSON"
12
+ def test_deserialize_integer_fail
13
+ assert_raise JsonerError do
14
+ Jsoner.from_json(Integer, '"abc"')
24
15
  end
16
+ end
25
17
 
26
- def test_deserialize_float_from_integer
27
- data = Jsoner.from_json(Float, '123')
28
- T.check(Float, data)
29
- assert_equal 123.0, data, "Float should be parsable from JSON"
30
- end
18
+ def test_deserialize_float
19
+ data = Jsoner.from_json(Float, '1.23')
20
+ T.check(Float, data)
21
+ assert_equal 1.23, data, "Float should be parsable from JSON"
22
+ end
31
23
 
32
- def test_deserialize_float_fail
33
- assert_raise JsonerError do
34
- Jsoner.from_json(Float, '"abc"')
35
- end
36
- end
24
+ def test_deserialize_float_from_integer
25
+ data = Jsoner.from_json(Float, '123')
26
+ T.check(Float, data)
27
+ assert_equal 123.0, data, "Float should be parsable from JSON"
28
+ end
37
29
 
38
- def test_deserialize_boolean
39
- data = Jsoner.from_json(Boolean, 'true')
40
- T.check(Boolean, data)
41
- assert_equal true, data, "Boolean should be parsable from JSON"
30
+ def test_deserialize_float_fail
31
+ assert_raise JsonerError do
32
+ Jsoner.from_json(Float, '"abc"')
42
33
  end
34
+ end
43
35
 
44
- def test_deserialize_boolean_fail
45
- assert_raise JsonerError do
46
- Jsoner.from_json(Boolean, '1')
47
- end
48
- end
36
+ def test_deserialize_true
37
+ data = Jsoner.from_json(Boolean, 'true')
38
+ T.check(Boolean, data)
39
+ assert_equal true, data, "Boolean true should be parsable from JSON"
40
+ end
49
41
 
50
- def test_deserialize_string
51
- data = Jsoner.from_json(String, '"the string"')
52
- T.check(String, data)
53
- assert_equal "the string", data, "String should be parsable from JSON"
54
- end
42
+ def test_deserialize_false
43
+ data = Jsoner.from_json(Boolean, 'false')
44
+ T.check(Boolean, data)
45
+ assert_equal false, data, "Boolean false should be parsable from JSON"
46
+ end
55
47
 
56
- def test_deserialize_string_fail
57
- assert_raise JsonerError do
58
- Jsoner.from_json(String, '123')
59
- end
48
+ def test_deserialize_boolean_fail
49
+ assert_raise JsonerError do
50
+ Jsoner.from_json(Boolean, '1')
60
51
  end
52
+ end
61
53
 
62
- def test_deserialize_uuid
63
- data = Jsoner.from_json(UUID, '"58d5e212-165b-4ca0-909b-c86b9cee0111"')
64
- T.check(UUID, data)
65
- assert_equal "58d5e212-165b-4ca0-909b-c86b9cee0111", data, "String should be parsable from JSON"
66
- end
54
+ def test_deserialize_string
55
+ data = Jsoner.from_json(String, '"the string"')
56
+ T.check(String, data)
57
+ assert_equal "the string", data, "String should be parsable from JSON"
58
+ end
67
59
 
68
- def test_deserialize_uuid_fail
69
- assert_raise JsonerError do
70
- Jsoner.from_json(UUID, '"abc"')
71
- end
60
+ def test_deserialize_string_fail
61
+ assert_raise JsonerError do
62
+ Jsoner.from_json(String, '123')
72
63
  end
64
+ end
73
65
 
74
- def test_deserialize_date
75
- data = Jsoner.from_json(Date, '"2019-11-30"')
76
- T.check(Date, data)
77
- assert_equal Date.new(2019, 11, 30), data, "Date should be parsable from JSON"
78
- end
66
+ def test_deserialize_uuid
67
+ data = Jsoner.from_json(UUID, '"58d5e212-165b-4ca0-909b-c86b9cee0111"')
68
+ T.check(UUID, data)
69
+ assert_equal "58d5e212-165b-4ca0-909b-c86b9cee0111", data, "String should be parsable from JSON"
70
+ end
79
71
 
80
- def test_deserialize_date_wrong_format
81
- assert_raise JsonerError do
82
- Jsoner.from_json(Date, '"11/30/2019"')
83
- end
72
+ def test_deserialize_uuid_fail
73
+ assert_raise JsonerError do
74
+ Jsoner.from_json(UUID, '"abc"')
84
75
  end
76
+ end
85
77
 
86
- def test_deserialize_datetime
87
- data = Jsoner.from_json(DateTime, '"2019-11-30T17:45:55+00:00"')
88
- T.check(DateTime, data)
89
- assert_equal DateTime.new(2019, 11, 30, 17, 45, 55), data, "DateTime should be parsable from JSON"
90
- end
78
+ def test_deserialize_date
79
+ data = Jsoner.from_json(Date, '"2019-11-30"')
80
+ T.check(Date, data)
81
+ assert_equal Date.new(2019, 11, 30), data, "Date should be parsable from JSON"
82
+ end
91
83
 
92
- def test_deserialize_datetime_wrong_format
93
- assert_raise JsonerError do
94
- Jsoner.from_json(DateTime, '"2019-11-30 17:45:55"')
95
- end
84
+ def test_deserialize_date_wrong_format
85
+ assert_raise JsonerError do
86
+ Jsoner.from_json(Date, '"11/30/2019"')
96
87
  end
88
+ end
97
89
 
98
- def test_deserialize_nilable_nil
99
- data = Jsoner.from_json(T.nilable(String), 'null')
100
- T.check(T.nilable(String), data)
101
- assert_equal nil, data, "Nilable null value should be parsable from JSON"
102
- end
90
+ def test_deserialize_datetime
91
+ data = Jsoner.from_json(DateTime, '"2019-11-30T17:45:55+00:00"')
92
+ T.check(DateTime, data)
93
+ assert_equal DateTime.new(2019, 11, 30, 17, 45, 55), data, "DateTime should be parsable from JSON"
94
+ end
103
95
 
104
- def test_deserialize_nilable_string
105
- data = Jsoner.from_json(T.nilable(String), '"some string"')
106
- T.check(T.nilable(String), data)
107
- assert_equal "some string", data, "Nilable non-null value should be parsable from JSON"
96
+ def test_deserialize_datetime_wrong_format
97
+ assert_raise JsonerError do
98
+ Jsoner.from_json(DateTime, '"2019-11-30 17:45:55"')
108
99
  end
100
+ end
109
101
 
110
- def test_deserialize_non_nilable
111
- assert_raise JsonerError do
112
- Jsoner.from_json(String, 'null')
113
- end
114
- end
102
+ def test_deserialize_nilable_nil
103
+ data = Jsoner.from_json(T.nilable(String), 'null')
104
+ T.check(T.nilable(String), data)
105
+ assert_equal nil, data, "Nilable null value should be parsable from JSON"
115
106
  end
116
107
 
117
- class PlainTypesSerialization < Test::Unit::TestCase
118
- def test_serialize_integer
119
- assert_equal "123", Jsoner.to_json(Integer,123), "Integer should be serializable to JSON"
120
- end
108
+ def test_deserialize_nilable_string
109
+ data = Jsoner.from_json(T.nilable(String), '"some string"')
110
+ T.check(T.nilable(String), data)
111
+ assert_equal "some string", data, "Nilable non-null value should be parsable from JSON"
112
+ end
121
113
 
122
- def test_serialize_integer_fail
123
- assert_raise JsonerError do
124
- Jsoner.to_json(Integer,123.4)
125
- end
114
+ def test_deserialize_non_nilable
115
+ assert_raise JsonerError do
116
+ Jsoner.from_json(String, 'null')
126
117
  end
118
+ end
119
+ end
127
120
 
128
- def test_serialize_float
129
- assert_equal "12.3", Jsoner.to_json(Float,12.3), "Float should be serializable to JSON"
130
- end
121
+ class PlainTypesSerialization < Test::Unit::TestCase
122
+ def test_serialize_integer
123
+ assert_equal "123", Jsoner.to_json(Integer,123), "Integer should be serializable to JSON"
124
+ end
131
125
 
132
- def test_serialize_float_fail
133
- assert_raise JsonerError do
134
- Jsoner.to_json(Float,123)
135
- end
126
+ def test_serialize_integer_fail
127
+ assert_raise JsonerError do
128
+ Jsoner.to_json(Integer,123.4)
136
129
  end
130
+ end
137
131
 
138
- def test_serialize_boolean
139
- assert_equal "true", Jsoner.to_json(Boolean, true), "Boolean should be serializable to JSON"
140
- end
132
+ def test_serialize_float
133
+ assert_equal "12.3", Jsoner.to_json(Float,12.3), "Float should be serializable to JSON"
134
+ end
141
135
 
142
- def test_serialize_string
143
- assert_equal '"the string"', Jsoner.to_json(String,"the string"), "String should be serializable to JSON"
136
+ def test_serialize_float_fail
137
+ assert_raise JsonerError do
138
+ Jsoner.to_json(Float,123)
144
139
  end
140
+ end
145
141
 
146
- def test_serialize_date
147
- assert_equal '"2019-11-30"', Jsoner.to_json(Date, Date.new(2019, 11, 30)), "Date should be serializable to JSON"
148
- end
142
+ def test_serialize_boolean
143
+ assert_equal "true", Jsoner.to_json(Boolean, true), "Boolean should be serializable to JSON"
144
+ end
149
145
 
150
- def test_serialize_date_fail
151
- assert_raise JsonerError do
152
- Jsoner.to_json(Date, 123)
153
- end
154
- end
146
+ def test_serialize_string
147
+ assert_equal '"the string"', Jsoner.to_json(String,"the string"), "String should be serializable to JSON"
148
+ end
155
149
 
156
- def test_serialize_datetime
157
- assert_equal '"2019-11-30T17:45:55"', Jsoner.to_json(DateTime, DateTime.new(2019, 11, 30, 17, 45, 55)), "DateTime should be serializable to JSON"
158
- end
150
+ def test_serialize_date
151
+ assert_equal '"2019-11-30"', Jsoner.to_json(Date, Date.new(2019, 11, 30)), "Date should be serializable to JSON"
152
+ end
159
153
 
160
- def test_serialize_nil
161
- json_str = Jsoner.to_json(T.nilable(Untyped), nil)
162
- assert_equal "null", json_str, "nil should be serializable to JSON"
154
+ def test_serialize_date_fail
155
+ assert_raise JsonerError do
156
+ Jsoner.to_json(Date, 123)
163
157
  end
158
+ end
164
159
 
165
- def test_serialize_uuid
166
- assert_equal '"58d5e212-165b-4ca0-909b-c86b9cee0111"', Jsoner.to_json(UUID, "58d5e212-165b-4ca0-909b-c86b9cee0111"), "UUID should be serializable to JSON"
167
- end
160
+ def test_serialize_datetime
161
+ assert_equal '"2019-11-30T17:45:55"', Jsoner.to_json(DateTime, DateTime.new(2019, 11, 30, 17, 45, 55)), "DateTime should be serializable to JSON"
168
162
  end
169
163
 
170
- class ArrayDeserialization < Test::Unit::TestCase
171
- def test_deserialize_array
172
- data = Jsoner.from_json(T.array(String), '["the string", "the other string"]')
173
- T.check(T.array(String), data)
174
- assert_equal ["the string", "the other string"], data, "Should parse array of strings"
175
- end
164
+ def test_serialize_nil
165
+ json_str = Jsoner.to_json(T.nilable(Untyped), nil)
166
+ assert_equal "null", json_str, "nil should be serializable to JSON"
167
+ end
176
168
 
177
- def test_deserialize_array_of_datetime
178
- data = Jsoner.from_json(T.array(DateTime), '["2019-11-30T17:45:55+00:00"]')
179
- T.check(T.array(DateTime), data)
180
- assert_equal [DateTime.new(2019, 11, 30, 17, 45, 55)], data, "Should parse array of DateTime"
181
- end
169
+ def test_serialize_uuid
170
+ assert_equal '"58d5e212-165b-4ca0-909b-c86b9cee0111"', Jsoner.to_json(UUID, "58d5e212-165b-4ca0-909b-c86b9cee0111"), "UUID should be serializable to JSON"
182
171
  end
172
+ end
183
173
 
184
- class ArraySerialization < Test::Unit::TestCase
185
- def test_serialize_array
186
- assert_equal '["the string","the other string"]', Jsoner.to_json(T.array(String), ["the string", "the other string"]), "Array should be serializable to JSON"
187
- end
174
+ class ArrayDeserialization < Test::Unit::TestCase
175
+ def test_deserialize_array
176
+ data = Jsoner.from_json(T.array(String), '["the string", "the other string"]')
177
+ T.check(T.array(String), data)
178
+ assert_equal ["the string", "the other string"], data, "Should parse array of strings"
179
+ end
188
180
 
189
- def test_serialize_array_of_datetime
190
- assert_equal '["2019-11-30T17:45:55"]', Jsoner.to_json(T.array(DateTime), [DateTime.new(2019, 11, 30, 17, 45, 55)]), "Array should be serializable to JSON"
191
- end
181
+ def test_deserialize_array_of_datetime
182
+ data = Jsoner.from_json(T.array(DateTime), '["2019-11-30T17:45:55+00:00"]')
183
+ T.check(T.array(DateTime), data)
184
+ assert_equal [DateTime.new(2019, 11, 30, 17, 45, 55)], data, "Should parse array of DateTime"
192
185
  end
186
+ end
193
187
 
194
- class HashDeserialization < Test::Unit::TestCase
195
- def test_deserialize_hash
196
- data = Jsoner.from_json(T.hash(String, Integer), '{"one": 123, "two": 456}')
197
- T.check(T.hash(String, Integer), data)
198
- assert_equal ({"one" => 123, "two" => 456}), data, "Should parse hash"
199
- end
188
+ class ArraySerialization < Test::Unit::TestCase
189
+ def test_serialize_array
190
+ assert_equal '["the string","the other string"]', Jsoner.to_json(T.array(String), ["the string", "the other string"]), "Array should be serializable to JSON"
191
+ end
200
192
 
201
- def test_deserialize_hash_string_to_datetime
202
- data = Jsoner.from_json(T.hash(String, DateTime), '{"one": "2019-11-30T17:45:55+00:00"}')
203
- T.check(T.hash(String, DateTime), data)
204
- assert_equal ({"one" => DateTime.new(2019, 11, 30, 17, 45, 55)}), data, "Should parse hash"
205
- end
193
+ def test_serialize_array_of_datetime
194
+ assert_equal '["2019-11-30T17:45:55"]', Jsoner.to_json(T.array(DateTime), [DateTime.new(2019, 11, 30, 17, 45, 55)]), "Array should be serializable to JSON"
206
195
  end
196
+ end
207
197
 
208
- class HashSerialization < Test::Unit::TestCase
209
- def test_serialize_hash
210
- assert_equal '{"one":123,"two":456}', Jsoner.to_json(T.hash(String, Integer), {"one" => 123, "two" => 456}), "Hash should be serializable to JSON"
211
- end
198
+ class HashDeserialization < Test::Unit::TestCase
199
+ def test_deserialize_hash
200
+ data = Jsoner.from_json(T.hash(String, Integer), '{"one": 123, "two": 456}')
201
+ T.check(T.hash(String, Integer), data)
202
+ assert_equal ({"one" => 123, "two" => 456}), data, "Should parse hash"
203
+ end
212
204
 
213
- def test_serialize_hash_string_to_datetime
214
- assert_equal '{"one":"2019-11-30T17:45:55"}', Jsoner.to_json(T.hash(String, DateTime), {"one" => DateTime.new(2019, 11, 30, 17, 45, 55)}), "Hash should be serializable to JSON"
215
- end
205
+ def test_deserialize_hash_string_to_datetime
206
+ data = Jsoner.from_json(T.hash(String, DateTime), '{"one": "2019-11-30T17:45:55+00:00"}')
207
+ T.check(T.hash(String, DateTime), data)
208
+ assert_equal ({"one" => DateTime.new(2019, 11, 30, 17, 45, 55)}), data, "Should parse hash"
216
209
  end
210
+ end
217
211
 
218
- class AnyDeserialization < Test::Unit::TestCase
219
- def test_deserialize
220
- data = Jsoner.from_json(T.any(String, Integer), '"the string"')
221
- T.check(T.any(String, Integer), data)
222
- assert_equal "the string", data, "Should parse any type"
223
- end
212
+ class HashSerialization < Test::Unit::TestCase
213
+ def test_serialize_hash
214
+ assert_equal '{"one":123,"two":456}', Jsoner.to_json(T.hash(String, Integer), {"one" => 123, "two" => 456}), "Hash should be serializable to JSON"
215
+ end
224
216
 
225
- def test_deserialize_fail
226
- assert_raise JsonerError do
227
- Jsoner.from_json(T.any(Integer, Float), '"the string"')
228
- end
229
- end
217
+ def test_serialize_hash_string_to_datetime
218
+ assert_equal '{"one":"2019-11-30T17:45:55"}', Jsoner.to_json(T.hash(String, DateTime), {"one" => DateTime.new(2019, 11, 30, 17, 45, 55)}), "Hash should be serializable to JSON"
230
219
  end
220
+ end
231
221
 
232
- class AnySerialization < Test::Unit::TestCase
233
- def test_serialize
234
- data = Jsoner.to_json(T.any(String, Integer), "the string")
235
- T.check(T.any(String, Integer), data)
236
- assert_equal '"the string"', data, "Should serialize any type"
237
- end
222
+ class UntypedDeserialization < Test::Unit::TestCase
223
+ def test_deserialize_hash
224
+ data = Jsoner.from_json(Untyped, '{"one":123,"two":"some string"}')
225
+ assert_equal ({"one" => 123, "two" => "some string"}), data
238
226
  end
239
227
 
240
- class UnionDeserialization < Test::Unit::TestCase
241
- def test_deserialize
242
- data = Jsoner.from_json(T.union(str: String, int: Integer), '{"str":"the string"}')
243
- T.check(T.union(str: String, int: Integer), data)
244
- assert_equal "the string", data, "Should parse union type"
245
- end
228
+ def test_deserialize_array
229
+ data = Jsoner.from_json(Untyped, '[123,"some string"]')
230
+ assert_equal [123, "some string"], data
231
+ end
232
+ end
233
+
234
+ class UntypedSerialization < Test::Unit::TestCase
235
+ def test_serialize_hash
236
+ assert_equal '{"one":123,"two":"some string"}', Jsoner.to_json(Untyped, {"one" => 123, "two" => "some string"})
237
+ end
238
+
239
+ def test_serialize_array
240
+ assert_equal '[123,"some string"]', Jsoner.to_json(Untyped, [123, "some string"])
241
+ end
242
+ end
243
+
244
+ class AnyDeserialization < Test::Unit::TestCase
245
+ def test_deserialize
246
+ data = Jsoner.from_json(T.any(String, Integer), '"the string"')
247
+ T.check(T.any(String, Integer), data)
248
+ assert_equal "the string", data, "Should parse any type"
249
+ end
246
250
 
247
- def test_deserialize_any_fail
248
- assert_raise JsonerError do
249
- Jsoner.from_json(T.union(str: String, int: Integer), '{"bool":true}')
250
- end
251
+ def test_deserialize_fail
252
+ assert_raise JsonerError do
253
+ Jsoner.from_json(T.any(Integer, Float), '"the string"')
251
254
  end
252
255
  end
256
+ end
257
+
258
+ class AnySerialization < Test::Unit::TestCase
259
+ def test_serialize
260
+ data = Jsoner.to_json(T.any(String, Integer), "the string")
261
+ T.check(T.any(String, Integer), data)
262
+ assert_equal '"the string"', data, "Should serialize any type"
263
+ end
264
+ end
253
265
 
254
- class UnionSerialization < Test::Unit::TestCase
255
- def test_serialize
256
- data = Jsoner.to_json(T.union(str: String, int: Integer), "the string")
257
- assert_equal '{"str":"the string"}', data, "Should serialize union type with wrapping object"
266
+ class UnionDeserialization < Test::Unit::TestCase
267
+ def test_deserialize
268
+ data = Jsoner.from_json(T.union(str: String, int: Integer), '{"str":"the string"}')
269
+ T.check(T.union(str: String, int: Integer), data)
270
+ assert_equal "the string", data, "Should parse union type"
271
+ end
272
+
273
+ def test_deserialize_any_fail
274
+ assert_raise JsonerError do
275
+ Jsoner.from_json(T.union(str: String, int: Integer), '{"bool":true}')
258
276
  end
259
277
  end
278
+ end
279
+
280
+ class UnionSerialization < Test::Unit::TestCase
281
+ def test_serialize
282
+ data = Jsoner.to_json(T.union(str: String, int: Integer), "the string")
283
+ assert_equal '{"str":"the string"}', data, "Should serialize union type with wrapping object"
284
+ end
260
285
  end