test/reader_test.rb in symmetric-encryption-2.0.1 vs test/reader_test.rb in symmetric-encryption-2.0.2

- old
+ new

@@ -111,19 +111,19 @@ setup do case usecase when :data # Create encrypted file @eof = false - @filename = '._test' + @filename = '_test' @header = (options[:header] != false) SymmetricEncryption::Writer.open(@filename, options) do |file| @data.inject(0) {|sum,str| sum + file.write(str)} end when :empty @data_str = '' @eof = true - @filename = '._test_empty' + @filename = '_test_empty' @header = (options[:header] != false) SymmetricEncryption::Writer.open(@filename, options) do |file| # Leave data portion empty end when :blank @@ -242,11 +242,11 @@ end end context "reading from files with previous keys" do setup do - @filename = '._test' + @filename = '_test' # Create encrypted file with old encryption key SymmetricEncryption::Writer.open(@filename, :version => 0) do |file| @data.inject(0) {|sum,str| sum + file.write(str)} end end @@ -280,18 +280,22 @@ end end context "reading from files with previous keys without a header" do setup do - @filename = '._test' + @filename = '_test' # Create encrypted file with old encryption key SymmetricEncryption::Writer.open(@filename, :version => 0, :header => false, :random_key => false) do |file| @data.inject(0) {|sum,str| sum + file.write(str)} end end teardown do - File.delete(@filename) if File.exist?(@filename) + begin + File.delete(@filename) if File.exist?(@filename) + rescue Errno::EACCES + # Required for Windows + end end should "decrypt from file in a single read" do decrypted = SymmetricEncryption::Reader.open(@filename, :version => 0) {|file| file.read} assert_equal @data_str, decrypted