juicer 1.0.16 → 1.0.17
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +27 -11
- data/History.txt +3 -0
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/lib/juicer.rb +1 -1
- data/lib/juicer/install/yui_compressor_installer.rb +2 -2
- metadata +29 -113
- data/GPATH +0 -0
- data/GRTAGS +0 -0
- data/GSYMS +0 -0
- data/GTAGS +0 -0
- data/test/bin/jslint-1.0.js +0 -523
- data/test/bin/jslint.js +0 -523
- data/test/bin/rhino1_7R1.zip +0 -0
- data/test/bin/rhino1_7R2-RC1.jar +0 -0
- data/test/bin/rhino1_7R2-RC1.zip +0 -0
- data/test/bin/rhino1_7R3.jar +0 -0
- data/test/bin/rhino1_7R3.zip +0 -0
- data/test/bin/yuicompressor +0 -0
- data/test/bin/yuicompressor-2.3.5.zip +0 -0
- data/test/bin/yuicompressor-2.4.2.jar +0 -0
- data/test/bin/yuicompressor-2.4.2.zip +0 -0
- data/test/data/Changelog.txt +0 -10
- data/test/data/a.css +0 -3
- data/test/data/a.js +0 -5
- data/test/data/a1.css +0 -5
- data/test/data/b.css +0 -1
- data/test/data/b.js +0 -5
- data/test/data/b1.css +0 -5
- data/test/data/b2.css +0 -5
- data/test/data/c1.css +0 -3
- data/test/data/css/2.gif +0 -1
- data/test/data/css/test.css +0 -15
- data/test/data/css/test2.css +0 -1
- data/test/data/css/test3.css +0 -12
- data/test/data/d1.css +0 -3
- data/test/data/images/1.png +0 -1
- data/test/data/my_app.js +0 -2
- data/test/data/not-ok.js +0 -2
- data/test/data/ok.js +0 -3
- data/test/data/path_test.css +0 -5
- data/test/data/path_test2.css +0 -14
- data/test/data/pkg/module/moda.js +0 -2
- data/test/data/pkg/module/modb.js +0 -3
- data/test/data/pkg/pkg.js +0 -1
- data/test/fixtures/rhino-download.html +0 -42
- data/test/fixtures/yui-download.html +0 -375
- data/test/test_helper.rb +0 -204
- data/test/unit/juicer/asset/path_resolver_test.rb +0 -76
- data/test/unit/juicer/asset/path_test.rb +0 -376
- data/test/unit/juicer/cache_buster_test.rb +0 -128
- data/test/unit/juicer/chainable_test.rb +0 -94
- data/test/unit/juicer/command/install_test.rb +0 -58
- data/test/unit/juicer/command/list_test.rb +0 -81
- data/test/unit/juicer/command/merge_test.rb +0 -162
- data/test/unit/juicer/command/util_test.rb +0 -58
- data/test/unit/juicer/command/verify_test.rb +0 -48
- data/test/unit/juicer/css_cache_buster_test.rb +0 -122
- data/test/unit/juicer/datafy_test.rb +0 -37
- data/test/unit/juicer/dependency_resolver/css_dependency_resolver_test.rb +0 -36
- data/test/unit/juicer/dependency_resolver/javascript_dependency_resolver_test.rb +0 -50
- data/test/unit/juicer/ext/string_test.rb +0 -59
- data/test/unit/juicer/ext/symbol_test.rb +0 -27
- data/test/unit/juicer/image_embed_test.rb +0 -339
- data/test/unit/juicer/install/installer_base_test.rb +0 -214
- data/test/unit/juicer/install/jslint_installer_test.rb +0 -54
- data/test/unit/juicer/install/rhino_installer_test.rb +0 -57
- data/test/unit/juicer/install/yui_compressor_test.rb +0 -56
- data/test/unit/juicer/jslint_test.rb +0 -60
- data/test/unit/juicer/merger/base_test.rb +0 -122
- data/test/unit/juicer/merger/javascript_merger_test.rb +0 -74
- data/test/unit/juicer/merger/stylesheet_merger_test.rb +0 -262
- data/test/unit/juicer/minifyer/closure_compressor_test.rb +0 -107
- data/test/unit/juicer/minifyer/yui_compressor_test.rb +0 -133
- data/test/unit/juicer_test.rb +0 -1
@@ -1,128 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
|
3
|
-
require "test_helper"
|
4
|
-
require "juicer/cache_buster"
|
5
|
-
|
6
|
-
class CacheBusterTest < Test::Unit::TestCase
|
7
|
-
def setup
|
8
|
-
@filename = "tmp.cachebuster.txt"
|
9
|
-
File.open(@filename, "w") { |f| f.puts "Testing" }
|
10
|
-
end
|
11
|
-
|
12
|
-
def teardown
|
13
|
-
File.delete(@filename)
|
14
|
-
end
|
15
|
-
|
16
|
-
context "cleaning files with cache busters" do
|
17
|
-
should "remove cache buster query parameters" do
|
18
|
-
assert_equal @filename, Juicer::CacheBuster.clean("#@filename?jcb=1234567890")
|
19
|
-
end
|
20
|
-
|
21
|
-
should "remove cache buster query parameters, but preserve other query parameters" do
|
22
|
-
assert_equal "#@filename?some=param&others=again", Juicer::CacheBuster.clean("#@filename?some=param&jcb=1234567890&others=again")
|
23
|
-
end
|
24
|
-
|
25
|
-
should "remove cache buster query parameters with no name" do
|
26
|
-
assert_equal @filename, Juicer::CacheBuster.clean("#@filename?1234567890", nil)
|
27
|
-
end
|
28
|
-
|
29
|
-
should "not destroy numeric file names with no cache buster name" do
|
30
|
-
@numeric_filename = "815.gif"
|
31
|
-
File.open(@numeric_filename, "w") { |f| f.puts "Testing" }
|
32
|
-
assert_equal @numeric_filename, Juicer::CacheBuster.clean("#@numeric_filename?1234567890", nil)
|
33
|
-
File.delete(@numeric_filename)
|
34
|
-
end
|
35
|
-
|
36
|
-
should "remove cache buster query parameters with custom name" do
|
37
|
-
assert_equal @filename, Juicer::CacheBuster.clean("#@filename?cb=1234567890", :cb)
|
38
|
-
end
|
39
|
-
|
40
|
-
should "remove hard cache buster" do
|
41
|
-
assert_equal @filename, Juicer::CacheBuster.clean(@filename.sub(/(\.txt)/, '-jcb1234567890\1'))
|
42
|
-
end
|
43
|
-
|
44
|
-
should "remove hard cache buster and preserve query params" do
|
45
|
-
assert_equal "#@filename?hey=there", Juicer::CacheBuster.clean("#@filename?hey=there".sub(/(\.txt)/, '-jcb1234567890\1'))
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
context "creating soft cache busters" do
|
50
|
-
should "clean file before adding new cache buster" do
|
51
|
-
cache_buster = "jcb=1234567890"
|
52
|
-
assert_no_match /#{cache_buster}/, Juicer::CacheBuster.soft("#@filename?#{cache_buster}")
|
53
|
-
end
|
54
|
-
|
55
|
-
should "preserve query parameters" do
|
56
|
-
parameters = "id=1"
|
57
|
-
assert_match /#{parameters}/, Juicer::CacheBuster.soft("#@filename?#{parameters}")
|
58
|
-
end
|
59
|
-
|
60
|
-
should "raise error if file is not found" do
|
61
|
-
assert_raise ArgumentError do
|
62
|
-
Juicer::CacheBuster.path("#@filename.ico")
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
should "include mtime as query parameter" do
|
67
|
-
mtime = File.mtime(@filename).to_i
|
68
|
-
assert_equal "#@filename?jcb=#{mtime}", Juicer::CacheBuster.soft(@filename)
|
69
|
-
end
|
70
|
-
|
71
|
-
should "include only mtime when parameter name is nil" do
|
72
|
-
mtime = File.mtime(@filename).to_i
|
73
|
-
assert_equal "#@filename?#{mtime}", Juicer::CacheBuster.soft(@filename, nil)
|
74
|
-
end
|
75
|
-
|
76
|
-
should "include custom parameter name" do
|
77
|
-
mtime = File.mtime(@filename).to_i
|
78
|
-
assert_equal "#@filename?juicer=#{mtime}", Juicer::CacheBuster.soft(@filename, :juicer)
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
context "creating rails-style cache busters" do
|
83
|
-
should "clean file before adding new cache buster" do
|
84
|
-
cache_buster = "1234567890"
|
85
|
-
assert_no_match /#{cache_buster}/, Juicer::CacheBuster.rails("#@filename?#{cache_buster}")
|
86
|
-
end
|
87
|
-
|
88
|
-
should "append no cache buster when parameters exist" do
|
89
|
-
parameters = "id=1"
|
90
|
-
assert_match /#{parameters}/, Juicer::CacheBuster.rails("#@filename?#{parameters}")
|
91
|
-
end
|
92
|
-
|
93
|
-
should "include only mtime as query parameter" do
|
94
|
-
mtime = File.mtime(@filename).to_i
|
95
|
-
assert_equal "#@filename?#{mtime}", Juicer::CacheBuster.rails(@filename)
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
context "hard cache busters" do
|
100
|
-
setup { @filename.sub!(/\.txt/, '') }
|
101
|
-
teardown { @filename = "#@filename.txt" }
|
102
|
-
|
103
|
-
should "clean file before adding new cache buster" do
|
104
|
-
cache_buster = "-jcb1234567890"
|
105
|
-
assert_no_match /#{cache_buster}/, Juicer::CacheBuster.hard("#@filename#{cache_buster}.txt")
|
106
|
-
end
|
107
|
-
|
108
|
-
should "preserve query parameters" do
|
109
|
-
parameters = "id=1"
|
110
|
-
assert_match /#{parameters}/, Juicer::CacheBuster.hard("#@filename.txt?#{parameters}")
|
111
|
-
end
|
112
|
-
|
113
|
-
should "include mtime in filename" do
|
114
|
-
mtime = File.mtime("#@filename.txt").to_i
|
115
|
-
assert_equal "#@filename-jcb#{mtime}.txt", Juicer::CacheBuster.hard("#@filename.txt")
|
116
|
-
end
|
117
|
-
|
118
|
-
should "include only mtime when parameter name is nil" do
|
119
|
-
mtime = File.mtime("#@filename.txt").to_i
|
120
|
-
assert_equal "#@filename-#{mtime}.txt", Juicer::CacheBuster.hard("#@filename.txt", nil)
|
121
|
-
end
|
122
|
-
|
123
|
-
should "include custom parameter name" do
|
124
|
-
mtime = File.mtime("#@filename.txt").to_i
|
125
|
-
assert_equal "#@filename-juicer#{mtime}.txt", Juicer::CacheBuster.hard("#@filename.txt", :juicer)
|
126
|
-
end
|
127
|
-
end
|
128
|
-
end
|
@@ -1,94 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
|
3
|
-
class Host
|
4
|
-
include Juicer::Chainable
|
5
|
-
|
6
|
-
def initialize(msg = nil)
|
7
|
-
@msg = msg || ""
|
8
|
-
end
|
9
|
-
|
10
|
-
def dummy(ios)
|
11
|
-
ios.print @msg
|
12
|
-
end
|
13
|
-
|
14
|
-
chain_method :dummy
|
15
|
-
|
16
|
-
def unchained(ios)
|
17
|
-
ios.print @msg
|
18
|
-
end
|
19
|
-
|
20
|
-
def abortable(ios, abort = false)
|
21
|
-
ios.print @msg
|
22
|
-
abort_chain if abort
|
23
|
-
end
|
24
|
-
|
25
|
-
chain_method :abortable
|
26
|
-
end
|
27
|
-
|
28
|
-
class Dummy
|
29
|
-
end
|
30
|
-
|
31
|
-
class TestChainable < Test::Unit::TestCase
|
32
|
-
def test_next_initial_state
|
33
|
-
host = Host.new
|
34
|
-
assert host.respond_to?(:next_in_chain), "Host should respond to next_in_chain()"
|
35
|
-
assert_nil host.next_in_chain, "Next command should be nil for newly created object"
|
36
|
-
end
|
37
|
-
|
38
|
-
def test_set_next
|
39
|
-
host = Host.new
|
40
|
-
host2 = Host.new
|
41
|
-
host.next_in_chain = host2
|
42
|
-
assert_equal host2, host.next_in_chain
|
43
|
-
|
44
|
-
host3 = host.next_in_chain = Host.new
|
45
|
-
assert_not_equal host3, host
|
46
|
-
assert_not_equal host3, host2
|
47
|
-
assert_equal host3, host.next_in_chain
|
48
|
-
end
|
49
|
-
|
50
|
-
def test_set_next_return_value
|
51
|
-
host = Host.new
|
52
|
-
host2 = host.set_next(Host.new)
|
53
|
-
|
54
|
-
assert_not_equal host2, host
|
55
|
-
assert_equal host2, host.next_in_chain
|
56
|
-
end
|
57
|
-
|
58
|
-
def test_set_next_return_self_if_next_nil
|
59
|
-
host = Host.new
|
60
|
-
|
61
|
-
assert_not_nil host.set_next(nil)
|
62
|
-
assert_equal host, host.set_next(nil)
|
63
|
-
end
|
64
|
-
|
65
|
-
def test_simple_chain
|
66
|
-
host = Host.new("a")
|
67
|
-
host2 = host.next_in_chain = Host.new("b")
|
68
|
-
ios = StringIO.new
|
69
|
-
host.dummy(ios)
|
70
|
-
|
71
|
-
assert_equal "ab", ios.string
|
72
|
-
end
|
73
|
-
|
74
|
-
def test_unchained_method
|
75
|
-
host = Host.new("a")
|
76
|
-
host2 = host.next_in_chain = Host.new("b")
|
77
|
-
ios = StringIO.new
|
78
|
-
host.unchained(ios)
|
79
|
-
|
80
|
-
assert_equal "a", ios.string
|
81
|
-
end
|
82
|
-
|
83
|
-
def test_abort_chain
|
84
|
-
host = Host.new("a")
|
85
|
-
host2 = host.next_in_chain = Host.new("b")
|
86
|
-
ios = StringIO.new
|
87
|
-
|
88
|
-
host.abortable(ios)
|
89
|
-
assert_equal "ab", ios.string
|
90
|
-
|
91
|
-
host.abortable(ios, true)
|
92
|
-
assert_equal "aba", ios.string
|
93
|
-
end
|
94
|
-
end
|
@@ -1,58 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
|
3
|
-
class TestInstallCommand < Test::Unit::TestCase
|
4
|
-
def setup
|
5
|
-
@io = StringIO.new
|
6
|
-
@command = Juicer::Command::Install.new(Logger.new(@io))
|
7
|
-
FileUtils.rm_rf(path(".juicer/lib")) if File.exists?(path(".juicer/lib"))
|
8
|
-
end
|
9
|
-
|
10
|
-
context "checking version" do
|
11
|
-
should "bring up latest from installer" do
|
12
|
-
assert_equal "1.0", @command.version(Juicer::Install::JSLintInstaller.new)
|
13
|
-
end
|
14
|
-
|
15
|
-
should "use explicit version" do
|
16
|
-
@command.instance_eval { @version = "1.0.1" }
|
17
|
-
assert_equal "1.0.1", @command.version(Juicer::Install::JSLintInstaller.new)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
context "executing command" do
|
22
|
-
should "require atleast one argument" do
|
23
|
-
assert_raise ArgumentError do
|
24
|
-
@command.execute
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
should "install single library" do
|
29
|
-
installer = Juicer::Install::JSLintInstaller.new(path(".juicer"))
|
30
|
-
assert !installer.installed?
|
31
|
-
|
32
|
-
@command.instance_eval { @path = path(".juicer") }
|
33
|
-
@command.execute("jslint")
|
34
|
-
|
35
|
-
assert installer.installed?
|
36
|
-
end
|
37
|
-
|
38
|
-
should "not install already installed library" do
|
39
|
-
installer = Juicer::Install::JSLintInstaller.new(path(".juicer"))
|
40
|
-
installer.install
|
41
|
-
assert installer.installed?
|
42
|
-
|
43
|
-
@command.execute("jslint")
|
44
|
-
assert_match(/is already installed in/, @io.string)
|
45
|
-
end
|
46
|
-
|
47
|
-
should "install specific version" do
|
48
|
-
installer = Juicer::Install::JSLintInstaller.new(path(".juicer"))
|
49
|
-
assert !installer.installed?("0.9")
|
50
|
-
|
51
|
-
@command.instance_eval { @path = path(".juicer") }
|
52
|
-
@command.instance_eval { @version = "0.9" }
|
53
|
-
@command.execute("jslint")
|
54
|
-
|
55
|
-
assert installer.installed?("0.9")
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
@@ -1,81 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
|
3
|
-
class TestListCommand < Test::Unit::TestCase
|
4
|
-
|
5
|
-
def setup
|
6
|
-
@log = Juicer::LOGGER
|
7
|
-
@command = Juicer::Command::List.new(@log)
|
8
|
-
Juicer::Test::FileSetup.new.create
|
9
|
-
end
|
10
|
-
|
11
|
-
def test_list_nothing
|
12
|
-
assert_raise ArgumentError do
|
13
|
-
@command.execute
|
14
|
-
end
|
15
|
-
|
16
|
-
assert_raise ArgumentError do
|
17
|
-
@command.execute []
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_list_css_file
|
22
|
-
result = @command.execute "test/data/a.css"
|
23
|
-
|
24
|
-
msg = <<-STDOUT
|
25
|
-
Dependency chain for test/data/a.css:
|
26
|
-
test/data/b.css
|
27
|
-
test/data/a.css
|
28
|
-
STDOUT
|
29
|
-
|
30
|
-
assert_equal msg, result
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_list_js_file
|
34
|
-
result = @command.execute "test/data/a.js"
|
35
|
-
|
36
|
-
msg = <<-STDOUT
|
37
|
-
Dependency chain for test/data/a.js:
|
38
|
-
test/data/b.js
|
39
|
-
test/data/a.js
|
40
|
-
STDOUT
|
41
|
-
|
42
|
-
assert_equal msg, result
|
43
|
-
end
|
44
|
-
|
45
|
-
def test_list_several_files
|
46
|
-
result = @command.execute ["test/data/a.js", "test/data/b.js"]
|
47
|
-
|
48
|
-
msg = <<-STDOUT
|
49
|
-
Dependency chain for test/data/a.js:
|
50
|
-
test/data/b.js
|
51
|
-
test/data/a.js
|
52
|
-
|
53
|
-
Dependency chain for test/data/b.js:
|
54
|
-
test/data/a.js
|
55
|
-
test/data/b.js
|
56
|
-
STDOUT
|
57
|
-
|
58
|
-
assert_equal msg, result
|
59
|
-
end
|
60
|
-
|
61
|
-
def test_list_several_files_with_empties
|
62
|
-
result = @command.execute ["test/data/a.css", "test/data/b.css"]
|
63
|
-
|
64
|
-
msg = <<-STDOUT
|
65
|
-
Dependency chain for test/data/a.css:
|
66
|
-
test/data/b.css
|
67
|
-
test/data/a.css
|
68
|
-
|
69
|
-
Dependency chain for test/data/b.css:
|
70
|
-
test/data/b.css
|
71
|
-
STDOUT
|
72
|
-
|
73
|
-
assert_equal msg, result
|
74
|
-
end
|
75
|
-
|
76
|
-
def test_list_files_unable_to_guess_type
|
77
|
-
assert_raise FileNotFoundError do
|
78
|
-
@command.execute("test/data/*.txt")
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
@@ -1,162 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
|
3
|
-
class TestMergeCommand < Test::Unit::TestCase
|
4
|
-
def setup
|
5
|
-
@io = StringIO.new
|
6
|
-
@merge = Juicer::Command::Merge.new(Logger.new(@io))
|
7
|
-
|
8
|
-
Juicer::Test::FileSetup.new.create
|
9
|
-
|
10
|
-
["a.min.css", "not-ok.min.js"].each { |f| File.delete(path(f)) if File.exists?(path(f)) }
|
11
|
-
end
|
12
|
-
|
13
|
-
context "getting minifyer" do
|
14
|
-
should "return nil when minifyer is not specified" do
|
15
|
-
@merge.instance_eval { @minifyer = nil }
|
16
|
-
|
17
|
-
Juicer::Command::Merge.publicize_methods do
|
18
|
-
assert_nil @merge.minifyer
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
should "return nil when minifyer is empty string" do
|
23
|
-
@merge.instance_eval { @minifyer = "" }
|
24
|
-
|
25
|
-
Juicer::Command::Merge.publicize_methods do
|
26
|
-
assert_nil @merge.minifyer
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
should "return nil when minifyer is 'none'" do
|
31
|
-
Juicer::Command::Merge.publicize_methods do
|
32
|
-
@merge.instance_eval { @minifyer = "none" }
|
33
|
-
assert_nil @merge.minifyer
|
34
|
-
|
35
|
-
@merge.instance_eval { @minifyer = "None" }
|
36
|
-
assert_nil @merge.minifyer
|
37
|
-
|
38
|
-
@merge.instance_eval { @minifyer = "NONE" }
|
39
|
-
assert_nil @merge.minifyer
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
should "get specified minifyer" do
|
44
|
-
Juicer::Command::Merge.publicize_methods do
|
45
|
-
assert @merge.minifyer.class == Juicer::Minifyer::YuiCompressor
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
context "output name" do
|
51
|
-
should "have suffix prepended with min when input is a file" do
|
52
|
-
Juicer::Command::Merge.publicize_methods do
|
53
|
-
assert_equal File.expand_path("test.min.js"), @merge.output("test.js")
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
should "be timestamp when input is not provided" do
|
58
|
-
Juicer::Command::Merge.publicize_methods do
|
59
|
-
assert_match(/\d{10}\.min\.tmp/, @merge.output)
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
should "be instance variable output" do
|
64
|
-
Juicer::Command::Merge.publicize_methods do
|
65
|
-
@merge.instance_eval { @output = "output.css" }
|
66
|
-
assert_equal File.expand_path("output.css"), @merge.output
|
67
|
-
assert_equal File.expand_path("output.css"), @merge.output("bleh.css")
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
should "should be generated when output is directory" do
|
72
|
-
Juicer::Command::Merge.publicize_methods do
|
73
|
-
@merge.instance_eval { @output = path("css") }
|
74
|
-
assert_equal File.join(path("css"), "file.min.css"), @merge.output("file.css")
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
context "get merger" do
|
80
|
-
should "return object from valid type" do
|
81
|
-
Juicer::Command::Merge.publicize_methods do
|
82
|
-
assert_equal Juicer::Merger::JavaScriptMerger, @merge.merger("bleh.js")
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
should "default to js for invalid type" do
|
87
|
-
Juicer::Command::Merge.publicize_methods do
|
88
|
-
assert_equal Juicer::Merger::JavaScriptMerger, @merge.merger("bleh.txt")
|
89
|
-
assert_match(/Unknown type 'txt', defaulting to 'js'/, @io.string)
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
should "use preset type" do
|
94
|
-
Juicer::Command::Merge.publicize_methods do
|
95
|
-
@merge.instance_eval { @type = "css" }
|
96
|
-
assert_equal Juicer::Merger::StylesheetMerger, @merge.merger
|
97
|
-
assert_equal Juicer::Merger::StylesheetMerger, @merge.merger("bleh.txt")
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
context "merging" do
|
103
|
-
should "raise error without input" do
|
104
|
-
assert_raise SystemExit do
|
105
|
-
@merge.execute([])
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
should "raise error with bogus input" do
|
110
|
-
assert_raise SystemExit do
|
111
|
-
@merge.execute(["*.css", "bleh/*.js"])
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
should "fail if output exists" do
|
116
|
-
assert_raise SystemExit do
|
117
|
-
@merge.instance_eval { @output = path("a.css") }
|
118
|
-
@merge.execute(path("a.css"))
|
119
|
-
assert_match(/Run again with --force to overwrite/, @io.string)
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
|
-
should "update output when force option is set" do
|
124
|
-
assert_nothing_raised do
|
125
|
-
@merge.instance_eval { @force = true }
|
126
|
-
@merge.execute(path("a.css"))
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
|
-
should "merge files" do
|
131
|
-
begin
|
132
|
-
@merge.instance_eval { @output = path("a.min.css") }
|
133
|
-
assert @merge.execute(path("a1.css"))
|
134
|
-
assert_match "h2{font-size:10px}html{background:red}h1{font-size:12px}body{width:800px}", IO.read(path("a.min.css"))
|
135
|
-
rescue Test::Unit::AssertionFailedError => err
|
136
|
-
raise err
|
137
|
-
rescue Exception => err
|
138
|
-
puts err.message
|
139
|
-
end
|
140
|
-
end
|
141
|
-
|
142
|
-
should "raise error when jslint does not pass" do
|
143
|
-
assert_raise SystemExit do
|
144
|
-
@merge.execute(path("not-ok.js"))
|
145
|
-
assert_match(/Problems were detected during verification/, @io.string)
|
146
|
-
assert_no_match(/Ignoring detected problems/, @io.string)
|
147
|
-
end
|
148
|
-
end
|
149
|
-
|
150
|
-
should "ignore jslint problems" do
|
151
|
-
@merge.instance_eval { @ignore = true }
|
152
|
-
|
153
|
-
assert_nothing_raised do
|
154
|
-
@merge.execute(path("not-ok.js"))
|
155
|
-
assert_match(/Problems were detected during verification/, @io.string)
|
156
|
-
assert_match(/Ignoring detected problems/, @io.string)
|
157
|
-
end
|
158
|
-
end
|
159
|
-
|
160
|
-
should_eventually "warn about duplicated image urls for embedding"
|
161
|
-
end
|
162
|
-
end
|