spec/stateful_spec.rb in yaml-write-stream-1.0.2 vs spec/stateful_spec.rb in yaml-write-stream-1.0.3
- old
+ new
@@ -33,9 +33,29 @@
expect(stream.string).to eq(utf8("- abc\n- def: ghi\n"))
expect(stream_writer).to be_closed
expect(stream).to be_closed
end
+
+ it 'quotes empty strings' do
+ stream_writer.write_map
+ stream_writer.write_key_value('foo', '')
+ stream_writer.close
+
+ expect(stream.string).to eq(utf8("foo: \"\"\n"))
+ expect(stream_writer).to be_closed
+ expect(stream).to be_closed
+ end
+
+ it 'writes nils as blank entries' do
+ stream_writer.write_map
+ stream_writer.write_key_value('foo', nil)
+ stream_writer.close
+
+ expect(stream.string).to eq(utf8("foo: \n"))
+ expect(stream_writer).to be_closed
+ expect(stream).to be_closed
+ end
end
describe '#closed?' do
it 'returns false if the stream is still open' do
expect(stream_writer).to_not be_closed