Sha256: 4c3509d04f342cbb57790e3d696ab54f68adb5cd46120ca18e511085da463853

Contents?: true

Size: 1.12 KB

Versions: 19

Compression:

Stored size: 1.12 KB

Contents

# -*- coding: utf-8 -*-
require 'helper'
require 'write_xlsx'

class TestDeleteFiles < Minitest::Test
  def setup
    @dir_path = 'test_delete_empty_directory'
    Writexlsx::Utility.delete_files(@dir_path) if FileTest.exist?(@dir_path)
  end

  def test_delete_empty_directory
    Dir.mkdir(@dir_path)
    assert(FileTest.exist?(@dir_path))
    Writexlsx::Utility.delete_files(@dir_path)
    assert(!FileTest.exist?(@dir_path))
  end

  def test_delete_directory_and_one_file
    filename = 'test_file'
    Dir.mkdir(@dir_path)
    File.open(File.join(@dir_path, filename), "w") { |file| file.write("str") }
    assert(FileTest.exist?(@dir_path))
    assert(FileTest.exist?(File.join(@dir_path, filename)))
    Writexlsx::Utility.delete_files(@dir_path)
    assert(!FileTest.exist?(@dir_path))
  end

  def test_delete_directory_and_subdirectory
    subdir_name = 'subdir'
    Dir.mkdir(@dir_path)
    Dir.mkdir(File.join(@dir_path, subdir_name))
    assert(FileTest.exist?(@dir_path))
    assert(FileTest.exist?(File.join(@dir_path, subdir_name)))
    Writexlsx::Utility.delete_files(@dir_path)
    assert(!FileTest.exist?(@dir_path))
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
write_xlsx-1.09.4 test/test_delete_files.rb
write_xlsx-1.09.3 test/test_delete_files.rb
write_xlsx-1.09.2 test/test_delete_files.rb
write_xlsx-1.09.1 test/test_delete_files.rb
write_xlsx-1.09.0 test/test_delete_files.rb
write_xlsx-1.08.2 test/test_delete_files.rb
write_xlsx-1.08.1 test/test_delete_files.rb
write_xlsx-1.08.0 test/test_delete_files.rb
write_xlsx-1.07.0 test/test_delete_files.rb
write_xlsx-1.04.0 test/test_delete_files.rb
write_xlsx-1.02.0 test/test_delete_files.rb
write_xlsx-1.01.0 test/test_delete_files.rb
write_xlsx-1.00.0 test/test_delete_files.rb
write_xlsx-0.99.0 test/test_delete_files.rb
write_xlsx-0.97.0 test/test_delete_files.rb
write_xlsx-0.90.0 test/test_delete_files.rb
write_xlsx-0.89.0 test/test_delete_files.rb
write_xlsx-0.88.0 test/test_delete_files.rb
write_xlsx-0.87.0 test/test_delete_files.rb