test/io_streams_test.rb in iostreams-0.20.1 vs test/io_streams_test.rb in iostreams-0.20.2
- old
+ new
@@ -28,10 +28,26 @@
let :stripped_data do
bad_data.gsub("\xE9".b, '').gsub("\x07", '')
end
+ let :multiple_zip_file_name do
+ File.join(File.dirname(__FILE__), 'files', 'multiple_files.zip')
+ end
+
+ let :zip_gz_file_name do
+ File.join(File.dirname(__FILE__), 'files', 'text.zip.gz')
+ end
+
+ let :contents_test_txt do
+ File.read(File.join(File.dirname(__FILE__), 'files', 'text.txt'))
+ end
+
+ let :contents_test_json do
+ File.read(File.join(File.dirname(__FILE__), 'files', 'test.json'))
+ end
+
after do
temp_file.delete
end
describe '.copy' do
@@ -122,7 +138,22 @@
assert_equal stripped_data.lines.map(&:strip), lines
assert_equal stripped_data.lines.count, count
end
end
+ describe '.reader' do
+ it 'reads a zip file' do
+ result = IOStreams.reader(multiple_zip_file_name, streams: {zip: {entry_file_name: 'test.json'}}) do |io|
+ io.read
+ end
+ assert_equal contents_test_json, result
+ end
+
+ it 'reads a zip file from within a gz file' do
+ result = IOStreams.reader(zip_gz_file_name) do |io|
+ io.read
+ end
+ assert_equal contents_test_txt, result
+ end
+ end
end
end