Sha256: b3b718833c2370e894ebf17e1b7fb58cf2004c9cfb3a17216a83d25abeb7b3da

Contents?: true

Size: 1.59 KB

Versions: 169

Compression:

Stored size: 1.59 KB

Contents

require File.expand_path('../helper', __FILE__)
require 'rake/clean'

class TestRakeClean < Rake::TestCase
  def test_clean
    load 'rake/clean.rb', true

    assert Rake::Task['clean'], "Should define clean"
    assert Rake::Task['clobber'], "Should define clobber"
    assert Rake::Task['clobber'].prerequisites.include?("clean"),
      "Clobber should require clean"
  end

  def test_cleanup
    file_name = create_undeletable_file

    out, _ = capture_io do
      Rake::Cleaner.cleanup(file_name, :verbose => false)
    end
    assert_match(/failed to remove/i, out)

  ensure
    remove_undeletable_file
  end

  def test_cleanup_ignores_missing_files
    file_name = File.join(@tempdir, "missing_directory", "no_such_file")

    out, _ = capture_io do
      Rake::Cleaner.cleanup(file_name, :verbose => false)
    end
    refute_match(/failed to remove/i, out)
  end

  private

  def create_undeletable_file
    dir_name = File.join(@tempdir, "deletedir")
    file_name = File.join(dir_name, "deleteme")
    FileUtils.mkdir(dir_name)
    FileUtils.touch(file_name)
    FileUtils.chmod(0, file_name)
    FileUtils.chmod(0, dir_name)
    begin
      FileUtils.chmod(0644, file_name)
    rescue
      file_name
    else
      skip "Permission to delete files is different on thie system"
    end
  end

  def remove_undeletable_file
    dir_name = File.join(@tempdir, "deletedir")
    file_name = File.join(dir_name, "deleteme")
    FileUtils.chmod(0777, dir_name)
    FileUtils.chmod(0777, file_name)
    Rake::Cleaner.cleanup(file_name, :verbose => false)
    Rake::Cleaner.cleanup(dir_name, :verbose => false)
  end
end

Version data entries

169 entries across 153 versions & 58 rubygems

Version Path
mercadopago-custom-checkout-0.2.0 .gs/gems/rake-10.5.0/test/test_rake_clean.rb
video_chat_get-0.1.9 vendor/bundle/ruby/2.5.0/gems/rake-10.5.0/test/test_rake_clean.rb
video_chat_get-0.1.6 vendor/bundle/ruby/2.5.0/gems/rake-10.5.0/test/test_rake_clean.rb
lotrd-0.1.9 vendor/cache/ruby/2.6.0/gems/rake-10.5.0/test/test_rake_clean.rb
lotrd-0.1.8 vendor/cache/ruby/2.6.0/gems/rake-10.5.0/test/test_rake_clean.rb
lotrd-0.1.6 vendor/cache/ruby/2.6.0/gems/rake-10.5.0/test/test_rake_clean.rb
lotrd-0.1.5 vendor/cache/ruby/2.6.0/gems/rake-10.5.0/test/test_rake_clean.rb
video_chat_get-0.1.5 vendor/bundle/ruby/2.5.0/gems/rake-10.5.0/test/test_rake_clean.rb
video_chat_get-0.1.4 vendor/bundle/ruby/2.5.0/gems/rake-10.5.0/test/test_rake_clean.rb
video_chat_get-0.1.3 vendor/bundle/ruby/2.5.0/gems/rake-10.5.0/test/test_rake_clean.rb
video_chat_get-0.1.2 vendor/bundle/ruby/2.5.0/gems/rake-10.5.0/test/test_rake_clean.rb
video_chat_get-0.1.1 vendor/bundle/ruby/2.5.0/gems/rake-10.5.0/test/test_rake_clean.rb
video_chat_get-0.1.0 vendor/bundle/ruby/2.5.0/gems/rake-10.5.0/test/test_rake_clean.rb
josufst_palindrome-0.2.0 vendor/cache/gems/rake-10.5.0/test/test_rake_clean.rb
josufst_palindrome-0.2.0 vendor/cache/ruby/2.6.0/gems/rake-10.5.0/test/test_rake_clean.rb
josufst_palindrome-0.1.1 vendor/cache/gems/rake-10.5.0/test/test_rake_clean.rb
josufst_palindrome-0.1.1 vendor/cache/ruby/2.6.0/gems/rake-10.5.0/test/test_rake_clean.rb
nlmt-wrappers-0.0.1 vendor/bundle/ruby/2.6.0/gems/rake-10.5.0/test/test_rake_clean.rb
jscop-0.1.2 vendor/cache/ruby/2.6.0/gems/rake-10.5.0/test/test_rake_clean.rb
argon-1.3.1 vendor/bundle/ruby/2.7.0/gems/rake-10.5.0/test/test_rake_clean.rb