Module: File::Write::Etest

Defined in:
lib/vex/base/filesystem/write.rb

Constant Summary collapse

TESTFILE =
"#{__FILE__}.test"

Instance Method Summary collapse

Instance Method Details

#test_touchesObject


22
23
24
25
26
27
28
29
30
# File 'lib/vex/base/filesystem/write.rb', line 22

def test_touches
  assert !File.exist?(TESTFILE)
  File.touch TESTFILE
  assert File.exist?(TESTFILE)
  File.touch TESTFILE
  assert File.exist?(TESTFILE)
  File.unlink TESTFILE
  assert !File.exist?(TESTFILE)
end

#test_writesObject


32
33
34
35
36
37
38
39
40
41
42
# File 'lib/vex/base/filesystem/write.rb', line 32

def test_writes
  assert !File.exist?(TESTFILE)
  File.write TESTFILE, "blabber"
  assert_equal("blabber", File.read(TESTFILE))
  File.write TESTFILE, "bla"
  assert_equal("bla", File.read(TESTFILE))
  File.write TESTFILE, ""
  assert_equal("", File.read(TESTFILE))
  File.unlink TESTFILE
  assert !File.exist?(TESTFILE)
end