Sha256: 8ebb596560e20a32c05be898932ac4eb5d81fa4b9e2bd89e7d75f2adc94a0a81

Contents?: true

Size: 1.72 KB

Versions: 259

Compression:

Stored size: 1.72 KB

Contents

require File.expand_path('../helper', __FILE__)
require 'fileutils'

######################################################################
class TestRakeFileCreationTask < Rake::TestCase
  include Rake
  include Rake::DSL

  DUMMY_DIR = 'dummy_dir'

  def setup
    super

    Task.clear
  end

  def test_file_needed
    create_dir DUMMY_DIR
    fc_task = Task[DUMMY_DIR]
    assert_equal DUMMY_DIR, fc_task.name
    FileUtils.rm_rf fc_task.name
    assert fc_task.needed?, "file should be needed"
    FileUtils.mkdir fc_task.name
    assert_equal nil, fc_task.prerequisites.map { |n| Task[n].timestamp }.max
    assert ! fc_task.needed?, "file should not be needed"
  end

  def test_directory
    directory DUMMY_DIR
    fc_task = Task[DUMMY_DIR]
    assert_equal DUMMY_DIR, fc_task.name
    assert FileCreationTask === fc_task
  end

  def test_no_retriggers_on_filecreate_task
    create_timed_files(OLDFILE, NEWFILE)
    t1 = Rake.application.intern(FileCreationTask, OLDFILE).enhance([NEWFILE])
    t2 = Rake.application.intern(FileCreationTask, NEWFILE)
    assert ! t2.needed?, "Should not need to build new file"
    assert ! t1.needed?, "Should not need to rebuild old file because of new"
  end

  def test_no_retriggers_on_file_task
    create_timed_files(OLDFILE, NEWFILE)
    t1 = Rake.application.intern(FileCreationTask, OLDFILE).enhance([NEWFILE])
    t2 = Rake.application.intern(FileCreationTask, NEWFILE)
    assert ! t2.needed?, "Should not need to build new file"
    assert ! t1.needed?, "Should not need to rebuild old file because of new"
  end

  def test_very_early_timestamp
    t1 = Rake.application.intern(FileCreationTask, OLDFILE)
    assert t1.timestamp < Time.now
    assert t1.timestamp < Time.now - 1_000_000
  end
end

Version data entries

259 entries across 235 versions & 74 rubygems

Version Path
rake-10.1.1 test/test_rake_file_creation_task.rb
social_url_stats-0.0.1 vendor/ruby/1.9.1/gems/rake-10.1.0/test/test_rake_file_creation_task.rb
climine-0.0.2 vendor/bundle/ruby/2.0.0/gems/rake-10.1.0/test/test_rake_file_creation_task.rb
climine-0.0.1 vendor/bundle/ruby/2.0.0/gems/rake-10.1.0/test/test_rake_file_creation_task.rb
bundle_depot-0.2.2 fixtures/bundle/rake/4c3a94088cd7bd0ac6b190c7f40a19c809356cda7fbd7dd8860ed3155b8e5c3d/ruby/2.0.0/gems/rake-10.1.0/test/test_rake_file_creation_task.rb
bundle_depot-0.2.1 fixtures/bundle/rake/4c3a94088cd7bd0ac6b190c7f40a19c809356cda7fbd7dd8860ed3155b8e5c3d/ruby/2.0.0/gems/rake-10.1.0/test/test_rake_file_creation_task.rb
bundle_depot-0.2.0 fixtures/bundle/rake/4c3a94088cd7bd0ac6b190c7f40a19c809356cda7fbd7dd8860ed3155b8e5c3d/ruby/2.0.0/gems/rake-10.1.0/test/test_rake_file_creation_task.rb
bundle_depot-0.0.3 fixtures/bundle/rake/4c3a94088cd7bd0ac6b190c7f40a19c809356cda7fbd7dd8860ed3155b8e5c3d/ruby/2.0.0/gems/rake-10.1.0/test/test_rake_file_creation_task.rb
bundle_depot-0.0.2 fixtures/bundle/rake/4c3a94088cd7bd0ac6b190c7f40a19c809356cda7fbd7dd8860ed3155b8e5c3d/ruby/2.0.0/gems/rake-10.1.0/test/test_rake_file_creation_task.rb
bundle_depot-0.0.1 fixtures/bundle/rake/4c3a94088cd7bd0ac6b190c7f40a19c809356cda7fbd7dd8860ed3155b8e5c3d/ruby/2.0.0/gems/rake-10.1.0/test/test_rake_file_creation_task.rb
tnargav-1.3.3 vendor/bundle/ruby/1.9.1/gems/rake-10.1.0/test/test_rake_file_creation_task.rb
clickable_link-0.0.2 vendor/bundle/ruby/1.9.1/gems/rake-10.1.0/test/test_rake_file_creation_task.rb
syllable_counter-1.0.0 vendor/bundle/gems/rake-10.1.0/test/test_rake_file_creation_task.rb
challah-1.0.0 vendor/bundle/gems/rake-10.1.0/test/test_rake_file_creation_task.rb
tnargav-1.2.3 vendor/bundle/ruby/1.9.1/gems/rake-10.1.0/test/test_rake_file_creation_task.rb
rake-10.1.0 test/test_rake_file_creation_task.rb
rake-10.1.0.beta.3 test/test_rake_file_creation_task.rb
rake-10.1.0.beta.2 test/test_rake_file_creation_task.rb
rake-10.1.0.beta.1 test/test_rake_file_creation_task.rb