bson 4.2.2 → 4.12.1

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.
Files changed (169) hide show
  1. checksums.yaml +5 -5
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/README.md +25 -7
  5. data/Rakefile +16 -9
  6. data/ext/bson/{native-endian.h → bson-endian.h} +5 -99
  7. data/ext/bson/bson-native.h +125 -0
  8. data/ext/bson/bytebuf.c +133 -0
  9. data/ext/bson/endian.c +117 -0
  10. data/ext/bson/init.c +355 -0
  11. data/ext/bson/libbson-utf8.c +230 -0
  12. data/ext/bson/read.c +411 -0
  13. data/ext/bson/util.c +95 -0
  14. data/ext/bson/write.c +680 -0
  15. data/lib/bson.rb +6 -3
  16. data/lib/bson/active_support.rb +17 -0
  17. data/lib/bson/array.rb +57 -17
  18. data/lib/bson/binary.rb +185 -13
  19. data/lib/bson/boolean.rb +12 -3
  20. data/lib/bson/code.rb +16 -2
  21. data/lib/bson/code_with_scope.rb +32 -5
  22. data/lib/bson/config.rb +1 -1
  23. data/lib/bson/date.rb +12 -2
  24. data/lib/bson/date_time.rb +2 -2
  25. data/lib/bson/db_pointer.rb +110 -0
  26. data/lib/bson/decimal128.rb +17 -3
  27. data/lib/bson/decimal128/builder.rb +1 -1
  28. data/lib/bson/document.rb +152 -5
  29. data/lib/bson/environment.rb +2 -1
  30. data/lib/bson/error.rb +27 -0
  31. data/lib/bson/ext_json.rb +383 -0
  32. data/lib/bson/false_class.rb +1 -1
  33. data/lib/bson/float.rb +48 -2
  34. data/lib/bson/hash.rb +68 -17
  35. data/lib/bson/int32.rb +52 -13
  36. data/lib/bson/int64.rb +59 -15
  37. data/lib/bson/integer.rb +36 -2
  38. data/lib/bson/json.rb +1 -1
  39. data/lib/bson/max_key.rb +13 -1
  40. data/lib/bson/min_key.rb +13 -1
  41. data/lib/bson/nil_class.rb +4 -2
  42. data/lib/bson/object.rb +28 -1
  43. data/lib/bson/object_id.rb +16 -2
  44. data/lib/bson/open_struct.rb +1 -1
  45. data/lib/bson/regexp.rb +27 -4
  46. data/lib/bson/registry.rb +3 -3
  47. data/lib/bson/specialized.rb +4 -2
  48. data/lib/bson/string.rb +5 -3
  49. data/lib/bson/symbol.rb +99 -7
  50. data/lib/bson/time.rb +63 -4
  51. data/lib/bson/time_with_zone.rb +54 -0
  52. data/lib/bson/timestamp.rb +44 -6
  53. data/lib/bson/true_class.rb +1 -1
  54. data/lib/bson/undefined.rb +12 -1
  55. data/lib/bson/version.rb +2 -2
  56. data/spec/bson/array_spec.rb +18 -1
  57. data/spec/bson/binary_spec.rb +100 -3
  58. data/spec/bson/binary_uuid_spec.rb +189 -0
  59. data/spec/bson/boolean_spec.rb +1 -1
  60. data/spec/bson/byte_buffer_read_spec.rb +197 -0
  61. data/spec/bson/byte_buffer_spec.rb +121 -381
  62. data/spec/bson/byte_buffer_write_spec.rb +854 -0
  63. data/spec/bson/code_spec.rb +1 -1
  64. data/spec/bson/code_with_scope_spec.rb +1 -1
  65. data/spec/bson/date_spec.rb +1 -1
  66. data/spec/bson/date_time_spec.rb +54 -1
  67. data/spec/bson/decimal128_spec.rb +35 -35
  68. data/spec/bson/document_as_spec.rb +46 -0
  69. data/spec/bson/document_spec.rb +197 -30
  70. data/spec/bson/ext_json_parse_spec.rb +308 -0
  71. data/spec/bson/false_class_spec.rb +1 -1
  72. data/spec/bson/float_spec.rb +37 -1
  73. data/spec/bson/hash_as_spec.rb +57 -0
  74. data/spec/bson/hash_spec.rb +209 -1
  75. data/spec/bson/int32_spec.rb +180 -6
  76. data/spec/bson/int64_spec.rb +199 -6
  77. data/spec/bson/integer_spec.rb +29 -3
  78. data/spec/bson/json_spec.rb +1 -1
  79. data/spec/bson/max_key_spec.rb +1 -1
  80. data/spec/bson/min_key_spec.rb +1 -1
  81. data/spec/bson/nil_class_spec.rb +1 -1
  82. data/spec/bson/object_id_spec.rb +1 -1
  83. data/spec/bson/object_spec.rb +1 -1
  84. data/spec/bson/open_struct_spec.rb +1 -1
  85. data/spec/bson/raw_spec.rb +34 -2
  86. data/spec/bson/regexp_spec.rb +1 -1
  87. data/spec/bson/registry_spec.rb +1 -1
  88. data/spec/bson/string_spec.rb +19 -1
  89. data/spec/bson/symbol_raw_spec.rb +45 -0
  90. data/spec/bson/symbol_spec.rb +63 -3
  91. data/spec/bson/time_spec.rb +205 -2
  92. data/spec/bson/time_with_zone_spec.rb +68 -0
  93. data/spec/bson/timestamp_spec.rb +56 -1
  94. data/spec/bson/true_class_spec.rb +1 -1
  95. data/spec/bson/undefined_spec.rb +1 -1
  96. data/spec/bson_spec.rb +1 -1
  97. data/spec/{support → runners}/common_driver.rb +1 -1
  98. data/spec/runners/corpus.rb +185 -0
  99. data/spec/{support/corpus.rb → runners/corpus_legacy.rb} +41 -59
  100. data/spec/spec_helper.rb +40 -3
  101. data/spec/{bson/driver_bson_spec.rb → spec_tests/common_driver_spec.rb} +1 -0
  102. data/spec/{bson/corpus_spec.rb → spec_tests/corpus_legacy_spec.rb} +10 -7
  103. data/spec/spec_tests/corpus_spec.rb +124 -0
  104. data/spec/spec_tests/data/corpus/README.md +15 -0
  105. data/spec/spec_tests/data/corpus/array.json +49 -0
  106. data/spec/spec_tests/data/corpus/binary.json +113 -0
  107. data/spec/spec_tests/data/corpus/boolean.json +27 -0
  108. data/spec/spec_tests/data/corpus/code.json +67 -0
  109. data/spec/spec_tests/data/corpus/code_w_scope.json +78 -0
  110. data/spec/spec_tests/data/corpus/datetime.json +42 -0
  111. data/spec/spec_tests/data/corpus/dbpointer.json +56 -0
  112. data/spec/spec_tests/data/corpus/dbref.json +31 -0
  113. data/spec/spec_tests/data/corpus/decimal128-1.json +317 -0
  114. data/spec/spec_tests/data/corpus/decimal128-2.json +793 -0
  115. data/spec/spec_tests/data/corpus/decimal128-3.json +1771 -0
  116. data/spec/spec_tests/data/corpus/decimal128-4.json +117 -0
  117. data/spec/spec_tests/data/corpus/decimal128-5.json +402 -0
  118. data/spec/spec_tests/data/corpus/decimal128-6.json +119 -0
  119. data/spec/spec_tests/data/corpus/decimal128-7.json +323 -0
  120. data/spec/spec_tests/data/corpus/document.json +36 -0
  121. data/spec/spec_tests/data/corpus/double.json +87 -0
  122. data/spec/spec_tests/data/corpus/int32.json +43 -0
  123. data/spec/spec_tests/data/corpus/int64.json +43 -0
  124. data/spec/spec_tests/data/corpus/maxkey.json +12 -0
  125. data/spec/spec_tests/data/corpus/minkey.json +12 -0
  126. data/spec/spec_tests/data/corpus/multi-type-deprecated.json +15 -0
  127. data/spec/spec_tests/data/corpus/multi-type.json +11 -0
  128. data/spec/spec_tests/data/corpus/null.json +12 -0
  129. data/spec/spec_tests/data/corpus/oid.json +28 -0
  130. data/spec/spec_tests/data/corpus/regex.json +65 -0
  131. data/spec/spec_tests/data/corpus/string.json +72 -0
  132. data/spec/spec_tests/data/corpus/symbol.json +80 -0
  133. data/spec/spec_tests/data/corpus/timestamp.json +34 -0
  134. data/spec/spec_tests/data/corpus/top.json +236 -0
  135. data/spec/spec_tests/data/corpus/undefined.json +15 -0
  136. data/spec/{support/corpus-tests → spec_tests/data/corpus_legacy}/array.json +8 -2
  137. data/spec/{support/corpus-tests/failures → spec_tests/data/corpus_legacy}/binary.json +0 -0
  138. data/spec/{support/corpus-tests → spec_tests/data/corpus_legacy}/boolean.json +0 -0
  139. data/spec/{support/corpus-tests → spec_tests/data/corpus_legacy}/code.json +1 -1
  140. data/spec/{support/corpus-tests → spec_tests/data/corpus_legacy}/code_w_scope.json +1 -1
  141. data/spec/{support/corpus-tests → spec_tests/data/corpus_legacy}/document.json +1 -1
  142. data/spec/{support/corpus-tests → spec_tests/data/corpus_legacy}/double.json +1 -1
  143. data/spec/{support/corpus-tests → spec_tests/data/corpus_legacy}/failures/datetime.json +0 -0
  144. data/spec/{support/corpus-tests → spec_tests/data/corpus_legacy}/failures/dbpointer.json +0 -0
  145. data/spec/{support/corpus-tests → spec_tests/data/corpus_legacy}/failures/int64.json +0 -0
  146. data/spec/{support/corpus-tests → spec_tests/data/corpus_legacy}/failures/symbol.json +0 -0
  147. data/spec/{support/corpus-tests → spec_tests/data/corpus_legacy}/int32.json +1 -1
  148. data/spec/{support/corpus-tests → spec_tests/data/corpus_legacy}/maxkey.json +1 -1
  149. data/spec/{support/corpus-tests → spec_tests/data/corpus_legacy}/minkey.json +1 -1
  150. data/spec/{support/corpus-tests → spec_tests/data/corpus_legacy}/null.json +1 -1
  151. data/spec/{support/corpus-tests → spec_tests/data/corpus_legacy}/oid.json +0 -0
  152. data/spec/{support/corpus-tests → spec_tests/data/corpus_legacy}/regex.json +1 -1
  153. data/spec/{support/corpus-tests → spec_tests/data/corpus_legacy}/string.json +0 -0
  154. data/spec/{support/corpus-tests → spec_tests/data/corpus_legacy}/timestamp.json +1 -1
  155. data/spec/{support/corpus-tests → spec_tests/data/corpus_legacy}/top.json +0 -0
  156. data/spec/{support/corpus-tests/failures → spec_tests/data/corpus_legacy}/undefined.json +0 -0
  157. data/spec/{support/driver-spec-tests → spec_tests/data}/decimal128/decimal128-1.json +0 -0
  158. data/spec/{support/driver-spec-tests → spec_tests/data}/decimal128/decimal128-2.json +0 -0
  159. data/spec/{support/driver-spec-tests → spec_tests/data}/decimal128/decimal128-3.json +0 -0
  160. data/spec/{support/driver-spec-tests → spec_tests/data}/decimal128/decimal128-4.json +0 -0
  161. data/spec/{support/driver-spec-tests → spec_tests/data}/decimal128/decimal128-5.json +0 -0
  162. data/spec/{support/driver-spec-tests → spec_tests/data}/decimal128/decimal128-6.json +0 -0
  163. data/spec/{support/driver-spec-tests → spec_tests/data}/decimal128/decimal128-7.json +0 -0
  164. data/spec/support/shared_examples.rb +3 -5
  165. data/spec/support/spec_config.rb +16 -0
  166. data/spec/support/utils.rb +10 -0
  167. metadata +227 -124
  168. metadata.gz.sig +0 -0
  169. data/ext/bson/bson_native.c +0 -762
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2009-2014 MongoDB Inc.
1
+ # Copyright (C) 2009-2020 MongoDB Inc.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -25,7 +25,7 @@ describe BSON::Int32 do
25
25
  let(:integer) { Integer::MAX_32BIT }
26
26
 
27
27
  it "wraps the integer" do
28
- expect(obj.instance_variable_get(:@integer)).to be(integer)
28
+ expect(obj.value).to be(integer)
29
29
  end
30
30
  end
31
31
 
@@ -34,9 +34,9 @@ describe BSON::Int32 do
34
34
  let(:integer) { Integer::MAX_32BIT + 1 }
35
35
 
36
36
  it "raises an out of range error" do
37
- expect {
37
+ expect do
38
38
  obj
39
- }.to raise_error(RangeError)
39
+ end.to raise_error(RangeError, /#{integer} cannot be stored in 32 bits/)
40
40
  end
41
41
  end
42
42
 
@@ -50,6 +50,16 @@ describe BSON::Int32 do
50
50
  }.to raise_error(RangeError)
51
51
  end
52
52
  end
53
+
54
+ context 'when argument is an Int32' do
55
+ let(:integer) do
56
+ described_class.new(described_class.new(50))
57
+ end
58
+
59
+ it 'works' do
60
+ expect(integer.value).to be 50
61
+ end
62
+ end
53
63
  end
54
64
 
55
65
  describe "#from_bson" do
@@ -93,10 +103,174 @@ describe BSON::Int32 do
93
103
  describe "#to_bson_key" do
94
104
 
95
105
  let(:obj) { BSON::Int32.new(Integer::MAX_32BIT - 1) }
96
- let(:encoded) { (Integer::MAX_32BIT - 1).to_s }
106
+ let(:encoded) { (Integer::MAX_32BIT - 1) }
97
107
 
98
- it "returns the key as a string" do
108
+ it "returns the key as an integer" do
99
109
  expect(obj.to_bson_key).to eq(encoded)
100
110
  end
101
111
  end
112
+
113
+ describe "#==" do
114
+
115
+ let(:object) do
116
+ described_class.new(1)
117
+ end
118
+
119
+ context "when data is identical" do
120
+
121
+ let(:other_object) do
122
+ described_class.new(1)
123
+ end
124
+
125
+ it "returns true" do
126
+ expect(object).to eq(other_object)
127
+ end
128
+
129
+ context "other object is of another integer type" do
130
+
131
+ let(:other_object) do
132
+ BSON::Int64.new(1)
133
+ end
134
+
135
+ it "returns false" do
136
+ expect(object).not_to eq(other_object)
137
+ end
138
+ end
139
+ end
140
+
141
+ context "when the data is different" do
142
+
143
+ let(:other_object) do
144
+ described_class.new(2)
145
+ end
146
+
147
+ it "returns false" do
148
+ expect(object).not_to eq(other_object)
149
+ end
150
+ end
151
+
152
+ context "when other is not a BSON integer" do
153
+
154
+ it "returns false" do
155
+ expect(described_class.new(1)).to_not eq('1')
156
+ end
157
+ end
158
+ end
159
+
160
+ describe "#===" do
161
+
162
+ let(:object) do
163
+ described_class.new(1)
164
+ end
165
+
166
+ context "when comparing with another BSON int32" do
167
+
168
+ context "when the data is equal" do
169
+
170
+ let(:other_object) do
171
+ described_class.new(1)
172
+ end
173
+
174
+ it "returns true" do
175
+ expect(object === other_object).to be true
176
+ end
177
+
178
+ context "other object is of another integer type" do
179
+
180
+ let(:other_object) do
181
+ BSON::Int64.new(1)
182
+ end
183
+
184
+ it "returns false" do
185
+ expect(object === other_object).to be false
186
+ end
187
+ end
188
+ end
189
+
190
+ context "when the data is not equal" do
191
+
192
+ let(:other_object) do
193
+ described_class.new(2)
194
+ end
195
+
196
+ it "returns false" do
197
+ expect(object === other_object).to be false
198
+ end
199
+ end
200
+ end
201
+
202
+ context "when comparing to an object id class" do
203
+
204
+ it "returns false" do
205
+ expect(described_class.new(1) === described_class).to be false
206
+ end
207
+ end
208
+
209
+ context "when comparing with a string" do
210
+
211
+ context "when the data is equal" do
212
+
213
+ let(:other) do
214
+ '1'
215
+ end
216
+
217
+ it "returns false" do
218
+ expect(object === other).to be false
219
+ end
220
+ end
221
+
222
+ context "when the data is not equal" do
223
+
224
+ let(:other) do
225
+ '2'
226
+ end
227
+
228
+ it "returns false" do
229
+ expect(object === other).to be false
230
+ end
231
+ end
232
+ end
233
+
234
+ context "when comparing with a non-bson integer object" do
235
+
236
+ it "returns false" do
237
+ expect(object === []).to be false
238
+ end
239
+ end
240
+
241
+ context "when comparing with a non int64 class" do
242
+
243
+ it "returns false" do
244
+ expect(object === String).to be false
245
+ end
246
+ end
247
+ end
248
+
249
+ describe '#value' do
250
+ let(:obj) { described_class.new(12345) }
251
+
252
+ it 'returns value passed to initializer' do
253
+ expect(obj.value).to eq(12345)
254
+ end
255
+ end
256
+
257
+ describe '#as_extended_json' do
258
+ context 'canonical mode' do
259
+ it 'returns $numberInt' do
260
+ described_class.new(42).as_extended_json.should == {'$numberInt' => '42'}
261
+ end
262
+ end
263
+
264
+ context 'relaxed mode' do
265
+ it 'returns integer' do
266
+ described_class.new(42).as_extended_json(mode: :relaxed).should == 42
267
+ end
268
+ end
269
+
270
+ context 'legacy mode' do
271
+ it 'returns integer' do
272
+ described_class.new(42).as_extended_json(mode: :legacy).should be 42
273
+ end
274
+ end
275
+ end
102
276
  end
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2009-2014 MongoDB Inc.
1
+ # Copyright (C) 2009-2020 MongoDB Inc.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -25,7 +25,7 @@ describe BSON::Int64 do
25
25
  let(:integer) { Integer::MAX_64BIT - 1 }
26
26
 
27
27
  it "wraps the integer" do
28
- expect(obj.instance_variable_get(:@integer)).to be(integer)
28
+ expect(obj.value).to be(integer)
29
29
  end
30
30
  end
31
31
 
@@ -34,9 +34,9 @@ describe BSON::Int64 do
34
34
  let(:integer) { Integer::MAX_64BIT + 1 }
35
35
 
36
36
  it "raises an out of range error" do
37
- expect {
37
+ expect do
38
38
  obj
39
- }.to raise_error(RangeError)
39
+ end.to raise_error(RangeError, /#{integer} cannot be stored in 64 bits/)
40
40
  end
41
41
  end
42
42
 
@@ -50,6 +50,16 @@ describe BSON::Int64 do
50
50
  }.to raise_error(RangeError)
51
51
  end
52
52
  end
53
+
54
+ context 'when argument is an Int64' do
55
+ let(:integer) do
56
+ described_class.new(described_class.new(50))
57
+ end
58
+
59
+ it 'works' do
60
+ expect(integer.value).to be 50
61
+ end
62
+ end
53
63
  end
54
64
 
55
65
  describe "#from_bson" do
@@ -61,6 +71,25 @@ describe BSON::Int64 do
61
71
  it_behaves_like "a bson element"
62
72
  it_behaves_like "a deserializable bson element"
63
73
 
74
+ context 'canonical deserialization' do
75
+ let(:integer) { 42 }
76
+
77
+ let(:bson) do
78
+ BSON::ByteBuffer.new(BSON::Int64.new(integer).to_bson.to_s)
79
+ end
80
+
81
+ let(:deserialized) do
82
+ described_class.from_bson(bson, mode: :bson)
83
+ end
84
+
85
+ it 'deserializes to BSON::Int64' do
86
+ deserialized.class.should be BSON::Int64
87
+ end
88
+
89
+ it 'has the correct value' do
90
+ deserialized.value.should == 42
91
+ end
92
+ end
64
93
 
65
94
  context "when the integer is within the MRI Fixnum range" do
66
95
 
@@ -138,10 +167,174 @@ describe BSON::Int64 do
138
167
  describe "#to_bson_key" do
139
168
 
140
169
  let(:obj) { BSON::Int64.new(Integer::MAX_64BIT - 1) }
141
- let(:encoded) { (Integer::MAX_64BIT - 1).to_s }
170
+ let(:encoded) { (Integer::MAX_64BIT - 1) }
142
171
 
143
- it "returns the key as a string" do
172
+ it "returns the key as an integer" do
144
173
  expect(obj.to_bson_key).to eq(encoded)
145
174
  end
146
175
  end
176
+
177
+ describe "#==" do
178
+
179
+ let(:object) do
180
+ described_class.new(1)
181
+ end
182
+
183
+ context "when data is identical" do
184
+
185
+ let(:other_object) do
186
+ described_class.new(1)
187
+ end
188
+
189
+ it "returns true" do
190
+ expect(object).to eq(other_object)
191
+ end
192
+
193
+ context "other object is of another integer type" do
194
+
195
+ let(:other_object) do
196
+ BSON::Int32.new(1)
197
+ end
198
+
199
+ it "returns false" do
200
+ expect(object).not_to eq(other_object)
201
+ end
202
+ end
203
+ end
204
+
205
+ context "when the data is different" do
206
+
207
+ let(:other_object) do
208
+ described_class.new(2)
209
+ end
210
+
211
+ it "returns false" do
212
+ expect(object).not_to eq(other_object)
213
+ end
214
+ end
215
+
216
+ context "when other is not a BSON integer" do
217
+
218
+ it "returns false" do
219
+ expect(described_class.new(1)).to_not eq('1')
220
+ end
221
+ end
222
+ end
223
+
224
+ describe "#===" do
225
+
226
+ let(:object) do
227
+ described_class.new(1)
228
+ end
229
+
230
+ context "when comparing with another BSON int64" do
231
+
232
+ context "when the data is equal" do
233
+
234
+ let(:other_object) do
235
+ described_class.new(1)
236
+ end
237
+
238
+ it "returns true" do
239
+ expect(object === other_object).to be true
240
+ end
241
+
242
+ context "other object is of another integer type" do
243
+
244
+ let(:other_object) do
245
+ BSON::Int32.new(1)
246
+ end
247
+
248
+ it "returns false" do
249
+ expect(object === other_object).to be false
250
+ end
251
+ end
252
+ end
253
+
254
+ context "when the data is not equal" do
255
+
256
+ let(:other_object) do
257
+ described_class.new(2)
258
+ end
259
+
260
+ it "returns false" do
261
+ expect(object === other_object).to be false
262
+ end
263
+ end
264
+ end
265
+
266
+ context "when comparing to an object id class" do
267
+
268
+ it "returns false" do
269
+ expect(described_class.new(1) === described_class).to be false
270
+ end
271
+ end
272
+
273
+ context "when comparing with a string" do
274
+
275
+ context "when the data is equal" do
276
+
277
+ let(:other) do
278
+ '1'
279
+ end
280
+
281
+ it "returns false" do
282
+ expect(object === other).to be false
283
+ end
284
+ end
285
+
286
+ context "when the data is not equal" do
287
+
288
+ let(:other) do
289
+ '2'
290
+ end
291
+
292
+ it "returns false" do
293
+ expect(object === other).to be false
294
+ end
295
+ end
296
+ end
297
+
298
+ context "when comparing with a non-bson integer object" do
299
+
300
+ it "returns false" do
301
+ expect(object === []).to be false
302
+ end
303
+ end
304
+
305
+ context "when comparing with a non int64 class" do
306
+
307
+ it "returns false" do
308
+ expect(object === String).to be false
309
+ end
310
+ end
311
+ end
312
+
313
+ describe '#value' do
314
+ let(:obj) { described_class.new(12345) }
315
+
316
+ it 'returns value passed to initializer' do
317
+ expect(obj.value).to eq(12345)
318
+ end
319
+ end
320
+
321
+ describe '#as_extended_json' do
322
+ context 'canonical mode' do
323
+ it 'returns $numberLong' do
324
+ described_class.new(42).as_extended_json.should == {'$numberLong' => '42'}
325
+ end
326
+ end
327
+
328
+ context 'relaxed mode' do
329
+ it 'returns integer' do
330
+ described_class.new(42).as_extended_json(mode: :relaxed).should == 42
331
+ end
332
+ end
333
+
334
+ context 'legacy mode' do
335
+ it 'returns integer' do
336
+ described_class.new(42).as_extended_json(mode: :legacy).should be 42
337
+ end
338
+ end
339
+ end
147
340
  end