Module: File::Write::Etest
- Defined in:
- lib/vex/base/filesystem/write.rb
Constant Summary collapse
- TESTFILE =
"#{__FILE__}.test"
Instance Method Summary collapse
- #setup ⇒ Object
- #teardown ⇒ Object
- #test_touch_w_content ⇒ Object
- #test_touches ⇒ Object
- #test_writes ⇒ Object
Instance Method Details
#setup ⇒ Object
31 32 33 |
# File 'lib/vex/base/filesystem/write.rb', line 31 def setup File.unlink TESTFILE if File.exist?(TESTFILE) end |
#teardown ⇒ Object
35 36 37 |
# File 'lib/vex/base/filesystem/write.rb', line 35 def teardown File.unlink TESTFILE if File.exist?(TESTFILE) end |
#test_touch_w_content ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/vex/base/filesystem/write.rb', line 49 def test_touch_w_content assert !File.exist?(TESTFILE) File.touch TESTFILE, :content => "TEST CONTENT" assert_equal "TEST CONTENT", File.read(TESTFILE) File.touch TESTFILE, :content => "TEST CONTENT2" assert_equal "TEST CONTENT", File.read(TESTFILE) File.unlink TESTFILE assert !File.exist?(TESTFILE) end |
#test_touches ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'lib/vex/base/filesystem/write.rb', line 39 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_writes ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/vex/base/filesystem/write.rb', line 62 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 |