test/reader_test.rb in symmetric-encryption-3.8.3 vs test/reader_test.rb in symmetric-encryption-3.9.0

- old
+ new

@@ -138,18 +138,18 @@ after do File.delete(@filename) if File.exist?(@filename) && !@filename.end_with?('empty.csv') end - it ".empty?" do + it '.empty?' do assert_equal (@data_size==0), SymmetricEncryption::Reader.empty?(@filename) assert_raises Errno::ENOENT do SymmetricEncryption::Reader.empty?('missing_file') end end - it ".header_present?" do + it '.header_present?' do assert_equal @header, SymmetricEncryption::Reader.header_present?(@filename) assert_raises Errno::ENOENT do SymmetricEncryption::Reader.header_present?('missing_file') end end @@ -158,11 +158,11 @@ file = SymmetricEncryption::Reader.open(@filename) #assert_equal (@header && (options[:compress]||false)), file.is_a?(Zlib::GzipReader) file.close end - it "#read()" do + it '#read' do data = nil eof = nil result = SymmetricEncryption::Reader.open(@filename) do |file| eof = file.eof? data = file.read @@ -170,40 +170,45 @@ assert_equal @eof, eof assert_equal @data_str, data assert_equal @data_str, result end - it "#read(size)" do + it '#read(size)' do file = SymmetricEncryption::Reader.open(@filename) eof = file.eof? data = file.read(4096) file.close assert_equal @eof, eof - assert_equal (@data_size > 0 ? @data_str : nil), data + if @data_size > 0 + assert_equal @data_str, data + else + assert_nil data + end + end - it "#each_line" do + it '#each_line' do SymmetricEncryption::Reader.open(@filename) do |file| i = 0 file.each_line do |line| assert_equal @data[i], line i += 1 end end end - it "#rewind" do + it '#rewind' do decrypted = SymmetricEncryption::Reader.open(@filename) do |file| file.read file.rewind file.read end assert_equal @data_str, decrypted end - it "#gets(nil,size)" do + it '#gets(nil,size)' do file = SymmetricEncryption::Reader.open(@filename) eof = file.eof? data = file.gets(nil, 4096) file.close @@ -214,26 +219,26 @@ # On JRuby Zlib::GzipReader.new(file) returns '' instead of nil # on an empty file if defined?(JRuby) && options[:compress] && (usecase == :empty) assert_equal '', data else - assert_equal nil, data + assert_nil data end end end - it "#gets(delim)" do + it '#gets(delim)' do SymmetricEncryption::Reader.open(@filename) do |file| i = 0 while line = file.gets("\n") assert_equal @data[i], line i += 1 end assert_equal (@data_size > 0 ? 3 : 0), i end end - it "#gets(delim,size)" do + it '#gets(delim,size)' do SymmetricEncryption::Reader.open(@filename) do |file| i = 0 while file.gets("\n", 128) i += 1 end