juicer 1.0.16 → 1.0.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. data/Gemfile.lock +27 -11
  2. data/History.txt +3 -0
  3. data/Rakefile +1 -1
  4. data/VERSION +1 -1
  5. data/lib/juicer.rb +1 -1
  6. data/lib/juicer/install/yui_compressor_installer.rb +2 -2
  7. metadata +29 -113
  8. data/GPATH +0 -0
  9. data/GRTAGS +0 -0
  10. data/GSYMS +0 -0
  11. data/GTAGS +0 -0
  12. data/test/bin/jslint-1.0.js +0 -523
  13. data/test/bin/jslint.js +0 -523
  14. data/test/bin/rhino1_7R1.zip +0 -0
  15. data/test/bin/rhino1_7R2-RC1.jar +0 -0
  16. data/test/bin/rhino1_7R2-RC1.zip +0 -0
  17. data/test/bin/rhino1_7R3.jar +0 -0
  18. data/test/bin/rhino1_7R3.zip +0 -0
  19. data/test/bin/yuicompressor +0 -0
  20. data/test/bin/yuicompressor-2.3.5.zip +0 -0
  21. data/test/bin/yuicompressor-2.4.2.jar +0 -0
  22. data/test/bin/yuicompressor-2.4.2.zip +0 -0
  23. data/test/data/Changelog.txt +0 -10
  24. data/test/data/a.css +0 -3
  25. data/test/data/a.js +0 -5
  26. data/test/data/a1.css +0 -5
  27. data/test/data/b.css +0 -1
  28. data/test/data/b.js +0 -5
  29. data/test/data/b1.css +0 -5
  30. data/test/data/b2.css +0 -5
  31. data/test/data/c1.css +0 -3
  32. data/test/data/css/2.gif +0 -1
  33. data/test/data/css/test.css +0 -15
  34. data/test/data/css/test2.css +0 -1
  35. data/test/data/css/test3.css +0 -12
  36. data/test/data/d1.css +0 -3
  37. data/test/data/images/1.png +0 -1
  38. data/test/data/my_app.js +0 -2
  39. data/test/data/not-ok.js +0 -2
  40. data/test/data/ok.js +0 -3
  41. data/test/data/path_test.css +0 -5
  42. data/test/data/path_test2.css +0 -14
  43. data/test/data/pkg/module/moda.js +0 -2
  44. data/test/data/pkg/module/modb.js +0 -3
  45. data/test/data/pkg/pkg.js +0 -1
  46. data/test/fixtures/rhino-download.html +0 -42
  47. data/test/fixtures/yui-download.html +0 -375
  48. data/test/test_helper.rb +0 -204
  49. data/test/unit/juicer/asset/path_resolver_test.rb +0 -76
  50. data/test/unit/juicer/asset/path_test.rb +0 -376
  51. data/test/unit/juicer/cache_buster_test.rb +0 -128
  52. data/test/unit/juicer/chainable_test.rb +0 -94
  53. data/test/unit/juicer/command/install_test.rb +0 -58
  54. data/test/unit/juicer/command/list_test.rb +0 -81
  55. data/test/unit/juicer/command/merge_test.rb +0 -162
  56. data/test/unit/juicer/command/util_test.rb +0 -58
  57. data/test/unit/juicer/command/verify_test.rb +0 -48
  58. data/test/unit/juicer/css_cache_buster_test.rb +0 -122
  59. data/test/unit/juicer/datafy_test.rb +0 -37
  60. data/test/unit/juicer/dependency_resolver/css_dependency_resolver_test.rb +0 -36
  61. data/test/unit/juicer/dependency_resolver/javascript_dependency_resolver_test.rb +0 -50
  62. data/test/unit/juicer/ext/string_test.rb +0 -59
  63. data/test/unit/juicer/ext/symbol_test.rb +0 -27
  64. data/test/unit/juicer/image_embed_test.rb +0 -339
  65. data/test/unit/juicer/install/installer_base_test.rb +0 -214
  66. data/test/unit/juicer/install/jslint_installer_test.rb +0 -54
  67. data/test/unit/juicer/install/rhino_installer_test.rb +0 -57
  68. data/test/unit/juicer/install/yui_compressor_test.rb +0 -56
  69. data/test/unit/juicer/jslint_test.rb +0 -60
  70. data/test/unit/juicer/merger/base_test.rb +0 -122
  71. data/test/unit/juicer/merger/javascript_merger_test.rb +0 -74
  72. data/test/unit/juicer/merger/stylesheet_merger_test.rb +0 -262
  73. data/test/unit/juicer/minifyer/closure_compressor_test.rb +0 -107
  74. data/test/unit/juicer/minifyer/yui_compressor_test.rb +0 -133
  75. data/test/unit/juicer_test.rb +0 -1
@@ -1,214 +0,0 @@
1
- require "test_helper"
2
-
3
- module Juicer
4
- module Install
5
- class SomeMagicInstaller < Juicer::Install::Base
6
- def install(version = nil)
7
- version ||= "1.0.0"
8
- ver = super(version)
9
- File.open(File.join(@install_dir, path, "bin", ver + ".app"), "w") do |file|
10
- file.puts version
11
- end
12
-
13
- version
14
- end
15
-
16
- def uninstall(version = "1.0.0")
17
- super(version) do |path, version|
18
- File.delete(File.join(path, "bin", version + ".app"))
19
- end
20
- end
21
- end
22
-
23
- class SomeOtherInstaller < Juicer::Install::SomeMagicInstaller
24
- def install(version = nil)
25
- version ||= "1.0.0"
26
- super(version)
27
- end
28
-
29
- def latest
30
- "1.0.0"
31
- end
32
- end
33
- end
34
- end
35
-
36
- class TestInstallerBase < Test::Unit::TestCase
37
- def initialize(*args)
38
- super
39
- @juicer_home = File.expand_path(File.join("test", "data", ".juicer"))
40
- end
41
-
42
- def setup
43
- FileUtils.rm_rf @juicer_home
44
- @installer = Juicer::Install::SomeMagicInstaller.new(@juicer_home)
45
- end
46
-
47
- context "installation directory" do
48
- should "should be Juicer.home by default" do
49
- installer = Juicer::Install::SomeMagicInstaller.new
50
- assert_equal Juicer.home, installer.install_dir
51
- end
52
-
53
- should "override installation directory" do
54
- installer = Juicer::Install::SomeMagicInstaller.new("/home/baluba")
55
- assert_equal "/home/baluba", installer.install_dir
56
- end
57
- end
58
-
59
- context "latest" do
60
- should "raise NotImplementedError" do
61
- assert_raise NotImplementedError do
62
- @installer.latest
63
- end
64
- end
65
- end
66
-
67
- context "paths and name" do
68
- should "reflect installer class name" do
69
- assert_equal "lib/some_magic", @installer.path
70
- end
71
-
72
- should "reflect installer class name for bin path" do
73
- assert_equal "lib/some_magic/bin", @installer.bin_path
74
- end
75
-
76
- should "reflect class name in human name" do
77
- assert_equal "Some Magic", @installer.name
78
- end
79
- end
80
-
81
- context "already installed module" do
82
- should "report as installed" do
83
- assert !@installer.installed?("x.y.z")
84
- @installer.install("x.y.z")
85
- assert @installer.installed?("x.y.z")
86
- end
87
-
88
- should "fail re-installation" do
89
- @installer.install("1.0.0")
90
-
91
- assert_raise RuntimeError do
92
- @installer.install("1.0.0")
93
- end
94
- end
95
- end
96
-
97
- context "installation" do
98
- should "create bin and release folders" do
99
- assert_equal "1.0.0", @installer.install("1.0.0")
100
- assert File.exists?(File.join(@juicer_home, "lib/some_magic/bin"))
101
- assert File.exists?(File.join(@juicer_home, "lib/some_magic/1.0.0"))
102
- end
103
- end
104
-
105
- context "uninstall" do
106
- should "remove library path when only version is uninstalled" do
107
- @installer.install("1.0.0")
108
- @installer.uninstall("1.0.0")
109
- assert !File.exists?(File.join(@juicer_home, "lib/some_magic"))
110
- end
111
-
112
- should "keep other versions" do
113
- @installer.install("1.0.0")
114
- @installer.install("1.0.1")
115
- @installer.uninstall("1.0.0")
116
- assert !File.exists?(File.join(@juicer_home, "lib/some_magic/1.0.0"))
117
- assert File.exists?(File.join(@juicer_home, "lib/some_magic"))
118
- end
119
- end
120
-
121
- context "download" do
122
- # TODO: Don't download
123
- should "cache files" do
124
- File.expects(:delete).at_most(0)
125
- @installer.download("http://www.julienlecomte.net/yuicompressor/")
126
- filename = File.join(@juicer_home, "download/some_magic/yuicompressor")
127
- assert File.exists?(filename)
128
- @installer.download("http://www.julienlecomte.net/yuicompressor/")
129
- end
130
-
131
- should "redownload cached files when forced" do
132
- File.expects(:delete).at_most(1)
133
- @installer.download("http://www.julienlecomte.net/yuicompressor/")
134
- filename = File.join(@juicer_home, "download/some_magic/yuicompressor")
135
- assert File.exists?(filename)
136
- File.expects(:open).at_most(1)
137
- @installer.download("http://www.julienlecomte.net/yuicompressor/", true)
138
- end
139
- end
140
-
141
- context "installer dependencies" do
142
- should "not return true from installer when missing dependencies" do
143
- @installer.install
144
-
145
- installer = Juicer::Install::SomeMagicInstaller.new(@juicer_home)
146
- assert !installer.installed?("1.0.1"), "Installer should be installed"
147
-
148
- installer.dependency Juicer::Install::SomeOtherInstaller
149
- assert !installer.installed?("1.0.1"), "Installer should not report as being installed when missing dependencies"
150
- end
151
-
152
- should "install single dependency" do
153
- installer = Juicer::Install::SomeMagicInstaller.new(@juicer_home)
154
- installer.dependency Juicer::Install::SomeOtherInstaller
155
- installer.install "1.0.0"
156
- assert File.exists?(File.join(@juicer_home, "lib/some_magic/1.0.0"))
157
- assert File.exists?(File.join(@juicer_home, "lib/some_other/1.0.0"))
158
- end
159
-
160
- should "not raise error when they exist" do
161
- installer = Juicer::Install::SomeMagicInstaller.new(@juicer_home)
162
- installer.dependency Juicer::Install::SomeOtherInstaller
163
-
164
- dep = Juicer::Install::SomeOtherInstaller.new
165
- dep.install unless dep.installed?
166
-
167
- assert_nothing_raised do
168
- installer.install "1.0.0"
169
- end
170
- end
171
-
172
- should "get dependency from single symbol" do
173
- installer = Juicer::Install::SomeMagicInstaller.new(@juicer_home)
174
- installer.dependency :some_other
175
- installer.install "1.0.0"
176
- assert File.exists?(File.join(@juicer_home, "lib/some_magic/1.0.0"))
177
- assert File.exists?(File.join(@juicer_home, "lib/some_other/1.0.0"))
178
- end
179
-
180
- should "get dependency from single string" do
181
- installer = Juicer::Install::SomeMagicInstaller.new(@juicer_home)
182
- installer.dependency "some_other"
183
- installer.install "1.0.0"
184
- assert File.exists?(File.join(@juicer_home, "lib/some_magic/1.0.0"))
185
- assert File.exists?(File.join(@juicer_home, "lib/some_other/1.0.0"))
186
- end
187
-
188
- should "support multiple dependencies" do
189
- installer = Juicer::Install::SomeMagicInstaller.new(@juicer_home)
190
- installer.dependency :some_other
191
- installer.dependency :some_other, "2.0.4"
192
- installer.dependency :some_other, "3.0.5"
193
- installer.install "1.0.0"
194
- assert File.exists?(File.join(@juicer_home, "lib/some_magic/1.0.0"))
195
- assert File.exists?(File.join(@juicer_home, "lib/some_other/1.0.0"))
196
- assert File.exists?(File.join(@juicer_home, "lib/some_other/2.0.4"))
197
- assert File.exists?(File.join(@juicer_home, "lib/some_other/3.0.5"))
198
- end
199
- end
200
-
201
- context "resolving class" do
202
- should "accept class input" do
203
- assert_equal Juicer::Install::SomeMagicInstaller, Juicer::Install.get(Juicer::Install::SomeMagicInstaller)
204
- end
205
-
206
- should "accept symbol input" do
207
- assert_equal Juicer::Install::SomeMagicInstaller, Juicer::Install.get(:some_magic)
208
- end
209
-
210
- should "accept string input" do
211
- assert_equal Juicer::Install::SomeMagicInstaller, Juicer::Install.get("some_magic")
212
- end
213
- end
214
- end
@@ -1,54 +0,0 @@
1
- require "test_helper"
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
@@ -1,57 +0,0 @@
1
- require "test_helper"
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.7R3")
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
@@ -1,56 +0,0 @@
1
- require "test_helper"
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
@@ -1,60 +0,0 @@
1
- require "test_helper"
2
-
3
- class TestJsLint < Test::Unit::TestCase
4
- def initialize(*args)
5
- @path = File.expand_path(path("../bin"))
6
- @file = path("jsltest.js")
7
- super
8
- end
9
-
10
- def setup
11
- FileUtils.mkdir(path("")) unless File.exists?(path(""))
12
- File.open(@file, "w") { |f| f.puts "" }
13
- end
14
-
15
- def teardown
16
- File.delete(@file)
17
- end
18
-
19
- context "verifying file with jslint" do
20
- should "shell out to rhino/jslint" do
21
- jslint = Juicer::JsLint.new(:bin_path => @path)
22
- jslint.expects(:execute).with("-jar \"#{@path}/rhino1_7R3.jar\" \"#{@path}/jslint-1.0.js\" \"#{@file}\"").returns("jslint: No problems")
23
-
24
- assert jslint.check(@file).ok?
25
- end
26
- end
27
-
28
- context "jslint report returns" do
29
- should "be a report object for valid files" do
30
- jslint = Juicer::JsLint.new(:bin_path => @path)
31
- jslint.expects(:execute).returns("jslint: No problems")
32
-
33
- assert_equal Juicer::JsLint::Report, jslint.check(@file).class
34
- end
35
-
36
- should "be a report object for invalid files" do
37
- jslint = Juicer::JsLint.new(:bin_path => @path)
38
- jslint.expects(:execute).returns("Wrong use of semicolon\nWrong blabla")
39
-
40
- assert_equal Juicer::JsLint::Report, jslint.check(path("not-ok.js")).class
41
- end
42
- end
43
-
44
- context "errors" do
45
- should "be available on report" do
46
- jslint = Juicer::JsLint.new(:bin_path => @path)
47
- jslint.expects(:execute).returns("Wrong use of semicolon\nWrong blabla\nWrong use of semicolon\nWrong blabla")
48
-
49
- assert_equal 2, jslint.check(@file).errors.length
50
- end
51
-
52
- should "be error objects" do
53
- jslint = Juicer::JsLint.new(:bin_path => @path)
54
- jslint.expects(:execute).returns("Wrong use of semicolon\nWrong blabla")
55
-
56
- error = jslint.check(@file).errors.first
57
- assert_equal Juicer::JsLint::Error, error.class
58
- end
59
- end
60
- end
@@ -1,122 +0,0 @@
1
- require "test_helper"
2
-
3
- class TestMergerBase < Test::Unit::TestCase
4
-
5
- def setup
6
- @file_merger = Juicer::Merger::Base.new
7
- Juicer::Test::FileSetup.new.create
8
- end
9
-
10
- def teardown
11
- file = path('test_out.css')
12
- File.delete(file) if File.exists?(file)
13
- end
14
-
15
- def test_constructor
16
- files = ['a.css', 'b.css'].collect { |file| path(file) }
17
- file_merger = Juicer::Merger::Base.new files
18
- assert_equal 2, file_merger.files.length
19
- end
20
-
21
- def test_append_duplicate_files
22
- @file_merger.append ['a.css', 'b.css'].collect { |file| path(file) }
23
- assert_equal 2, @file_merger.files.length,
24
- "b.css should not be included twice even when a.css imports it and it is manually added"
25
- end
26
-
27
- def test_append_duplicate
28
- @file_merger.append ['a.css', 'b.css'].collect { |file| path(file) }
29
- assert_equal 2, @file_merger.files.length
30
-
31
- @file_merger.append path('a.css')
32
- assert_equal 2, @file_merger.files.length
33
-
34
- @file_merger.append path('version.txt')
35
- assert_equal 3, @file_merger.files.length
36
- end
37
-
38
- def test_append_alias
39
- @file_merger << ['a.css', 'b.css'].collect { |file| path(file) }
40
- assert_equal 2, @file_merger.files.length
41
- end
42
-
43
- def test_save_to_stream
44
- a_css = path('a.css')
45
- a_css_contents = IO.read(a_css) + "\n"
46
- ios = StringIO.new
47
- @file_merger << a_css
48
- @file_merger.save ios
49
- assert_equal a_css_contents, ios.string
50
- end
51
-
52
- def test_save_to_file
53
- a_css = path('a.css')
54
- output_file = path('test_out.css')
55
- @file_merger << a_css
56
- @file_merger.save(output_file)
57
-
58
- assert_equal IO.read(a_css) + "\n", IO.read(output_file)
59
- end
60
-
61
- def test_save_merged_to_stream
62
- a_css = path('a.css')
63
- b_css = path('b.css')
64
- ios = StringIO.new
65
-
66
- @file_merger << a_css
67
- @file_merger << b_css
68
- @file_merger.save(ios)
69
-
70
- assert_equal "#{IO.read(a_css)}\n#{IO.read(b_css)}\n", ios.string
71
- end
72
-
73
- def test_save_merged_to_file
74
- a_css = path('a.css')
75
- b_css = path('b.css')
76
- a_contents = IO.read(a_css) + "\n"
77
- b_contents = IO.read(b_css) + "\n"
78
- output_file = path('test_out.css')
79
-
80
- @file_merger << a_css
81
- @file_merger << b_css
82
- @file_merger.save(output_file)
83
-
84
- assert_equal "#{IO.read(a_css)}\n#{IO.read(b_css)}\n", IO.read(output_file)
85
- end
86
-
87
- def test_resolve_dependencies
88
- Juicer::Merger::Base.publicize_methods do
89
- @file_merger.dependency_resolver = MockImportResolver.new
90
-
91
- @file_merger.resolve_dependencies('a.css')
92
- assert_equal 1, @file_merger.files.length
93
-
94
- @file_merger.resolve_dependencies('a.css')
95
- assert_equal 1, @file_merger.files.length
96
- end
97
- end
98
-
99
- def test_merge
100
- Juicer::Merger::Base.publicize_methods do
101
- a_content = <<EOF
102
- @import 'b.css';
103
-
104
- /* Dette er a.css */
105
-
106
- EOF
107
-
108
- content = @file_merger.merge(path('a.css'))
109
- assert_equal a_content, content
110
- end
111
- end
112
-
113
- def test_attributes
114
- assert_not_nil @file_merger.files
115
- end
116
- end
117
-
118
- class MockImportResolver
119
- def resolve(file)
120
- [file]
121
- end
122
- end