spec/yielding_spec.rb in json-write-stream-1.1.0 vs spec/yielding_spec.rb in json-write-stream-1.2.0
- old
+ new
@@ -19,9 +19,25 @@
str.encode(Encoding::UTF_8)
end
it_behaves_like 'a json stream'
+ it 'respects the "before" option' do
+ stream_writer.write_object do |object_writer|
+ object_writer.write_key_value('foo', 'bar', before: "\n ")
+ end
+
+ expect(stream.string).to eq("{\n \"foo\":\"bar\"}")
+ end
+
+ it 'respects the "between" option' do
+ stream_writer.write_object do |object_writer|
+ object_writer.write_key_value('foo', 'bar', between: ' ')
+ end
+
+ expect(stream.string).to eq('{"foo": "bar"}')
+ end
+
describe '#write_key_value' do
it 'converts all keys to strings' do
stream_writer.write_object do |object_writer|
object_writer.write_key_value(123, 'abc')
end