Sha256: e63a0898f8a3d52467ee42e5e889411fa72deebf291cc0bf09fd59d361775158

Contents?: true

Size: 2 KB

Versions: 7

Compression:

Stored size: 2 KB

Contents

#!/usr/bin/env ruby

require 'test/unit'
require 'rake/packagetask'
require 'test/rake_test_setup'

class TestPackageTask < Test::Unit::TestCase
  include TestMethods

  def test_initialize
    pkg = Rake::PackageTask.new("pkgr", "1.2.3") { |p|
      p.package_files << "install.rb"
      p.package_files.include(
        '[A-Z]*',
        'bin/**/*',
        'lib/**/*.rb',
        'test/**/*.rb',
        'doc/**/*',
        'build/rubyapp.rb',
        '*.blurb')
      p.package_files.exclude(/\bCVS\b/)
      p.package_files.exclude(/~$/)
      p.package_dir = 'pkg'
      p.need_tar = true
      p.need_tar_gz = true
      p.need_tar_bz2 = true
      p.need_zip = true
    }

    assert_equal "pkg", pkg.package_dir
    assert pkg.package_files.include?("bin/rake")
    assert_equal 'pkgr', pkg.name
    assert_equal '1.2.3', pkg.version
    assert Rake::Task[:package]
    assert Rake::Task['pkg/pkgr-1.2.3.tgz']
    assert Rake::Task['pkg/pkgr-1.2.3.tar.gz']
    assert Rake::Task['pkg/pkgr-1.2.3.tar.bz2']
    assert Rake::Task['pkg/pkgr-1.2.3.zip']
    assert Rake::Task['pkg/pkgr-1.2.3']
    assert Rake::Task[:clobber_package]
    assert Rake::Task[:repackage]
  end

  def test_initialize_no_version
    e = assert_raises RuntimeError do
      Rake::PackageTask.new 'pkgr'
    end

    assert_equal 'Version required (or :noversion)', e.message
  end

  def test_initialize_noversion
    pkg = Rake::PackageTask.new 'pkgr', :noversion

    assert_equal 'pkg',  pkg.package_dir
    assert_equal 'pkgr', pkg.name
    assert_equal nil,    pkg.version
  end

  def test_clone
    pkg = Rake::PackageTask.new("x", :noversion)
    p2 = pkg.clone
    pkg.package_files << "y"
    p2.package_files << "x"
    assert_equal ["y"], pkg.package_files
    assert_equal ["x"], p2.package_files
  end

  def test_package_name
    pkg = Rake::PackageTask.new 'a', '1'

    assert_equal 'a-1', pkg.package_name
  end

  def test_package_name_noversion
    pkg = Rake::PackageTask.new 'a', :noversion

    assert_equal 'a', pkg.package_name
  end

end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
drake-0.9.0.0.3.0 test/lib/package_task_test.rb
rake-0.9.0 test/lib/package_task_test.rb
rake-0.9.0.beta.5 test/lib/package_task_test.rb
rake-0.9.0.beta.4 test/lib/package_task_test.rb
rake-0.9.0.beta.2 test/lib/package_task_test.rb
rake-0.9.0.beta.1 test/lib/package_task_test.rb
rake-0.9.0.beta.0 test/lib/package_task_test.rb