Sha256: 16e3b2706a7d1ae3fbcfb57efc6d0dba9e105742dc3b554daf1c3df03f5599f8

Contents?: true

Size: 1.9 KB

Versions: 8

Compression:

Stored size: 1.9 KB

Contents

require File.expand_path(File.join(File.dirname(__FILE__), %w[.. .. test_helper])) unless defined?(Juicer)

class TestJsLintInstaller < Test::Unit::TestCase
  def setup
    @installer = Juicer::Install::JSLintInstaller.new(path(".juicer"))
  end

  def teardown
    FileUtils.rm_rf(path(".juicer/lib")) if File.exists?(path(".juicer/lib"))
  end

  def test_install_should_download_js
    @installer.install unless @installer.installed?

    assert File.exists?(path(".juicer"))
    assert File.exists?(path(".juicer/lib"))
    assert File.exists?(path(".juicer/lib/jslint"))
    assert File.exists?(path(".juicer/lib/jslint/bin"))
    assert_match(/jslint-\d\.\d\.js/, Dir.glob(path(".juicer/lib/jslint/bin/*"))[0])
  end

  def test_uninstall_should_remove_all_files_and_empty_directories
    @installer.install
    assert File.exists?(path(".juicer/lib/jslint/bin"))
    assert_equal 1, Dir.glob(path(".juicer/lib/jslint/**/*")).find_all { |f| File.file?(f) }.length

    @installer.uninstall
    assert !File.exists?(path(".juicer/lib/jslint"))
  end

  def test_install_specific_version
    @installer.install("1.0")

    assert File.exists?(path(".juicer/lib/jslint/bin"))
    assert_equal "jslint-1.0.js", File.basename(Dir.glob(path(".juicer/lib/jslint/bin/*"))[0])
  end

  def test_install_should_install_rhino_also
    assert !File.exists?(path(".juicer/lib/rhino"))
    @installer.install
    assert File.exists?(path(".juicer/lib/rhino"))
 end

  def test_uninstall_should_leave_directories_when_other_versions_are_installed
    @installer.install
    @installer.install("1.1")
    assert File.exists?(path(".juicer/lib/jslint/bin"))
    assert_equal 2, Dir.glob(path(".juicer/lib/jslint/**/*")).find_all { |f| File.file?(f) }.length

    @installer.uninstall("1.1")
    assert File.exists?(path(".juicer/lib/jslint"))
    assert_equal 1, Dir.glob(path(".juicer/lib/jslint/**/*")).find_all { |f| File.file?(f) }.length
  end
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
cjohansen-juicer-0.2.4 test/juicer/install/test_jslint_installer.rb
cjohansen-juicer-0.2.5 test/juicer/install/test_jslint_installer.rb
juicer-0.2.6 test/juicer/install/test_jslint_installer.rb
juicer-0.2.0 test/juicer/install/test_jslint_installer.rb
juicer-0.2.5 test/juicer/install/test_jslint_installer.rb
juicer-0.2.4 test/juicer/install/test_jslint_installer.rb
juicer-0.2.1 test/juicer/install/test_jslint_installer.rb
juicer-0.2.3 test/juicer/install/test_jslint_installer.rb