sitefuel 0.0.0a
Sign up to get free protection for your applications and to get access to all the features.
- data/README +86 -0
- data/RELEASE_NOTES +7 -0
- data/bin/sitefuel +162 -0
- data/lib/sitefuel/Configuration.rb +35 -0
- data/lib/sitefuel/SiteFuelLogger.rb +128 -0
- data/lib/sitefuel/SiteFuelRuntime.rb +293 -0
- data/lib/sitefuel/extensions/ArrayComparisons.rb +34 -0
- data/lib/sitefuel/extensions/DynamicClassMethods.rb +19 -0
- data/lib/sitefuel/extensions/FileComparison.rb +24 -0
- data/lib/sitefuel/extensions/Silently.rb +27 -0
- data/lib/sitefuel/extensions/StringFormatting.rb +75 -0
- data/lib/sitefuel/extensions/SymbolComparison.rb +13 -0
- data/lib/sitefuel/external/AbstractExternalProgram.rb +616 -0
- data/lib/sitefuel/external/ExternalProgramTestCase.rb +67 -0
- data/lib/sitefuel/external/GIT.rb +9 -0
- data/lib/sitefuel/external/JPEGTran.rb +68 -0
- data/lib/sitefuel/external/PNGCrush.rb +66 -0
- data/lib/sitefuel/processors/AbstractExternalProgramProcessor.rb +72 -0
- data/lib/sitefuel/processors/AbstractProcessor.rb +378 -0
- data/lib/sitefuel/processors/AbstractStringBasedProcessor.rb +88 -0
- data/lib/sitefuel/processors/CSSProcessor.rb +84 -0
- data/lib/sitefuel/processors/HAMLProcessor.rb +52 -0
- data/lib/sitefuel/processors/HTMLProcessor.rb +211 -0
- data/lib/sitefuel/processors/JavaScriptProcessor.rb +57 -0
- data/lib/sitefuel/processors/PHPProcessor.rb +32 -0
- data/lib/sitefuel/processors/PNGProcessor.rb +80 -0
- data/lib/sitefuel/processors/RHTMLProcessor.rb +25 -0
- data/lib/sitefuel/processors/SASSProcessor.rb +50 -0
- data/test/processor_listing.rb +28 -0
- data/test/test_AbstractExternalProgram.rb +186 -0
- data/test/test_AbstractProcessor.rb +237 -0
- data/test/test_AbstractStringBasedProcessor.rb +48 -0
- data/test/test_AllProcessors.rb +65 -0
- data/test/test_ArrayComparisons.rb +32 -0
- data/test/test_CSSProcessor.rb +120 -0
- data/test/test_FileComparisons.rb +42 -0
- data/test/test_HAMLProcessor.rb.rb +60 -0
- data/test/test_HTMLProcessor.rb +186 -0
- data/test/test_JPEGTran.rb +40 -0
- data/test/test_JavaScriptProcessor.rb +63 -0
- data/test/test_PHPProcessor.rb +51 -0
- data/test/test_PNGCrush.rb +58 -0
- data/test/test_PNGProcessor.rb +32 -0
- data/test/test_RHTMLProcessor.rb +62 -0
- data/test/test_SASSProcessor.rb +68 -0
- data/test/test_SiteFuelLogging.rb +79 -0
- data/test/test_SiteFuelRuntime.rb +96 -0
- data/test/test_StringFormatting.rb +51 -0
- data/test/test_SymbolComparison.rb +27 -0
- data/test/test_images/sample_jpg01.jpg +0 -0
- data/test/test_images/sample_png01.png +0 -0
- data/test/test_programs/versioning.rb +26 -0
- data/test/test_sites/simplehtml/deployment.yml +22 -0
- data/test/test_sites/simplehtml/index.html +66 -0
- data/test/test_sites/simplehtml/style.css +40 -0
- data/test/ts_all.rb +39 -0
- metadata +165 -0
@@ -0,0 +1,42 @@
|
|
1
|
+
#
|
2
|
+
# File:: test_FileComparisons.rb
|
3
|
+
# Author:: wkm
|
4
|
+
# Copyright:: 2009
|
5
|
+
# License:: GPL
|
6
|
+
#
|
7
|
+
# Unit tests for File.equivalent? class method. The method is
|
8
|
+
# heuristic based so lots of tests are needed, although perhaps
|
9
|
+
# this is a little excessive.
|
10
|
+
#
|
11
|
+
|
12
|
+
$:.unshift File.join(File.dirname(__FILE__),'..','lib')
|
13
|
+
|
14
|
+
require 'test/unit'
|
15
|
+
require 'sitefuel/extensions/FileComparison'
|
16
|
+
|
17
|
+
class TestFileComparion < Test::Unit::TestCase
|
18
|
+
def test_equivalent
|
19
|
+
|
20
|
+
# files which are clearly not equivalent
|
21
|
+
assert !File.equivalent?('a.rb', 'b.rb')
|
22
|
+
assert !File.equivalent?('f/a.rb', 'f/b.rb')
|
23
|
+
assert !File.equivalent?('b/a.rb', 'c/a.rb')
|
24
|
+
assert !File.equivalent?('c/b/a.rb', 'c/a.rb')
|
25
|
+
|
26
|
+
# files which are potentially equivalent
|
27
|
+
assert File.equivalent?('b/a.rb', 'a.rb')
|
28
|
+
assert File.equivalent?('./a.rb', 'b/a.rb')
|
29
|
+
assert File.equivalent?('b/a.rb', 'b/a.rb')
|
30
|
+
assert File.equivalent?('../a.rb', './a.rb')
|
31
|
+
assert File.equivalent?('../../../.././../a.rb', 'a.rb')
|
32
|
+
|
33
|
+
# trivial, but incorrect, variations on the potentially
|
34
|
+
# equivalent files above
|
35
|
+
assert !File.equivalent?('./a.rb', 'b/c.rb')
|
36
|
+
assert !File.equivalent?('b/a.rb', 'c/a.rb')
|
37
|
+
assert !File.equivalent?('b/a.rb', 'b/c.rb')
|
38
|
+
assert !File.equivalent?('../a.rb', './b.rb')
|
39
|
+
assert !File.equivalent?('../../../.././../a.rb', 'b.rb')
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
#
|
2
|
+
# File:: test_HAMLProcessor.rb
|
3
|
+
# Author:: wkm
|
4
|
+
# Copyright:: 2009
|
5
|
+
# License:: GPL
|
6
|
+
#
|
7
|
+
# Unit tests for the HAMLProcessor
|
8
|
+
#
|
9
|
+
|
10
|
+
$:.unshift File.join(File.dirname(__FILE__),'..','lib')
|
11
|
+
|
12
|
+
require 'test/unit'
|
13
|
+
require 'sitefuel/extensions/StringFormatting'
|
14
|
+
require 'sitefuel/processors/HAMLProcessor'
|
15
|
+
|
16
|
+
include SiteFuel::Processor
|
17
|
+
|
18
|
+
class TestHAMLProcessor < Test::Unit::TestCase
|
19
|
+
def test_file_extensions
|
20
|
+
|
21
|
+
# negative tests
|
22
|
+
assert_equal false, HAMLProcessor.processes_file?("testhaml")
|
23
|
+
|
24
|
+
# positive tests
|
25
|
+
assert HAMLProcessor.processes_file?("test.haml")
|
26
|
+
assert HAMLProcessor.processes_file?("test.HAML")
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_name
|
31
|
+
assert_equal "HAML", HAMLProcessor.processor_name
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_generate
|
35
|
+
assert_equal(
|
36
|
+
"<strong class='code' id='message'>Hello, World!</strong>",
|
37
|
+
|
38
|
+
HAMLProcessor.filter_string(:generate,
|
39
|
+
%q{
|
40
|
+
%strong{:class => "code", :id => "message"} Hello, World!
|
41
|
+
}.align
|
42
|
+
).strip
|
43
|
+
)
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_minify
|
47
|
+
assert_equal(
|
48
|
+
"<quote><p><strong class=\"code\" id=\"message\">Hello, World!</strong></p></quote>",
|
49
|
+
|
50
|
+
HAMLProcessor.filter_string([:generate, :minify],
|
51
|
+
%q{
|
52
|
+
%quote
|
53
|
+
%p
|
54
|
+
%strong{:class => "code", :id => "message"} Hello, World!
|
55
|
+
}.align
|
56
|
+
).strip
|
57
|
+
)
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
@@ -0,0 +1,186 @@
|
|
1
|
+
#
|
2
|
+
# File:: test_HTMLProcessor.rb
|
3
|
+
# Author:: wkm
|
4
|
+
# Copyright:: 2009
|
5
|
+
# License:: GPL
|
6
|
+
#
|
7
|
+
# Unit tests for the HTMLProcessor
|
8
|
+
#
|
9
|
+
|
10
|
+
$:.unshift File.join(File.dirname(__FILE__),'..','lib')
|
11
|
+
|
12
|
+
require 'test/unit'
|
13
|
+
require 'sitefuel/processors/HTMLProcessor'
|
14
|
+
require 'sitefuel/extensions/StringFormatting'
|
15
|
+
|
16
|
+
include SiteFuel::Processor
|
17
|
+
|
18
|
+
class TestHTMLProcessor < Test::Unit::TestCase
|
19
|
+
def test_file_extensions
|
20
|
+
|
21
|
+
# negative tests
|
22
|
+
assert_equal false, HTMLProcessor.processes_file?("testhtml")
|
23
|
+
assert_equal false, HTMLProcessor.processes_file?("testhtm")
|
24
|
+
assert_equal false, HTMLProcessor.processes_file?("testHTML")
|
25
|
+
|
26
|
+
assert_equal false, HTMLProcessor.processes_file?("test.html.foo")
|
27
|
+
assert_equal false, HTMLProcessor.processes_file?("test.htm.foo")
|
28
|
+
|
29
|
+
# positive tests
|
30
|
+
assert HTMLProcessor.processes_file?("test.html")
|
31
|
+
assert HTMLProcessor.processes_file?("test.htm")
|
32
|
+
assert HTMLProcessor.processes_file?("test.HTML")
|
33
|
+
assert HTMLProcessor.processes_file?("test.HtMl")
|
34
|
+
assert HTMLProcessor.processes_file?("test.hTm")
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_name
|
39
|
+
assert_equal "HTML", HTMLProcessor.processor_name
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_beautify_quotes
|
43
|
+
assert_equal(
|
44
|
+
%q{<p>“Really?” Alice asked.<br>“Yes. Just yesterday.” said Bob.</p>},
|
45
|
+
|
46
|
+
HTMLProcessor.filter_string(
|
47
|
+
:beautify_quotes,
|
48
|
+
%q{<p>"Really?" Alice asked.<br>"Yes. Just yesterday." said Bob.}
|
49
|
+
)
|
50
|
+
)
|
51
|
+
|
52
|
+
assert_equal(
|
53
|
+
%q{<p>This was Alice’s car; she bought it from the Hoovers.</p>},
|
54
|
+
|
55
|
+
HTMLProcessor.filter_string(
|
56
|
+
:beautify_quotes,
|
57
|
+
%q{<p>This was Alice's car; she bought it from the Hoovers.</p>}
|
58
|
+
)
|
59
|
+
)
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_beautify_dashes
|
63
|
+
assert_equal(
|
64
|
+
%q{<p>Alice—having just finished—shouted</p>},
|
65
|
+
|
66
|
+
HTMLProcessor.filter_string(
|
67
|
+
:beautify_dashes,
|
68
|
+
%q{<p>Alice---having just finished---shouted</p>}
|
69
|
+
)
|
70
|
+
)
|
71
|
+
|
72
|
+
assert_equal(
|
73
|
+
%q{<p>See ppg. 12–15</p>},
|
74
|
+
|
75
|
+
HTMLProcessor.filter_string(
|
76
|
+
:beautify_dashes,
|
77
|
+
%q{<p>See ppg. 12--15</p>}
|
78
|
+
)
|
79
|
+
)
|
80
|
+
|
81
|
+
assert_equal(
|
82
|
+
%q{<p>These--are left alone</p>},
|
83
|
+
|
84
|
+
HTMLProcessor.filter_string(
|
85
|
+
:beautify_dashes,
|
86
|
+
%q{<p>These--are left alone</p>}
|
87
|
+
)
|
88
|
+
)
|
89
|
+
|
90
|
+
# test --'s use as a filler for "bad words"
|
91
|
+
assert_equal(
|
92
|
+
%q{<p>f––</p>},
|
93
|
+
|
94
|
+
HTMLProcessor.filter_string(
|
95
|
+
:beautify_dashes,
|
96
|
+
%q{<p>f----</p>}
|
97
|
+
)
|
98
|
+
)
|
99
|
+
end
|
100
|
+
|
101
|
+
def test_beautify_arrows
|
102
|
+
assert_equal(
|
103
|
+
%q{<p>a → b ← c ↔ d</p>},
|
104
|
+
|
105
|
+
HTMLProcessor.filter_string(
|
106
|
+
:beautify_arrows,
|
107
|
+
%q{<p>a --> b <-- c <-> d</p>}
|
108
|
+
)
|
109
|
+
)
|
110
|
+
|
111
|
+
assert_equal(
|
112
|
+
%q{<p>a ⇒ b ⇐ c ⇔ d</p>},
|
113
|
+
|
114
|
+
HTMLProcessor.filter_string(
|
115
|
+
:beautify_arrows,
|
116
|
+
%q{<p>a ==> b <== c <=> d</p>}
|
117
|
+
)
|
118
|
+
)
|
119
|
+
end
|
120
|
+
|
121
|
+
def test_beautify_symbols
|
122
|
+
assert_equal %q{<p>™</p>}, HTMLProcessor.filter_string(:beautify_symbols, %q{<p>(tm)</p>})
|
123
|
+
assert_equal %q{<p>©</p>}, HTMLProcessor.filter_string(:beautify_symbols, %q{<p>(c)</p>})
|
124
|
+
assert_equal %q{<p>®</p>}, HTMLProcessor.filter_string(:beautify_symbols, %q{<p>(r)</p>})
|
125
|
+
|
126
|
+
assert_equal(
|
127
|
+
%q{<p>Hello… Hi… And finally … that was it.</p>},
|
128
|
+
|
129
|
+
HTMLProcessor.filter_string(
|
130
|
+
:beautify_symbols,
|
131
|
+
%q{<p>Hello... Hi... And finally ... that was it.</p>}
|
132
|
+
)
|
133
|
+
)
|
134
|
+
end
|
135
|
+
|
136
|
+
def test_traverse
|
137
|
+
|
138
|
+
modifiable_tags = %w{h1 h2 h3 h4 h5 h6 p b i ul a li td th}
|
139
|
+
unmodifiable_tags = %w{pre code html head}
|
140
|
+
|
141
|
+
# test tags which should be modified
|
142
|
+
modifiable_tags.each do |tag|
|
143
|
+
assert_equal "<#{tag}>™</#{tag}>", HTMLProcessor.filter_string(:beautify_symbols, "<#{tag}>(tm)</#{tag}>")
|
144
|
+
end
|
145
|
+
|
146
|
+
|
147
|
+
# test tags which should be unmodified
|
148
|
+
unmodifiable_tags.each do |tag|
|
149
|
+
assert_equal "<#{tag}>(tm)</#{tag}>", HTMLProcessor.filter_string(:beautify_symbols, "<#{tag}>(tm)</#{tag}>")
|
150
|
+
end
|
151
|
+
|
152
|
+
end
|
153
|
+
|
154
|
+
def test_embedded_css
|
155
|
+
|
156
|
+
assert_equal(
|
157
|
+
%q{<style>body{font-family:"lucida grande",sans-serif;}</style>},
|
158
|
+
HTMLProcessor.filter_string(:minify_styles,
|
159
|
+
<<-END
|
160
|
+
<style>
|
161
|
+
body {
|
162
|
+
font-family: "lucida grande", sans-serif;
|
163
|
+
}
|
164
|
+
</style>
|
165
|
+
END
|
166
|
+
).strip
|
167
|
+
)
|
168
|
+
|
169
|
+
end
|
170
|
+
|
171
|
+
def test_embedded_javascript
|
172
|
+
assert_equal(
|
173
|
+
"<script>var protocol=document.location.protocol\ndocument.write(\"Web protocol used: \"+protocol)</script>",
|
174
|
+
|
175
|
+
HTMLProcessor.filter_string(:minify_javascript,
|
176
|
+
%q{
|
177
|
+
<script>
|
178
|
+
// some random java script invented by seriously fudging the
|
179
|
+
// google analytics includes
|
180
|
+
var protocol = document.location.protocol
|
181
|
+
document.write("Web protocol used: "+protocol)
|
182
|
+
}.align
|
183
|
+
).strip
|
184
|
+
)
|
185
|
+
end
|
186
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
#
|
2
|
+
# File:: test_JPEGTran.rb
|
3
|
+
# Author:: wkm
|
4
|
+
# Copyright:: 2009
|
5
|
+
# License:: GPL
|
6
|
+
#
|
7
|
+
# Unit tests for the JPEGTran wrapper.
|
8
|
+
#
|
9
|
+
|
10
|
+
$:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
|
11
|
+
|
12
|
+
require 'sitefuel/external/ExternalProgramTestCase'
|
13
|
+
require 'sitefuel/external/JPEGTran'
|
14
|
+
|
15
|
+
include SiteFuel::External
|
16
|
+
|
17
|
+
class TestJPEGTran < Test::Unit::TestCase
|
18
|
+
include ExternalProgramTestCase
|
19
|
+
|
20
|
+
SAMPLE_IMAGE = 'test/test_images/sample_jpg01.jpg'
|
21
|
+
|
22
|
+
def test_options
|
23
|
+
assert JPEGTran.option?(:version)
|
24
|
+
assert JPEGTran.option?(:copy)
|
25
|
+
assert JPEGTran.option?(:optimize)
|
26
|
+
assert JPEGTran.option?(:perfect)
|
27
|
+
assert JPEGTran.option?(:input)
|
28
|
+
assert JPEGTran.option?(:output)
|
29
|
+
|
30
|
+
assert_equal '-optimize', JPEGTran.option_template(:optimize)
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_lossless
|
34
|
+
new_image = 'test/test_images/tmp-sample_jpg01-lossless.jpg'
|
35
|
+
JPEGTran.compress_losslessly SAMPLE_IMAGE, new_image
|
36
|
+
|
37
|
+
|
38
|
+
assert File.size(SAMPLE_IMAGE) > File.size(new_image)
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
#
|
2
|
+
# File:: test_JavaScriptProcessor.rb
|
3
|
+
# Copyright:: 2009
|
4
|
+
# License:: GPL
|
5
|
+
#
|
6
|
+
# Unit tests for the JavaScriptProcessor
|
7
|
+
#
|
8
|
+
|
9
|
+
$:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
|
10
|
+
|
11
|
+
require 'test/unit'
|
12
|
+
require 'sitefuel/processors/JavaScriptProcessor'
|
13
|
+
|
14
|
+
include SiteFuel::Processor
|
15
|
+
|
16
|
+
class TestJavaScriptProcessor < Test::Unit::TestCase
|
17
|
+
|
18
|
+
def test_file_extensions
|
19
|
+
assert JavaScriptProcessor.processes_file?('foo.js')
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_name
|
23
|
+
assert_equal 'JS', JavaScriptProcessor.processor_name
|
24
|
+
end
|
25
|
+
|
26
|
+
# CDATA fields need to be left intact
|
27
|
+
def test_cdata
|
28
|
+
assert_equal(
|
29
|
+
"//<![CDATA[\nfunction foo(){12}\n//]]>",
|
30
|
+
|
31
|
+
JavaScriptProcessor.filter_string(:minify,
|
32
|
+
%q{
|
33
|
+
//<![CDATA[
|
34
|
+
function foo() {
|
35
|
+
12
|
36
|
+
}
|
37
|
+
//]]>
|
38
|
+
}
|
39
|
+
)
|
40
|
+
)
|
41
|
+
end
|
42
|
+
|
43
|
+
# test comment-only javascripts
|
44
|
+
def test_comments_only
|
45
|
+
assert_equal(
|
46
|
+
'',
|
47
|
+
JavaScriptProcessor.filter_string(:minify,
|
48
|
+
%q{
|
49
|
+
// just a comment....
|
50
|
+
}
|
51
|
+
)
|
52
|
+
)
|
53
|
+
|
54
|
+
assert_equal(
|
55
|
+
'',
|
56
|
+
JavaScriptProcessor.filter_string(:minify,
|
57
|
+
%q{//just a comment...}
|
58
|
+
)
|
59
|
+
)
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
|
@@ -0,0 +1,51 @@
|
|
1
|
+
#
|
2
|
+
# File:: test_PHPProcessor.rb
|
3
|
+
# Author:: wkm
|
4
|
+
# Copyright:: 2009
|
5
|
+
# License:: GPL
|
6
|
+
#
|
7
|
+
# Unit tests for the PHPProcessor
|
8
|
+
#
|
9
|
+
|
10
|
+
$:.unshift File.join(File.dirname(__FILE__),'..','lib')
|
11
|
+
|
12
|
+
require 'test/unit'
|
13
|
+
require 'sitefuel/processors/PHPProcessor'
|
14
|
+
|
15
|
+
include SiteFuel::Processor
|
16
|
+
|
17
|
+
class TestPHPProcessor < Test::Unit::TestCase
|
18
|
+
|
19
|
+
def test_file_extensions
|
20
|
+
assert PHPProcessor.processes_file?('test.php')
|
21
|
+
assert PHPProcessor.processes_file?('test.php5')
|
22
|
+
assert PHPProcessor.processes_file?('test.phtml')
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_name
|
26
|
+
assert_equal 'PHP', PHPProcessor.processor_name
|
27
|
+
end
|
28
|
+
|
29
|
+
# test support for PHP documents
|
30
|
+
def test_php
|
31
|
+
assert_equal(
|
32
|
+
"<html><head><title>PHP test</title></head><body><?php echo '<?>Hello World' ?> <p>Some filler text.</p> <? echo 'some more php! Weeee' ?> </body></html>",
|
33
|
+
|
34
|
+
PHPProcessor.filter_string(:whitespace,
|
35
|
+
%q{
|
36
|
+
<html>
|
37
|
+
<head>
|
38
|
+
<title>PHP test</title>
|
39
|
+
</head>
|
40
|
+
<body>
|
41
|
+
<?php echo '<p>Hello World</p>' ?>
|
42
|
+
<p>Some filler text.</p>
|
43
|
+
<? echo 'some more php! Weeee' ?>
|
44
|
+
</body>
|
45
|
+
</html>
|
46
|
+
}
|
47
|
+
)
|
48
|
+
)
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
#
|
2
|
+
# File:: test_PNGCrush.m
|
3
|
+
# Author:: wkm
|
4
|
+
# Copyright:: 2009
|
5
|
+
# License:: GPL
|
6
|
+
#
|
7
|
+
# Unit tests for the PNGCrush wrapper.
|
8
|
+
#
|
9
|
+
|
10
|
+
$:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
|
11
|
+
|
12
|
+
require 'sitefuel/external/ExternalProgramTestCase'
|
13
|
+
require 'sitefuel/external/PNGCrush'
|
14
|
+
|
15
|
+
include SiteFuel::External
|
16
|
+
|
17
|
+
class TestPNGCrush < Test::Unit::TestCase
|
18
|
+
include ExternalProgramTestCase
|
19
|
+
|
20
|
+
SAMPLE_IMAGE = 'test/test_images/sample_png01.png'
|
21
|
+
|
22
|
+
def test_option
|
23
|
+
# test that we have all options
|
24
|
+
assert PNGCrush.option?(:version)
|
25
|
+
assert PNGCrush.option?(:brute)
|
26
|
+
assert PNGCrush.option?(:reduce)
|
27
|
+
assert PNGCrush.option?(:method)
|
28
|
+
assert PNGCrush.option?(:input)
|
29
|
+
assert PNGCrush.option?(:output)
|
30
|
+
|
31
|
+
assert_equal '-brute', PNGCrush.option_template(:brute)
|
32
|
+
# assert_equal '-version', PNGCrush.option_template(:version)
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_brute
|
36
|
+
# test the crush capability against one of the test files
|
37
|
+
new_image = './test/test_images/tmp-sample_png01-brute.png'
|
38
|
+
PNGCrush.brute SAMPLE_IMAGE, new_image
|
39
|
+
|
40
|
+
assert File.size(SAMPLE_IMAGE) > File.size(new_image)
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_quick
|
45
|
+
new_image = './test/test_images/tmp-sample_png01-quick.png'
|
46
|
+
PNGCrush.quick SAMPLE_IMAGE, new_image
|
47
|
+
|
48
|
+
assert File.size(SAMPLE_IMAGE) > File.size(new_image)
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_chainsaw
|
52
|
+
new_image = './test/test_images/tmp-sample_png01-chainsaw.png'
|
53
|
+
PNGCrush.chainsaw SAMPLE_IMAGE, new_image
|
54
|
+
|
55
|
+
assert File.size(SAMPLE_IMAGE) > File.size(new_image)
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
#
|
2
|
+
# File:: test_PNGProcessor.rb
|
3
|
+
# Author:: wkm
|
4
|
+
# Copyright:: 2009
|
5
|
+
# License:: GPL
|
6
|
+
#
|
7
|
+
# Unit tests for the PNGProcessor
|
8
|
+
#
|
9
|
+
|
10
|
+
$:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
|
11
|
+
|
12
|
+
require 'test/unit'
|
13
|
+
require 'sitefuel/processors/PNGProcessor'
|
14
|
+
|
15
|
+
include SiteFuel::Processor
|
16
|
+
|
17
|
+
class TestPNGProcessor < Test::Unit::TestCase
|
18
|
+
def test_file_extensions
|
19
|
+
assert_equal false, PNGProcessor.processes_file?("testpng")
|
20
|
+
|
21
|
+
assert PNGProcessor.processes_file?("test.png")
|
22
|
+
assert PNGProcessor.processes_file?("test.PNG")
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_name
|
26
|
+
assert_equal 'PNG', PNGProcessor.processor_name
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_crush
|
30
|
+
PNGProcessor.process_file('test/test_images/sample_png01.png')
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
#
|
2
|
+
# File:: test_RHTMLProcessor.rb
|
3
|
+
# Author:: wkm
|
4
|
+
# Copyright:: 2009
|
5
|
+
# License:: GPL
|
6
|
+
#
|
7
|
+
# Unit tests for the RHTMLProcessor
|
8
|
+
#
|
9
|
+
|
10
|
+
$:.unshift File.join(File.dirname(__FILE__),'..','lib')
|
11
|
+
|
12
|
+
require 'test/unit'
|
13
|
+
require 'sitefuel/processors/RHTMLProcessor'
|
14
|
+
|
15
|
+
include SiteFuel::Processor
|
16
|
+
|
17
|
+
class TestRHTMLProcessor < Test::Unit::TestCase
|
18
|
+
|
19
|
+
def test_file_extensions
|
20
|
+
assert RHTMLProcessor.processes_file?('test.rhtml')
|
21
|
+
assert RHTMLProcessor.processes_file?('test.erb')
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_name
|
25
|
+
assert_equal 'RHTML', RHTMLProcessor.processor_name
|
26
|
+
end
|
27
|
+
|
28
|
+
# test support for RHTML documents (really testing hpricot here)
|
29
|
+
def test_rhtml
|
30
|
+
assert_equal(
|
31
|
+
"<html><head><title>Goodbye, World.</title></head><body><h1>Goodbye!</h1> <% 5.times do || %> <p>and again...</p> <% end %> </body></html>",
|
32
|
+
RHTMLProcessor.filter_string(:whitespace,
|
33
|
+
%q{
|
34
|
+
<html>
|
35
|
+
<head>
|
36
|
+
<title>Goodbye, World.</title>
|
37
|
+
</head>
|
38
|
+
<body>
|
39
|
+
<h1>Goodbye!</h1>
|
40
|
+
<% 5.times do || %>
|
41
|
+
<p>and again...</p>
|
42
|
+
<% end %>
|
43
|
+
</body>
|
44
|
+
</html>
|
45
|
+
}
|
46
|
+
)
|
47
|
+
)
|
48
|
+
|
49
|
+
assert_equal(
|
50
|
+
"<html> <%= page.title %> </html>",
|
51
|
+
|
52
|
+
RHTMLProcessor.filter_string(:whitespace,
|
53
|
+
%q{
|
54
|
+
<html>
|
55
|
+
<%= page.title %>
|
56
|
+
</html>
|
57
|
+
}
|
58
|
+
)
|
59
|
+
)
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
#
|
2
|
+
# File:: test_SASSProcessor.rb
|
3
|
+
# Author:: wkm
|
4
|
+
# Copyright:: 2009
|
5
|
+
# License:: GPL
|
6
|
+
#
|
7
|
+
# Unit tests for the SASSProcessor
|
8
|
+
#
|
9
|
+
|
10
|
+
$:.unshift File.join(File.dirname(__FILE__),'..','lib')
|
11
|
+
|
12
|
+
require 'test/unit'
|
13
|
+
require 'sitefuel/extensions/StringFormatting'
|
14
|
+
require 'sitefuel/processors/SASSProcessor'
|
15
|
+
|
16
|
+
include SiteFuel::Processor
|
17
|
+
|
18
|
+
class TestSASSProcessor < Test::Unit::TestCase
|
19
|
+
def test_file_extensions
|
20
|
+
|
21
|
+
# negative tests
|
22
|
+
assert_equal false, SASSProcessor.processes_file?("testsass")
|
23
|
+
|
24
|
+
# positive tests
|
25
|
+
assert SASSProcessor.processes_file?("test.sass")
|
26
|
+
assert SASSProcessor.processes_file?("test.SASS")
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_name
|
31
|
+
assert_equal "SASS", SASSProcessor.processor_name
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_generate
|
35
|
+
assert_equal(
|
36
|
+
%q{
|
37
|
+
#main {
|
38
|
+
background-color: #ff0000;
|
39
|
+
width: 98%; }
|
40
|
+
}.align.strip,
|
41
|
+
|
42
|
+
SASSProcessor.filter_string(:generate,
|
43
|
+
%q{
|
44
|
+
// from the SASS documentation
|
45
|
+
#main
|
46
|
+
background-color: #ff0000
|
47
|
+
width: 98%
|
48
|
+
}.align
|
49
|
+
).strip
|
50
|
+
)
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_minify
|
54
|
+
assert_equal(
|
55
|
+
"#main{background-color:#f00;width:98%;}",
|
56
|
+
|
57
|
+
SASSProcessor.filter_string([:generate, :minify],
|
58
|
+
%q{
|
59
|
+
// from the SASS documentation
|
60
|
+
#main
|
61
|
+
background-color: #ff0000
|
62
|
+
width: 98%
|
63
|
+
}.align
|
64
|
+
).strip
|
65
|
+
)
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|