juicer 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +10 -0
- data/Manifest.txt +58 -0
- data/Rakefile +44 -0
- data/Readme.rdoc +143 -0
- data/bin/juicer +8 -0
- data/lib/juicer.rb +70 -0
- data/lib/juicer/binary.rb +173 -0
- data/lib/juicer/cache_buster.rb +45 -0
- data/lib/juicer/chainable.rb +106 -0
- data/lib/juicer/cli.rb +56 -0
- data/lib/juicer/command/install.rb +59 -0
- data/lib/juicer/command/list.rb +50 -0
- data/lib/juicer/command/merge.rb +185 -0
- data/lib/juicer/command/util.rb +32 -0
- data/lib/juicer/command/verify.rb +60 -0
- data/lib/juicer/core.rb +59 -0
- data/lib/juicer/css_cache_buster.rb +99 -0
- data/lib/juicer/install/base.rb +186 -0
- data/lib/juicer/install/jslint_installer.rb +51 -0
- data/lib/juicer/install/rhino_installer.rb +52 -0
- data/lib/juicer/install/yui_compressor_installer.rb +66 -0
- data/lib/juicer/jslint.rb +90 -0
- data/lib/juicer/merger/base.rb +74 -0
- data/lib/juicer/merger/css_dependency_resolver.rb +25 -0
- data/lib/juicer/merger/dependency_resolver.rb +82 -0
- data/lib/juicer/merger/javascript_dependency_resolver.rb +21 -0
- data/lib/juicer/merger/javascript_merger.rb +30 -0
- data/lib/juicer/merger/stylesheet_merger.rb +112 -0
- data/lib/juicer/minifyer/yui_compressor.rb +129 -0
- data/tasks/ann.rake +80 -0
- data/tasks/bones.rake +20 -0
- data/tasks/gem.rake +201 -0
- data/tasks/git.rake +40 -0
- data/tasks/notes.rake +27 -0
- data/tasks/post_load.rake +34 -0
- data/tasks/rdoc.rake +50 -0
- data/tasks/rubyforge.rake +55 -0
- data/tasks/setup.rb +300 -0
- data/tasks/spec.rake +54 -0
- data/tasks/svn.rake +47 -0
- data/tasks/test.rake +40 -0
- data/tasks/test/setup.rake +35 -0
- data/test/bin/jslint.js +474 -0
- data/test/bin/rhino1_7R1.zip +0 -0
- data/test/bin/rhino1_7R2-RC1.zip +0 -0
- data/test/bin/yuicompressor +238 -0
- data/test/bin/yuicompressor-2.3.5.zip +0 -0
- data/test/bin/yuicompressor-2.4.2.zip +0 -0
- data/test/juicer/command/test_install.rb +53 -0
- data/test/juicer/command/test_list.rb +69 -0
- data/test/juicer/command/test_merge.rb +155 -0
- data/test/juicer/command/test_util.rb +54 -0
- data/test/juicer/command/test_verify.rb +33 -0
- data/test/juicer/install/test_installer_base.rb +195 -0
- data/test/juicer/install/test_jslint_installer.rb +54 -0
- data/test/juicer/install/test_rhino_installer.rb +57 -0
- data/test/juicer/install/test_yui_compressor_installer.rb +56 -0
- data/test/juicer/merger/test_base.rb +122 -0
- data/test/juicer/merger/test_css_dependency_resolver.rb +36 -0
- data/test/juicer/merger/test_javascript_dependency_resolver.rb +39 -0
- data/test/juicer/merger/test_javascript_merger.rb +74 -0
- data/test/juicer/merger/test_stylesheet_merger.rb +178 -0
- data/test/juicer/minifyer/test_yui_compressor.rb +159 -0
- data/test/juicer/test_cache_buster.rb +58 -0
- data/test/juicer/test_chainable.rb +94 -0
- data/test/juicer/test_core.rb +47 -0
- data/test/juicer/test_css_cache_buster.rb +72 -0
- data/test/juicer/test_jslint.rb +33 -0
- data/test/test_helper.rb +146 -0
- data/test/test_juicer.rb +4 -0
- metadata +194 -0
@@ -0,0 +1,54 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), %w[.. .. test_helper])) unless defined?(Juicer)
|
2
|
+
|
3
|
+
class Dummy
|
4
|
+
include Juicer::Command::Util
|
5
|
+
end
|
6
|
+
|
7
|
+
class TestCommandUtil < Test::Unit::TestCase
|
8
|
+
|
9
|
+
def setup
|
10
|
+
@impl = Dummy.new
|
11
|
+
Juicer::Test::FileSetup.new.create
|
12
|
+
Dir.glob("test/data/*.min.css").each { |file| File.delete(file) }
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_files_from_single_file
|
16
|
+
files = @impl.files("test/data/a.css")
|
17
|
+
assert files.is_a?(Array)
|
18
|
+
assert_equal "test/data/a.css", files.sort.join
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_files_from_single_glob_pattern
|
22
|
+
files = @impl.files("test/data/*.css")
|
23
|
+
assert files.is_a?(Array)
|
24
|
+
assert_equal %w{a.css a1.css b.css b1.css c1.css d1.css path_test.css path_test2.css}.collect { |f| "test/data/#{f}" }.join, files.sort.join
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_files_from_mixed_arguments
|
28
|
+
files = @impl.files("test/data/*.css", "test/data/a.js")
|
29
|
+
assert files.is_a?(Array)
|
30
|
+
assert_equal %w{a.css a.js a1.css b.css b1.css c1.css d1.css path_test.css path_test2.css}.collect { |f| "test/data/#{f}" }.join, files.sort.join
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_files_from_array
|
34
|
+
files = @impl.files(["test/data/*.css", "test/data/a.js"])
|
35
|
+
assert files.is_a?(Array)
|
36
|
+
assert_equal %w{a.css a.js a1.css b.css b1.css c1.css d1.css path_test.css path_test2.css}.collect { |f| "test/data/#{f}" }.join, files.sort.join
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_relative_path_single_file
|
40
|
+
assert_equal "test/data/a.css", @impl.relative("test/data/a.css")
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_relative_path_many_files
|
44
|
+
files = @impl.relative(Dir.glob("test/data/*.css"))
|
45
|
+
assert files.is_a?(Array)
|
46
|
+
assert_equal %w{a.css a1.css b.css b1.css c1.css d1.css path_test.css path_test2.css}.collect { |f| "test/data/#{f}" }.join, files.sort.join
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_relative_path_many_files_explicit_reference
|
50
|
+
files = @impl.relative(Dir.glob("test/data/*.css"), "lib")
|
51
|
+
assert files.is_a?(Array)
|
52
|
+
assert_equal %w{a.css a1.css b.css b1.css c1.css d1.css path_test.css path_test2.css}.collect { |f| "../test/data/#{f}" }.join, files.sort.join
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), %w[.. .. test_helper])) unless defined?(Juicer)
|
2
|
+
|
3
|
+
class TestVerifyCommand < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
@io = StringIO.new
|
7
|
+
@command = Juicer::Command::Verify.new(Logger.new(@io))
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_no_files
|
11
|
+
assert_raise ArgumentError do
|
12
|
+
@command.execute []
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_installer_not_found
|
17
|
+
Juicer.home = path("somewhere")
|
18
|
+
|
19
|
+
assert_raise FileNotFoundError do
|
20
|
+
@command.execute path("a.js")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_verify_several_files
|
25
|
+
Juicer.home = path(".juicer")
|
26
|
+
installer = Juicer::Install::JSLintInstaller.new(path(".juicer"))
|
27
|
+
installer.install unless installer.installed?
|
28
|
+
|
29
|
+
@command.execute([path("ok.js"), path("not-ok.js"), path("a.js")])
|
30
|
+
assert_match(/OK!/, @io.string)
|
31
|
+
assert_match(/Problems detected/, @io.string)
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,195 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), %w[.. .. test_helper])) unless defined?(Juicer)
|
2
|
+
require File.expand_path(File.join(File.dirname(__FILE__), %w[.. .. .. lib juicer install base]))
|
3
|
+
|
4
|
+
module Juicer
|
5
|
+
module Install
|
6
|
+
class SomeMagicInstaller < Juicer::Install::Base
|
7
|
+
def install(version = nil)
|
8
|
+
version ||= "1.0.0"
|
9
|
+
ver = super(version)
|
10
|
+
File.open(File.join(@install_dir, path, "bin", ver + ".app"), "w") do |file|
|
11
|
+
file.puts version
|
12
|
+
end
|
13
|
+
|
14
|
+
version
|
15
|
+
end
|
16
|
+
|
17
|
+
def uninstall(version = "1.0.0")
|
18
|
+
super(version) do |path, version|
|
19
|
+
File.delete(File.join(path, "bin", version + ".app"))
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
class SomeOtherInstaller < Juicer::Install::SomeMagicInstaller
|
25
|
+
def install(version = nil)
|
26
|
+
version ||= "1.0.0"
|
27
|
+
super(version)
|
28
|
+
end
|
29
|
+
|
30
|
+
def latest
|
31
|
+
"1.0.0"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
class TestInstallerBase < Test::Unit::TestCase
|
38
|
+
|
39
|
+
def initialize(*args)
|
40
|
+
super
|
41
|
+
@juicer_home = File.expand_path(File.join("test", "data", ".juicer"))
|
42
|
+
end
|
43
|
+
|
44
|
+
def setup
|
45
|
+
FileUtils.rm_rf @juicer_home
|
46
|
+
@installer = Juicer::Install::SomeMagicInstaller.new(@juicer_home)
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_default_installation_directory_should_be_juicer_home
|
50
|
+
installer = Juicer::Install::SomeMagicInstaller.new
|
51
|
+
assert_equal Juicer.home, installer.install_dir
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_override_installation_directory
|
55
|
+
installer = Juicer::Install::SomeMagicInstaller.new("/home/baluba")
|
56
|
+
assert_equal "/home/baluba", installer.install_dir
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_latest_method_should_raise_NotImplementedError
|
60
|
+
assert_raise NotImplementedError do
|
61
|
+
@installer.latest
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_path
|
66
|
+
assert_equal "lib/some_magic", @installer.path
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_bin_path
|
70
|
+
assert_equal "lib/some_magic/bin", @installer.bin_path
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_name
|
74
|
+
assert_equal "Some Magic", @installer.name
|
75
|
+
end
|
76
|
+
|
77
|
+
def test_installed
|
78
|
+
assert !@installer.installed?("x.y.z")
|
79
|
+
@installer.install("x.y.z")
|
80
|
+
assert @installer.installed?("x.y.z")
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_installation_should_fail_when_already_installed
|
84
|
+
@installer.install("1.0.0")
|
85
|
+
|
86
|
+
assert_raise RuntimeError do
|
87
|
+
@installer.install("1.0.0")
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def test_installation_should_create_bin_and_release_folders
|
92
|
+
assert_equal "1.0.0", @installer.install("1.0.0")
|
93
|
+
assert File.exists?(File.join(@juicer_home, "lib/some_magic/bin"))
|
94
|
+
assert File.exists?(File.join(@juicer_home, "lib/some_magic/1.0.0"))
|
95
|
+
end
|
96
|
+
|
97
|
+
def test_uninstall_should_remove_library_path_when_only_version_is_uninstalled
|
98
|
+
@installer.install("1.0.0")
|
99
|
+
@installer.uninstall("1.0.0")
|
100
|
+
assert !File.exists?(File.join(@juicer_home, "lib/some_magic"))
|
101
|
+
end
|
102
|
+
|
103
|
+
def test_uninstall_should_keep_other_versions
|
104
|
+
@installer.install("1.0.0")
|
105
|
+
@installer.install("1.0.1")
|
106
|
+
@installer.uninstall("1.0.0")
|
107
|
+
assert !File.exists?(File.join(@juicer_home, "lib/some_magic/1.0.0"))
|
108
|
+
assert File.exists?(File.join(@juicer_home, "lib/some_magic"))
|
109
|
+
end
|
110
|
+
|
111
|
+
def test_download_should_cache_files_and_only_redownload_when_forced_to_do_so
|
112
|
+
@installer.download("http://www.julienlecomte.net/yuicompressor/")
|
113
|
+
filename = File.join(@juicer_home, "download/some_magic/yuicompressor")
|
114
|
+
assert File.exists?(filename)
|
115
|
+
sleep(0.5)
|
116
|
+
|
117
|
+
mtime = File.stat(filename).mtime
|
118
|
+
@installer.download("http://www.julienlecomte.net/yuicompressor/")
|
119
|
+
assert_equal mtime, File.stat(filename).mtime
|
120
|
+
sleep(0.5)
|
121
|
+
|
122
|
+
@installer.download("http://www.julienlecomte.net/yuicompressor/", true)
|
123
|
+
assert_not_equal mtime, File.stat(filename).mtime
|
124
|
+
end
|
125
|
+
|
126
|
+
def test_installer_should_not_report_true_when_missing_dependencies
|
127
|
+
@installer.install
|
128
|
+
|
129
|
+
installer = Juicer::Install::SomeMagicInstaller.new(@juicer_home)
|
130
|
+
assert !installer.installed?("1.0.1"), "Installer should be installed"
|
131
|
+
|
132
|
+
installer.dependency Juicer::Install::SomeOtherInstaller
|
133
|
+
assert !installer.installed?("1.0.1"), "Installer should not report as being installed when missing dependencies"
|
134
|
+
end
|
135
|
+
|
136
|
+
def installer_with_single_dependency_should_have_it_installed_on_install
|
137
|
+
installer = Juicer::Install::SomeMagicInstaller.new(@juicer_home)
|
138
|
+
installer.dependency Juicer::Install::SomeOtherInstaller
|
139
|
+
installer.install "1.0.0"
|
140
|
+
assert File.exists?(File.join(@juicer_home, "lib/some_magic/1.0.0"))
|
141
|
+
assert File.exists?(File.join(@juicer_home, "lib/some_other/1.0.0"))
|
142
|
+
end
|
143
|
+
|
144
|
+
def test_installed_dependency_should_not_cause_error
|
145
|
+
installer = Juicer::Install::SomeMagicInstaller.new(@juicer_home)
|
146
|
+
installer.dependency Juicer::Install::SomeOtherInstaller
|
147
|
+
|
148
|
+
dep = Juicer::Install::SomeOtherInstaller.new
|
149
|
+
dep.install unless dep.installed?
|
150
|
+
|
151
|
+
assert_nothing_raised do
|
152
|
+
installer.install "1.0.0"
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
def test_single_dependency_symbol
|
157
|
+
installer = Juicer::Install::SomeMagicInstaller.new(@juicer_home)
|
158
|
+
installer.dependency :some_other
|
159
|
+
installer.install "1.0.0"
|
160
|
+
assert File.exists?(File.join(@juicer_home, "lib/some_magic/1.0.0"))
|
161
|
+
assert File.exists?(File.join(@juicer_home, "lib/some_other/1.0.0"))
|
162
|
+
end
|
163
|
+
|
164
|
+
def test_single_dependency_string
|
165
|
+
installer = Juicer::Install::SomeMagicInstaller.new(@juicer_home)
|
166
|
+
installer.dependency "some_other"
|
167
|
+
installer.install "1.0.0"
|
168
|
+
assert File.exists?(File.join(@juicer_home, "lib/some_magic/1.0.0"))
|
169
|
+
assert File.exists?(File.join(@juicer_home, "lib/some_other/1.0.0"))
|
170
|
+
end
|
171
|
+
|
172
|
+
def test_multiple_dependencies
|
173
|
+
installer = Juicer::Install::SomeMagicInstaller.new(@juicer_home)
|
174
|
+
installer.dependency :some_other
|
175
|
+
installer.dependency :some_other, "2.0.4"
|
176
|
+
installer.dependency :some_other, "3.0.5"
|
177
|
+
installer.install "1.0.0"
|
178
|
+
assert File.exists?(File.join(@juicer_home, "lib/some_magic/1.0.0"))
|
179
|
+
assert File.exists?(File.join(@juicer_home, "lib/some_other/1.0.0"))
|
180
|
+
assert File.exists?(File.join(@juicer_home, "lib/some_other/2.0.4"))
|
181
|
+
assert File.exists?(File.join(@juicer_home, "lib/some_other/3.0.5"))
|
182
|
+
end
|
183
|
+
|
184
|
+
def test_get_class
|
185
|
+
assert_equal Juicer::Install::SomeMagicInstaller, Juicer::Install.get(Juicer::Install::SomeMagicInstaller)
|
186
|
+
end
|
187
|
+
|
188
|
+
def test_get_class_from_symbol
|
189
|
+
assert_equal Juicer::Install::SomeMagicInstaller, Juicer::Install.get(:some_magic)
|
190
|
+
end
|
191
|
+
|
192
|
+
def test_get_class_from_string
|
193
|
+
assert_equal Juicer::Install::SomeMagicInstaller, Juicer::Install.get("some_magic")
|
194
|
+
end
|
195
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), %w[.. .. test_helper])) unless defined?(Juicer)
|
2
|
+
|
3
|
+
class TestJsLintInstaller < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
@installer = Juicer::Install::JSLintInstaller.new(path(".juicer"))
|
6
|
+
end
|
7
|
+
|
8
|
+
def teardown
|
9
|
+
FileUtils.rm_rf(path(".juicer/lib")) if File.exists?(path(".juicer/lib"))
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_install_should_download_js
|
13
|
+
@installer.install unless @installer.installed?
|
14
|
+
|
15
|
+
assert File.exists?(path(".juicer"))
|
16
|
+
assert File.exists?(path(".juicer/lib"))
|
17
|
+
assert File.exists?(path(".juicer/lib/jslint"))
|
18
|
+
assert File.exists?(path(".juicer/lib/jslint/bin"))
|
19
|
+
assert_match(/jslint-\d\.\d\.js/, Dir.glob(path(".juicer/lib/jslint/bin/*"))[0])
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_uninstall_should_remove_all_files_and_empty_directories
|
23
|
+
@installer.install
|
24
|
+
assert File.exists?(path(".juicer/lib/jslint/bin"))
|
25
|
+
assert_equal 1, Dir.glob(path(".juicer/lib/jslint/**/*")).find_all { |f| File.file?(f) }.length
|
26
|
+
|
27
|
+
@installer.uninstall
|
28
|
+
assert !File.exists?(path(".juicer/lib/jslint"))
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_install_specific_version
|
32
|
+
@installer.install("1.0")
|
33
|
+
|
34
|
+
assert File.exists?(path(".juicer/lib/jslint/bin"))
|
35
|
+
assert_equal "jslint-1.0.js", File.basename(Dir.glob(path(".juicer/lib/jslint/bin/*"))[0])
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_install_should_install_rhino_also
|
39
|
+
assert !File.exists?(path(".juicer/lib/rhino"))
|
40
|
+
@installer.install
|
41
|
+
assert File.exists?(path(".juicer/lib/rhino"))
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_uninstall_should_leave_directories_when_other_versions_are_installed
|
45
|
+
@installer.install
|
46
|
+
@installer.install("1.1")
|
47
|
+
assert File.exists?(path(".juicer/lib/jslint/bin"))
|
48
|
+
assert_equal 2, Dir.glob(path(".juicer/lib/jslint/**/*")).find_all { |f| File.file?(f) }.length
|
49
|
+
|
50
|
+
@installer.uninstall("1.1")
|
51
|
+
assert File.exists?(path(".juicer/lib/jslint"))
|
52
|
+
assert_equal 1, Dir.glob(path(".juicer/lib/jslint/**/*")).find_all { |f| File.file?(f) }.length
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), %w[.. .. test_helper])) unless defined?(Juicer)
|
2
|
+
|
3
|
+
class TestRhinoInstaller < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
@installer = Juicer::Install::RhinoInstaller.new(path(".juicer"))
|
6
|
+
end
|
7
|
+
|
8
|
+
def teardown
|
9
|
+
FileUtils.rm_rf(path(".juicer/lib")) if File.exists?(path(".juicer/lib"))
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_check_installation
|
13
|
+
FileUtils.rm_rf(path(".juicer/lib")) if File.exists?(path(".juicer/lib"))
|
14
|
+
assert !@installer.installed?
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_install_should_download_jar_and_license
|
18
|
+
@installer.install
|
19
|
+
|
20
|
+
assert File.exists?(path(".juicer"))
|
21
|
+
assert File.exists?(path(".juicer/lib"))
|
22
|
+
assert File.exists?(path(".juicer/lib/rhino"))
|
23
|
+
assert File.exists?(path(".juicer/lib/rhino/bin"))
|
24
|
+
assert_match(/rhino\d\_\d[^\.]*\.jar/, Dir.glob(path(".juicer/lib/rhino/bin/*"))[0])
|
25
|
+
|
26
|
+
files = Dir.glob(path(".juicer/lib/rhino/*_*/**/*"))
|
27
|
+
assert_equal ["LICENSE.txt"], files.collect { |file| file.split("/").pop }.sort
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_uninstall_should_remove_all_files_and_empty_directories
|
31
|
+
@installer.install
|
32
|
+
assert File.exists?(path(".juicer/lib/rhino/bin"))
|
33
|
+
assert_equal 2, Dir.glob(path(".juicer/lib/rhino/**/*")).find_all { |f| File.file?(f) }.length
|
34
|
+
|
35
|
+
@installer.uninstall
|
36
|
+
assert !File.exists?(path(".juicer/lib/rhino"))
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_install_specific_version
|
40
|
+
@installer.install("1.7R2-RC1")
|
41
|
+
|
42
|
+
assert File.exists?(path(".juicer/lib/rhino/bin"))
|
43
|
+
assert File.exists?(path(".juicer/lib/rhino/1_7R2-RC1"))
|
44
|
+
assert_equal "rhino1_7R2-RC1.jar", File.basename(Dir.glob(path(".juicer/lib/rhino/bin/*"))[0])
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_uninstall_should_leave_directories_when_other_versions_are_installed
|
48
|
+
@installer.install
|
49
|
+
@installer.install("1.7R1")
|
50
|
+
assert File.exists?(path(".juicer/lib/rhino/bin"))
|
51
|
+
assert_equal 3, Dir.glob(path(".juicer/lib/rhino/**/*")).find_all { |f| File.file?(f) }.length
|
52
|
+
|
53
|
+
@installer.uninstall("1.7R2-RC1")
|
54
|
+
assert File.exists?(path(".juicer/lib/rhino"))
|
55
|
+
assert_equal 1, Dir.glob(path(".juicer/lib/rhino/**/*")).find_all { |f| File.file?(f) }.length
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), %w[.. .. test_helper])) unless defined?(Juicer)
|
2
|
+
|
3
|
+
class TestYuiCompressorInstall < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
@installer = Juicer::Install::YuiCompressorInstaller.new(path(".juicer"))
|
6
|
+
end
|
7
|
+
|
8
|
+
def teardown
|
9
|
+
FileUtils.rm_rf(path(".juicer/lib")) if File.exists?(path(".juicer/lib"))
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_check_installation
|
13
|
+
assert !@installer.installed?
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_install_should_download_jar_and_readme
|
17
|
+
@installer.install
|
18
|
+
|
19
|
+
assert File.exists?(path(".juicer"))
|
20
|
+
assert File.exists?(path(".juicer/lib"))
|
21
|
+
assert File.exists?(path(".juicer/lib/yui_compressor"))
|
22
|
+
assert File.exists?(path(".juicer/lib/yui_compressor/bin"))
|
23
|
+
assert_match(/yuicompressor-\d\.\d\.\d\.jar/, Dir.glob(path(".juicer/lib/yui_compressor/bin/*"))[0])
|
24
|
+
|
25
|
+
files = Dir.glob(path(".juicer/lib/yui_compressor/*.*.*/**/*"))
|
26
|
+
assert_equal ["CHANGELOG", "README"], files.collect { |file| file.split("/").pop }.sort
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_uninstall_should_remove_all_files_and_empty_directories
|
30
|
+
@installer.install
|
31
|
+
assert File.exists?(path(".juicer/lib/yui_compressor/bin"))
|
32
|
+
assert_equal 3, Dir.glob(path(".juicer/lib/yui_compressor/**/*")).find_all { |f| File.file?(f) }.length
|
33
|
+
|
34
|
+
@installer.uninstall
|
35
|
+
assert !File.exists?(path(".juicer/lib/yui_compressor"))
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_install_specific_version
|
39
|
+
@installer.install("2.3.5")
|
40
|
+
|
41
|
+
assert File.exists?(path(".juicer/lib/yui_compressor/bin"))
|
42
|
+
assert File.exists?(path(".juicer/lib/yui_compressor/2.3.5"))
|
43
|
+
assert_equal "yuicompressor-2.3.5.jar", File.basename(Dir.glob(path(".juicer/lib/yui_compressor/bin/*"))[0])
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_uninstall_should_leave_directories_when_other_versions_are_installed
|
47
|
+
@installer.install
|
48
|
+
@installer.install("2.3.5")
|
49
|
+
assert File.exists?(path(".juicer/lib/yui_compressor/bin"))
|
50
|
+
assert_equal 6, Dir.glob(path(".juicer/lib/yui_compressor/**/*")).find_all { |f| File.file?(f) }.length
|
51
|
+
|
52
|
+
@installer.uninstall("2.3.5")
|
53
|
+
assert File.exists?(path(".juicer/lib/yui_compressor"))
|
54
|
+
assert_equal 3, Dir.glob(path(".juicer/lib/yui_compressor/**/*")).find_all { |f| File.file?(f) }.length
|
55
|
+
end
|
56
|
+
end
|