Module: FileUtils::FastCopy::Etest

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

Instance Method Summary collapse

Instance Method Details

#test_fast_copyObject


33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/vex/base/filesystem/fast_copy.rb', line 33

def test_fast_copy
  assert File.exist?(__FILE__)
  File.unlink("tmp/somedata.dat") if File.exist?("tmp/somedata.dat")

  assert !File.exist?("tmp/somedata.dat")
  FileUtils.fast_copy __FILE__, "tmp/somedata.dat"
  assert_equal File.read("tmp/somedata.dat"), File.read(__FILE__)

  File.unlink("tmp/somedata.dat")
  File.touch("tmp/somedata.dat")
  assert_not_equal File.size("tmp/somedata.dat"), File.size(__FILE__)
  FileUtils.fast_copy __FILE__, "tmp/somedata.dat"
  assert_equal File.size("tmp/somedata.dat"), File.size(__FILE__)
end

#test_fast_copy_failuresObject


48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/vex/base/filesystem/fast_copy.rb', line 48

def test_fast_copy_failures
  assert_raise(Errno::ENOENT) {  
    FileUtils.fast_copy "fixtures/somedata.dat.nonexisting", "tmp/somedata.dat"
  }

  assert_raise(Errno::ENOENT) {  
    FileUtils.fast_copy "fixtures/somedata.dat.nonexisting", "tmp"
  }

  assert_raise(Errno::ENOENT) {  
    FileUtils.fast_copy __FILE__, "tmp/nonexisting/dir"
  }
end