Sha256: 354bb6dd942b7fe5188a030173458a2d8efba5712dc0320060dc9b2bb0ace87d
Contents?: true
Size: 1.11 KB
Versions: 2
Compression:
Stored size: 1.11 KB
Contents
#!/usr/bin/env ruby require 'test/unit' require 'tempfile' require 'spruz' module Spruz class SpruzSecureWriteTest < Test::Unit::TestCase module A extend SecureWrite end def test_secure_write assert_equal 4, A.secure_write(fn = File.join(Dir.tmpdir, "A_file.#$$"), 'test') assert_equal 4, A.secure_write(fn = File.join(Dir.tmpdir, "A_file.#$$")) { |f| f.write('test') } assert_equal 'test', File.read(fn) assert_raise(ArgumentError) { A.secure_write } end module B extend Write end module C def self.write(*args) args end extend Write end class ::IO extend Write end def test_write assert_equal 4, B.write(fn = File.join(Dir.tmpdir, "B_file.#$$"), 'test') assert_equal 4, B.write(fn = File.join(Dir.tmpdir, "B_file.#$$")) { |f| f.write('test') } assert_equal 4, IO.write(fn = File.join(Dir.tmpdir, "IO_file.#$$"), 'test') assert_equal 'test', File.read(fn) result = C.write(fn = File.join(Dir.tmpdir, "C_file.#$$"), 'test') assert_equal [ fn, 'test' ], result end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
spruz-0.2.13 | tests/spruz_secure_write_test.rb |
spruz-0.2.12 | tests/spruz_secure_write_test.rb |