Sha256: 38d4be4c3ac5977f37b12c622b73cf385b685cea01a43493754ffca4f3ee130f
Contents?: true
Size: 1.66 KB
Versions: 1
Compression:
Stored size: 1.66 KB
Contents
#!/usr/bin/env ruby $:.unshift File.join(File.dirname(__FILE__), '..', '..', 'lib') require 'rubygems' require 'test/unit' require 'tempfile' require 'sysadmin' class Test_FileString < Test::Unit::TestCase def setup @testfile = Tempfile::new("test.txt") end def test_append src = 'hoge' expect = "hoge\n" 3.times do Sysadmin::FileString.append(@testfile, src) end open(@testfile) { |file| while line = file.gets assert_equal(expect, line) end } end def test_newfile init = 'init' second = 'second' expect = "second\n" Sysadmin::FileString.newfile(@testfile, init) Sysadmin::FileString.newfile(@testfile, second) open(@testfile) { |file| while line = file.gets assert_equal(expect, line) end } end def test_replace src = 'hoge' try = 'fuga' expect = "fuga\n" 3.times do Sysadmin::FileString.append(@testfile, src) end Sysadmin::FileString.replace(@testfile, src, try) open(@testfile) { |file| while line = file.gets assert_equal(expect, line) end } end def test_deleteString src = 'hoge' replace = 'fuga' erase = 'hoge' expect = "fuga\n" 3.times do Sysadmin::FileString.append(@testfile, src) end Sysadmin::FileString.replace(@testfile, src, replace) 2.times do Sysadmin::FileString.append(@testfile, src) end Sysadmin::FileString.delete(@testfile, erase) open(@testfile) { |file| while line = file.gets assert_equal(expect, line) end } end def teardown @testfile.close(true) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sysadmin-0.0.2 | test/lib/file_string_test.rb |