jwhitmire-haml 2.1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (168) hide show
  1. data/README.rdoc +332 -0
  2. data/bin/css2sass +7 -0
  3. data/bin/haml +9 -0
  4. data/bin/html2haml +7 -0
  5. data/bin/sass +8 -0
  6. data/lib/haml/buffer.rb +255 -0
  7. data/lib/haml/engine.rb +268 -0
  8. data/lib/haml/error.rb +22 -0
  9. data/lib/haml/exec.rb +395 -0
  10. data/lib/haml/filters.rb +276 -0
  11. data/lib/haml/helpers/action_view_extensions.rb +45 -0
  12. data/lib/haml/helpers/action_view_mods.rb +181 -0
  13. data/lib/haml/helpers.rb +468 -0
  14. data/lib/haml/html.rb +218 -0
  15. data/lib/haml/precompiler.rb +889 -0
  16. data/lib/haml/shared.rb +45 -0
  17. data/lib/haml/template/patch.rb +58 -0
  18. data/lib/haml/template/plugin.rb +72 -0
  19. data/lib/haml/template.rb +51 -0
  20. data/lib/haml/util.rb +77 -0
  21. data/lib/haml/version.rb +47 -0
  22. data/lib/haml.rb +1042 -0
  23. data/lib/sass/css.rb +388 -0
  24. data/lib/sass/engine.rb +499 -0
  25. data/lib/sass/environment.rb +33 -0
  26. data/lib/sass/error.rb +35 -0
  27. data/lib/sass/plugin/merb.rb +56 -0
  28. data/lib/sass/plugin/rails.rb +24 -0
  29. data/lib/sass/plugin.rb +203 -0
  30. data/lib/sass/repl.rb +51 -0
  31. data/lib/sass/script/bool.rb +13 -0
  32. data/lib/sass/script/color.rb +97 -0
  33. data/lib/sass/script/funcall.rb +28 -0
  34. data/lib/sass/script/functions.rb +122 -0
  35. data/lib/sass/script/lexer.rb +152 -0
  36. data/lib/sass/script/literal.rb +60 -0
  37. data/lib/sass/script/number.rb +231 -0
  38. data/lib/sass/script/operation.rb +30 -0
  39. data/lib/sass/script/parser.rb +142 -0
  40. data/lib/sass/script/string.rb +42 -0
  41. data/lib/sass/script/unary_operation.rb +21 -0
  42. data/lib/sass/script/variable.rb +20 -0
  43. data/lib/sass/script.rb +38 -0
  44. data/lib/sass/tree/attr_node.rb +64 -0
  45. data/lib/sass/tree/comment_node.rb +34 -0
  46. data/lib/sass/tree/debug_node.rb +22 -0
  47. data/lib/sass/tree/directive_node.rb +50 -0
  48. data/lib/sass/tree/file_node.rb +27 -0
  49. data/lib/sass/tree/for_node.rb +29 -0
  50. data/lib/sass/tree/if_node.rb +27 -0
  51. data/lib/sass/tree/mixin_def_node.rb +18 -0
  52. data/lib/sass/tree/mixin_node.rb +34 -0
  53. data/lib/sass/tree/node.rb +99 -0
  54. data/lib/sass/tree/rule_node.rb +120 -0
  55. data/lib/sass/tree/variable_node.rb +24 -0
  56. data/lib/sass/tree/while_node.rb +20 -0
  57. data/lib/sass.rb +1062 -0
  58. data/test/benchmark.rb +99 -0
  59. data/test/haml/engine_test.rb +734 -0
  60. data/test/haml/helper_test.rb +224 -0
  61. data/test/haml/html2haml_test.rb +92 -0
  62. data/test/haml/markaby/standard.mab +52 -0
  63. data/test/haml/mocks/article.rb +6 -0
  64. data/test/haml/results/content_for_layout.xhtml +15 -0
  65. data/test/haml/results/eval_suppressed.xhtml +9 -0
  66. data/test/haml/results/filters.xhtml +62 -0
  67. data/test/haml/results/helpers.xhtml +93 -0
  68. data/test/haml/results/helpful.xhtml +10 -0
  69. data/test/haml/results/just_stuff.xhtml +68 -0
  70. data/test/haml/results/list.xhtml +12 -0
  71. data/test/haml/results/nuke_inner_whitespace.xhtml +40 -0
  72. data/test/haml/results/nuke_outer_whitespace.xhtml +148 -0
  73. data/test/haml/results/original_engine.xhtml +20 -0
  74. data/test/haml/results/partial_layout.xhtml +5 -0
  75. data/test/haml/results/partials.xhtml +21 -0
  76. data/test/haml/results/render_layout.xhtml +3 -0
  77. data/test/haml/results/silent_script.xhtml +74 -0
  78. data/test/haml/results/standard.xhtml +42 -0
  79. data/test/haml/results/tag_parsing.xhtml +23 -0
  80. data/test/haml/results/very_basic.xhtml +5 -0
  81. data/test/haml/results/whitespace_handling.xhtml +89 -0
  82. data/test/haml/rhtml/_av_partial_1.rhtml +12 -0
  83. data/test/haml/rhtml/_av_partial_2.rhtml +8 -0
  84. data/test/haml/rhtml/action_view.rhtml +62 -0
  85. data/test/haml/rhtml/standard.rhtml +54 -0
  86. data/test/haml/template_test.rb +204 -0
  87. data/test/haml/templates/_av_partial_1.haml +9 -0
  88. data/test/haml/templates/_av_partial_1_ugly.haml +9 -0
  89. data/test/haml/templates/_av_partial_2.haml +5 -0
  90. data/test/haml/templates/_av_partial_2_ugly.haml +5 -0
  91. data/test/haml/templates/_layout.erb +3 -0
  92. data/test/haml/templates/_layout_for_partial.haml +3 -0
  93. data/test/haml/templates/_partial.haml +8 -0
  94. data/test/haml/templates/_text_area.haml +3 -0
  95. data/test/haml/templates/action_view.haml +47 -0
  96. data/test/haml/templates/action_view_ugly.haml +47 -0
  97. data/test/haml/templates/breakage.haml +8 -0
  98. data/test/haml/templates/content_for_layout.haml +10 -0
  99. data/test/haml/templates/eval_suppressed.haml +11 -0
  100. data/test/haml/templates/filters.haml +66 -0
  101. data/test/haml/templates/helpers.haml +95 -0
  102. data/test/haml/templates/helpful.haml +11 -0
  103. data/test/haml/templates/just_stuff.haml +83 -0
  104. data/test/haml/templates/list.haml +12 -0
  105. data/test/haml/templates/nuke_inner_whitespace.haml +32 -0
  106. data/test/haml/templates/nuke_outer_whitespace.haml +144 -0
  107. data/test/haml/templates/original_engine.haml +17 -0
  108. data/test/haml/templates/partial_layout.haml +3 -0
  109. data/test/haml/templates/partialize.haml +1 -0
  110. data/test/haml/templates/partials.haml +12 -0
  111. data/test/haml/templates/render_layout.haml +2 -0
  112. data/test/haml/templates/silent_script.haml +40 -0
  113. data/test/haml/templates/standard.haml +42 -0
  114. data/test/haml/templates/standard_ugly.haml +1 -0
  115. data/test/haml/templates/tag_parsing.haml +21 -0
  116. data/test/haml/templates/very_basic.haml +4 -0
  117. data/test/haml/templates/whitespace_handling.haml +87 -0
  118. data/test/linked_rails.rb +12 -0
  119. data/test/sass/css2sass_test.rb +193 -0
  120. data/test/sass/engine_test.rb +786 -0
  121. data/test/sass/functions_test.rb +96 -0
  122. data/test/sass/more_results/more1.css +9 -0
  123. data/test/sass/more_results/more1_with_line_comments.css +26 -0
  124. data/test/sass/more_results/more_import.css +29 -0
  125. data/test/sass/more_templates/_more_partial.sass +2 -0
  126. data/test/sass/more_templates/more1.sass +23 -0
  127. data/test/sass/more_templates/more_import.sass +11 -0
  128. data/test/sass/plugin_test.rb +208 -0
  129. data/test/sass/results/alt.css +4 -0
  130. data/test/sass/results/basic.css +9 -0
  131. data/test/sass/results/compact.css +5 -0
  132. data/test/sass/results/complex.css +87 -0
  133. data/test/sass/results/compressed.css +1 -0
  134. data/test/sass/results/expanded.css +19 -0
  135. data/test/sass/results/import.css +29 -0
  136. data/test/sass/results/line_numbers.css +49 -0
  137. data/test/sass/results/mixins.css +95 -0
  138. data/test/sass/results/multiline.css +24 -0
  139. data/test/sass/results/nested.css +22 -0
  140. data/test/sass/results/parent_ref.css +13 -0
  141. data/test/sass/results/script.css +16 -0
  142. data/test/sass/results/subdir/nested_subdir/nested_subdir.css +1 -0
  143. data/test/sass/results/subdir/subdir.css +3 -0
  144. data/test/sass/results/units.css +11 -0
  145. data/test/sass/script_test.rb +153 -0
  146. data/test/sass/templates/_partial.sass +2 -0
  147. data/test/sass/templates/alt.sass +16 -0
  148. data/test/sass/templates/basic.sass +23 -0
  149. data/test/sass/templates/bork.sass +2 -0
  150. data/test/sass/templates/bork2.sass +2 -0
  151. data/test/sass/templates/compact.sass +17 -0
  152. data/test/sass/templates/complex.sass +309 -0
  153. data/test/sass/templates/compressed.sass +15 -0
  154. data/test/sass/templates/expanded.sass +17 -0
  155. data/test/sass/templates/import.sass +11 -0
  156. data/test/sass/templates/importee.sass +19 -0
  157. data/test/sass/templates/line_numbers.sass +13 -0
  158. data/test/sass/templates/mixins.sass +76 -0
  159. data/test/sass/templates/multiline.sass +20 -0
  160. data/test/sass/templates/nested.sass +25 -0
  161. data/test/sass/templates/parent_ref.sass +25 -0
  162. data/test/sass/templates/script.sass +101 -0
  163. data/test/sass/templates/subdir/nested_subdir/_nested_partial.sass +2 -0
  164. data/test/sass/templates/subdir/nested_subdir/nested_subdir.sass +3 -0
  165. data/test/sass/templates/subdir/subdir.sass +6 -0
  166. data/test/sass/templates/units.sass +11 -0
  167. data/test/test_helper.rb +21 -0
  168. metadata +245 -0
@@ -0,0 +1,96 @@
1
+ require 'test/unit'
2
+ require File.dirname(__FILE__) + '/../../lib/sass'
3
+ require 'sass/script'
4
+
5
+ class SassFunctionTest < Test::Unit::TestCase
6
+ def test_hsl
7
+ # These tests adapted from the w3c browser tests
8
+ # http://www.w3.org/Style/CSS/Test/CSS3/Color/20070927/html4/t040204-hsl-h-rotating-b.htm
9
+ red = [255, 0, 0]
10
+ assert_rgb_hsl(red, ['0', '100%', '50%'])
11
+ assert_rgb_hsl(red, ['-360', '100%', '50%'])
12
+ assert_rgb_hsl(red, ['360', '100%', '50%'])
13
+ assert_rgb_hsl(red, ['6120', '100%', '50%'])
14
+
15
+ yellow = [255, 255, 0]
16
+ assert_rgb_hsl(yellow, ['60', '100%', '50%'])
17
+ assert_rgb_hsl(yellow, ['-300', '100%', '50%'])
18
+ assert_rgb_hsl(yellow, ['420', '100%', '50%'])
19
+ assert_rgb_hsl(yellow, ['-9660', '100%', '50%'])
20
+
21
+ green = [0, 255, 0]
22
+ assert_rgb_hsl(green, ['120', '100%', '50%'])
23
+ assert_rgb_hsl(green, ['-240', '100%', '50%'])
24
+ assert_rgb_hsl(green, ['480', '100%', '50%'])
25
+ assert_rgb_hsl(green, ['99840', '100%', '50%'])
26
+
27
+ cyan = [0, 255, 255]
28
+ assert_rgb_hsl(cyan, ['180', '100%', '50%'])
29
+ assert_rgb_hsl(cyan, ['-180', '100%', '50%'])
30
+ assert_rgb_hsl(cyan, ['540', '100%', '50%'])
31
+ assert_rgb_hsl(cyan, ['-900', '100%', '50%'])
32
+
33
+ blue = [0, 0, 255]
34
+ assert_rgb_hsl(blue, ['240', '100%', '50%'])
35
+ assert_rgb_hsl(blue, ['-120', '100%', '50%'])
36
+ assert_rgb_hsl(blue, ['600', '100%', '50%'])
37
+ assert_rgb_hsl(blue, ['-104880', '100%', '50%'])
38
+
39
+ purple = [255, 0, 255]
40
+ assert_rgb_hsl(purple, ['300', '100%', '50%'])
41
+ assert_rgb_hsl(purple, ['-60', '100%', '50%'])
42
+ assert_rgb_hsl(purple, ['660', '100%', '50%'])
43
+ assert_rgb_hsl(purple, ['2820', '100%', '50%'])
44
+ end
45
+
46
+ def test_hsl_checks_bounds
47
+ assert_error_message("Saturation -114 must be between 0% and 100% for `hsl'", "hsl(10, -114, 12)");
48
+ assert_error_message("Lightness 256 must be between 0% and 100% for `hsl'", "hsl(10, 10, 256%)");
49
+ end
50
+
51
+ def test_percentage
52
+ assert_equal("50%", evaluate("percentage(.5)"))
53
+ assert_equal("100%", evaluate("percentage(1)"))
54
+ assert_equal("25%", evaluate("percentage(25px / 100px)"))
55
+ assert_error_message("25px is not a unitless number for `percentage'", "percentage(25px)")
56
+ assert_error_message("#cccccc is not a unitless number for `percentage'", "percentage(#ccc)")
57
+ assert_error_message("string is not a unitless number for `percentage'", %Q{percentage("string")})
58
+ end
59
+
60
+ def test_numeric_transformations
61
+ assert_equal("5", evaluate("round(4.8)"))
62
+ assert_equal("5px", evaluate("round(4.8px)"))
63
+ assert_equal("5px", evaluate("round(5.49px)"))
64
+ assert_equal("4", evaluate("floor(4.8)"))
65
+ assert_equal("4px", evaluate("floor(4.8px)"))
66
+ assert_equal("5", evaluate("ceil(4.1)"))
67
+ assert_equal("5px", evaluate("ceil(4.8px)"))
68
+ assert_equal("5", evaluate("abs(-5)"))
69
+ assert_equal("5px", evaluate("abs(-5px)"))
70
+ assert_equal("5", evaluate("abs(5)"))
71
+ assert_equal("5px", evaluate("abs(5px)"))
72
+ assert_error_message("#cccccc is not a number for `round'", "round(#ccc)")
73
+ assert_error_message("foo is not a number for `floor'", "floor(\"foo\")")
74
+ assert_error_message("a is not a number for `ceil'", "ceil(\"a\")")
75
+ assert_error_message("#aaaaaa is not a number for `abs'", "abs(#aaa)")
76
+ end
77
+
78
+ private
79
+
80
+ def assert_rgb_hsl(rgb, hsl)
81
+ hsl = hsl.map {|v| Sass::Script::Parser.parse v, 0, 0 }
82
+ assert_equal(rgb, Sass::Script::Functions.hsl(*hsl).value)
83
+ end
84
+
85
+ def evaluate(value)
86
+ Sass::Script::Parser.parse(value, 0, 0).perform({}).to_s
87
+ end
88
+
89
+ def assert_error_message(message, value)
90
+ evaluate(value)
91
+ flunk("Error message expected but not raised: #{message}")
92
+ rescue Sass::SyntaxError => e
93
+ assert_equal(message, e.message)
94
+ end
95
+
96
+ end
@@ -0,0 +1,9 @@
1
+ body { font: Arial; background: blue; }
2
+
3
+ #page { width: 700px; height: 100; }
4
+ #page #header { height: 300px; }
5
+ #page #header h1 { font-size: 50px; color: blue; }
6
+
7
+ #content.user.show #container.top #column.left { width: 100px; }
8
+ #content.user.show #container.top #column.right { width: 600px; }
9
+ #content.user.show #container.bottom { background: brown; }
@@ -0,0 +1,26 @@
1
+ /* line 3, ../more_templates/more1.sass */
2
+ body {
3
+ font: Arial;
4
+ background: blue; }
5
+
6
+ /* line 7, ../more_templates/more1.sass */
7
+ #page {
8
+ width: 700px;
9
+ height: 100; }
10
+ /* line 10, ../more_templates/more1.sass */
11
+ #page #header {
12
+ height: 300px; }
13
+ /* line 12, ../more_templates/more1.sass */
14
+ #page #header h1 {
15
+ font-size: 50px;
16
+ color: blue; }
17
+
18
+ /* line 18, ../more_templates/more1.sass */
19
+ #content.user.show #container.top #column.left {
20
+ width: 100px; }
21
+ /* line 20, ../more_templates/more1.sass */
22
+ #content.user.show #container.top #column.right {
23
+ width: 600px; }
24
+ /* line 22, ../more_templates/more1.sass */
25
+ #content.user.show #container.bottom {
26
+ background: brown; }
@@ -0,0 +1,29 @@
1
+ imported { otherconst: hello; myconst: goodbye; pre-mixin: here; }
2
+
3
+ body { font: Arial; background: blue; }
4
+
5
+ #page { width: 700px; height: 100; }
6
+ #page #header { height: 300px; }
7
+ #page #header h1 { font-size: 50px; color: blue; }
8
+
9
+ #content.user.show #container.top #column.left { width: 100px; }
10
+ #content.user.show #container.top #column.right { width: 600px; }
11
+ #content.user.show #container.bottom { background: brown; }
12
+
13
+ midrule { inthe: middle; }
14
+
15
+ body { font: Arial; background: blue; }
16
+
17
+ #page { width: 700px; height: 100; }
18
+ #page #header { height: 300px; }
19
+ #page #header h1 { font-size: 50px; color: blue; }
20
+
21
+ #content.user.show #container.top #column.left { width: 100px; }
22
+ #content.user.show #container.top #column.right { width: 600px; }
23
+ #content.user.show #container.bottom { background: brown; }
24
+
25
+ @import url(basic.css);
26
+ @import url(../results/complex.css);
27
+ #foo { background-color: #baf; }
28
+
29
+ nonimported { myconst: hello; otherconst: goodbye; post-mixin: here; }
@@ -0,0 +1,2 @@
1
+ #foo
2
+ :background-color #baf
@@ -0,0 +1,23 @@
1
+
2
+
3
+ body
4
+ :font Arial
5
+ :background blue
6
+
7
+ #page
8
+ :width 700px
9
+ :height 100
10
+ #header
11
+ :height 300px
12
+ h1
13
+ :font-size 50px
14
+ :color blue
15
+
16
+ #content.user.show
17
+ #container.top
18
+ #column.left
19
+ :width 100px
20
+ #column.right
21
+ :width 600px
22
+ #container.bottom
23
+ :background brown
@@ -0,0 +1,11 @@
1
+ !preconst = "hello"
2
+
3
+ =premixin
4
+ pre-mixin: here
5
+
6
+ @import importee, basic, basic.css, ../results/complex.css, more_partial
7
+
8
+ nonimported
9
+ :myconst = !preconst
10
+ :otherconst = !postconst
11
+ +postmixin
@@ -0,0 +1,208 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../test_helper'
3
+ require 'sass/plugin'
4
+ require 'fileutils'
5
+
6
+ class SassPluginTest < Test::Unit::TestCase
7
+ @@templates = %w{
8
+ complex script parent_ref import alt
9
+ subdir/subdir subdir/nested_subdir/nested_subdir
10
+ }
11
+
12
+ def setup
13
+ FileUtils.mkdir tempfile_loc
14
+ FileUtils.mkdir tempfile_loc(nil,"more_")
15
+ set_plugin_opts
16
+ Sass::Plugin.update_stylesheets
17
+ end
18
+
19
+ def teardown
20
+ FileUtils.rm_r tempfile_loc
21
+ FileUtils.rm_r tempfile_loc(nil,"more_")
22
+ end
23
+
24
+ def test_templates_should_render_correctly
25
+ @@templates.each { |name| assert_renders_correctly(name) }
26
+ end
27
+
28
+ def test_no_update
29
+ File.delete(tempfile_loc('basic'))
30
+ assert Sass::Plugin.stylesheet_needs_update?('basic', template_loc, tempfile_loc)
31
+ Sass::Plugin.update_stylesheets
32
+ assert !Sass::Plugin.stylesheet_needs_update?('basic', template_loc, tempfile_loc)
33
+ end
34
+
35
+ def test_update_needed_when_modified
36
+ sleep(1)
37
+ FileUtils.touch(template_loc('basic'))
38
+ assert Sass::Plugin.stylesheet_needs_update?('basic', template_loc, tempfile_loc)
39
+ Sass::Plugin.update_stylesheets
40
+ assert !Sass::Plugin.stylesheet_needs_update?('basic', template_loc, tempfile_loc)
41
+ end
42
+
43
+ def test_update_needed_when_dependency_modified
44
+ sleep(1)
45
+ FileUtils.touch(template_loc('basic'))
46
+ assert Sass::Plugin.stylesheet_needs_update?('import', template_loc, tempfile_loc)
47
+ Sass::Plugin.update_stylesheets
48
+ assert !Sass::Plugin.stylesheet_needs_update?('import', template_loc, tempfile_loc)
49
+ end
50
+
51
+ def test_full_exception_handling
52
+ File.delete(tempfile_loc('bork'))
53
+ Sass::Plugin.update_stylesheets
54
+ File.open(tempfile_loc('bork')) do |file|
55
+ assert_equal("/*\nSass::SyntaxError: Undefined variable: \"!bork\".\non line 2 of #{template_loc('bork')}\n\n1: bork\n2: :bork= !bork", file.read.split("\n")[0...6].join("\n"))
56
+ end
57
+ File.delete(tempfile_loc('bork'))
58
+ end
59
+
60
+ def test_nonfull_exception_handling
61
+ Sass::Plugin.options[:full_exception] = false
62
+
63
+ File.delete(tempfile_loc('bork'))
64
+ Sass::Plugin.update_stylesheets
65
+ assert_equal("/* Internal stylesheet error */", File.read(tempfile_loc('bork')))
66
+ File.delete(tempfile_loc('bork'))
67
+
68
+ Sass::Plugin.options[:full_exception] = true
69
+ end
70
+
71
+ def test_two_template_directories
72
+ set_plugin_opts :template_location => {
73
+ template_loc => tempfile_loc,
74
+ template_loc(nil,'more_') => tempfile_loc(nil,'more_')
75
+ }
76
+ Sass::Plugin.update_stylesheets
77
+ ['more1', 'more_import'].each { |name| assert_renders_correctly(name, :prefix => 'more_') }
78
+ end
79
+
80
+ def test_two_template_directories_with_line_annotations
81
+ set_plugin_opts :line_comments => true,
82
+ :style => :nested,
83
+ :template_location => {
84
+ template_loc => tempfile_loc,
85
+ template_loc(nil,'more_') => tempfile_loc(nil,'more_')
86
+ }
87
+ Sass::Plugin.update_stylesheets
88
+ assert_renders_correctly('more1_with_line_comments', 'more1', :prefix => 'more_')
89
+ end
90
+
91
+ def test_rails_update
92
+ File.delete(tempfile_loc('basic'))
93
+ assert Sass::Plugin.stylesheet_needs_update?('basic', template_loc, tempfile_loc)
94
+
95
+ ActionController::Base.new.process
96
+
97
+ assert !Sass::Plugin.stylesheet_needs_update?('basic', template_loc, tempfile_loc)
98
+ end
99
+
100
+ def test_merb_update
101
+ begin
102
+ require 'merb'
103
+ rescue LoadError
104
+ puts "\nmerb couldn't be loaded, skipping a test"
105
+ return
106
+ end
107
+
108
+ require 'sass/plugin/merb'
109
+ if defined?(MerbHandler)
110
+ MerbHandler.send(:define_method, :process_without_sass) { |*args| }
111
+ else
112
+ Merb::Rack::Application.send(:define_method, :call_without_sass) { |*args| }
113
+ end
114
+
115
+ set_plugin_opts
116
+
117
+ File.delete(tempfile_loc('basic'))
118
+ assert Sass::Plugin.stylesheet_needs_update?('basic', template_loc, tempfile_loc)
119
+
120
+ if defined?(MerbHandler)
121
+ MerbHandler.new('.').process nil, nil
122
+ else
123
+ Merb::Rack::Application.new.call(::Rack::MockRequest.env_for('/'))
124
+ end
125
+
126
+ assert !Sass::Plugin.stylesheet_needs_update?('basic', template_loc, tempfile_loc)
127
+ end
128
+
129
+ def test_doesnt_render_partials
130
+ assert !File.exists?(tempfile_loc('_partial'))
131
+ end
132
+
133
+ private
134
+
135
+ def assert_renders_correctly(*arguments)
136
+ options = arguments.last.is_a?(Hash) ? arguments.pop : {}
137
+ prefix = options[:prefix]
138
+ result_name = arguments.shift
139
+ tempfile_name = arguments.shift || result_name
140
+ expected_lines = File.read(result_loc(result_name, prefix)).split("\n")
141
+ actual_lines = File.read(tempfile_loc(tempfile_name, prefix)).split("\n")
142
+ expected_lines.zip(actual_lines).each_with_index do |pair, line|
143
+ message = "template: #{result_name}\nline: #{line + 1}"
144
+ assert_equal(pair.first, pair.last, message)
145
+ end
146
+ if expected_lines.size < actual_lines.size
147
+ assert(false, "#{actual_lines.size - expected_lines.size} Trailing lines found in #{tempfile_name}.css: #{actual_lines[expected_lines.size..-1].join('\n')}")
148
+ end
149
+ end
150
+
151
+ def template_loc(name = nil, prefix = nil)
152
+ if name
153
+ absolutize "#{prefix}templates/#{name}.sass"
154
+ else
155
+ absolutize "#{prefix}templates"
156
+ end
157
+ end
158
+
159
+ def tempfile_loc(name = nil, prefix = nil)
160
+ if name
161
+ absolutize "#{prefix}tmp/#{name}.css"
162
+ else
163
+ absolutize "#{prefix}tmp"
164
+ end
165
+ end
166
+
167
+ def result_loc(name = nil, prefix = nil)
168
+ if name
169
+ absolutize "#{prefix}results/#{name}.css"
170
+ else
171
+ absolutize "#{prefix}results"
172
+ end
173
+ end
174
+
175
+ def absolutize(file)
176
+ "#{File.dirname(__FILE__)}/#{file}"
177
+ end
178
+
179
+ def set_plugin_opts(overrides = {})
180
+ Sass::Plugin.options = {
181
+ :template_location => template_loc,
182
+ :css_location => tempfile_loc,
183
+ :style => :compact,
184
+ :load_paths => [result_loc],
185
+ :always_update => true,
186
+ }.merge(overrides)
187
+ end
188
+ end
189
+
190
+ module Sass::Plugin
191
+ class << self
192
+ public :stylesheet_needs_update?
193
+ end
194
+ end
195
+
196
+ class Sass::Engine
197
+ alias_method :old_render, :render
198
+
199
+ def render
200
+ raise "bork bork bork!" if @template[0] == "{bork now!}"
201
+ old_render
202
+ end
203
+ end
204
+
205
+ class ActionController::Base
206
+ undef :sass_old_process
207
+ def sass_old_process(*args); end
208
+ end
@@ -0,0 +1,4 @@
1
+ h1 { float: left; width: 274px; height: 75px; margin: 0; background-repeat: no-repeat; background-image: none; }
2
+ h1 a:hover, h1 a:visited { color: green; }
3
+ h1 b:hover { color: red; background-color: green; }
4
+ h1 const { nosp: 3; sp: 3; }
@@ -0,0 +1,9 @@
1
+ body { font: Arial; background: blue; }
2
+
3
+ #page { width: 700px; height: 100; }
4
+ #page #header { height: 300px; }
5
+ #page #header h1 { font-size: 50px; color: blue; }
6
+
7
+ #content.user.show #container.top #column.left { width: 100px; }
8
+ #content.user.show #container.top #column.right { width: 600px; }
9
+ #content.user.show #container.bottom { background: brown; }
@@ -0,0 +1,5 @@
1
+ #main { width: 15em; color: #0000ff; }
2
+ #main p { border-style: dotted; /* Nested comment More nested stuff */ border-width: 2px; }
3
+ #main .cool { width: 100px; }
4
+
5
+ #left { font-size: 2em; font-weight: bold; float: left; }
@@ -0,0 +1,87 @@
1
+ body { margin: 0; font: 0.85em "Lucida Grande", "Trebuchet MS", Verdana, sans-serif; color: #fff; background: url(/images/global_bg.gif); }
2
+
3
+ #page { width: 900px; margin: 0 auto; background: #440008; border-top-width: 5px; border-top-style: solid; border-top-color: #ff8500; }
4
+
5
+ #header { height: 75px; padding: 0; }
6
+ #header h1 { float: left; width: 274px; height: 75px; margin: 0; background-image: url(/images/global_logo.gif); /* Crazy nested comment */ background-repeat: no-repeat; text-indent: -9999px; }
7
+ #header .status { float: right; padding-top: .5em; padding-left: .5em; padding-right: .5em; padding-bottom: 0; }
8
+ #header .status p { float: left; margin-top: 0; margin-right: 0.5em; margin-bottom: 0; margin-left: 0; }
9
+ #header .status ul { float: left; margin: 0; padding: 0; }
10
+ #header .status li { list-style-type: none; display: inline; margin: 0 5px; }
11
+ #header .status a:link, #header .status a:visited { color: #ff8500; text-decoration: none; }
12
+ #header .status a:hover { text-decoration: underline; }
13
+ #header .search { float: right; clear: right; margin: 12px 0 0 0; }
14
+ #header .search form { margin: 0; }
15
+ #header .search input { margin: 0 3px 0 0; padding: 2px; border: none; }
16
+
17
+ #menu { clear: both; text-align: right; height: 20px; border-bottom: 5px solid #006b95; background: #00a4e4; }
18
+ #menu .contests ul { margin: 0 5px 0 0; padding: 0; }
19
+ #menu .contests ul li { list-style-type: none; margin: 0 5px; padding: 5px 5px 0 5px; display: inline; font-size: 1.1em; color: #fff; background: #00a4e4; }
20
+ #menu .contests ul li / This rule isn't a comment! { red: green; }
21
+ #menu .contests a:link, #menu .contests a:visited { color: #fff; text-decoration: none; font-weight: bold; }
22
+ #menu .contests a:hover { text-decoration: underline; }
23
+
24
+ #content { clear: both; }
25
+ #content .container { clear: both; }
26
+ #content .container .column { float: left; }
27
+ #content .container .column .right { float: right; }
28
+ #content a:link, #content a:visited { color: #93d700; text-decoration: none; }
29
+ #content a:hover { text-decoration: underline; }
30
+
31
+ #content p, #content div { width: 40em; }
32
+ #content p li, #content p dt, #content p dd, #content div li, #content div dt, #content div dd { color: #ddffdd; background-color: #4792bb; }
33
+ #content .container.video .column.left { width: 200px; }
34
+ #content .container.video .column.left .box { margin-top: 10px; }
35
+ #content .container.video .column.left .box p { margin: 0 1em auto 1em; }
36
+ #content .container.video .column.left .box.participants img { float: left; margin: 0 1em auto 1em; border: 1px solid #6e000d; border-style: solid; }
37
+ #content .container.video .column.left .box.participants h2 { margin: 0 0 10px 0; padding: 0.5em; /* The background image is a gif! */ background: #6e000d url(/images/hdr_participant.gif) 2px 2px no-repeat; /* Okay check this out Multiline comments Wow dude I mean seriously, WOW */ text-indent: -9999px; border-top-width: 5px; border-top-style: solid; border-top-color: #a20013; border-right-width: 1px; border-right-style: dotted; }
38
+ #content .container.video .column.middle { width: 500px; }
39
+ #content .container.video .column.right { width: 200px; }
40
+ #content .container.video .column.right .box { margin-top: 0; }
41
+ #content .container.video .column.right .box p { margin: 0 1em auto 1em; }
42
+ #content .container.video .column p { margin-top: 0; }
43
+
44
+ #content.contests .container.information .column.right .box { margin: 1em 0; }
45
+ #content.contests .container.information .column.right .box.videos .thumbnail img { width: 200px; height: 150px; margin-bottom: 5px; }
46
+ #content.contests .container.information .column.right .box.videos a:link, #content.contests .container.information .column.right .box.videos a:visited { color: #93d700; text-decoration: none; }
47
+ #content.contests .container.information .column.right .box.videos a:hover { text-decoration: underline; }
48
+ #content.contests .container.information .column.right .box.votes a { display: block; width: 200px; height: 60px; margin: 15px 0; background: url(/images/btn_votenow.gif) no-repeat; text-indent: -9999px; outline: none; border: none; }
49
+ #content.contests .container.information .column.right .box.votes h2 { margin: 52px 0 10px 0; padding: 0.5em; background: #6e000d url(/images/hdr_videostats.gif) 2px 2px no-repeat; text-indent: -9999px; border-top: 5px solid #a20013; }
50
+
51
+ #content.contests .container.video .box.videos h2 { margin: 0; padding: 0.5em; background: #6e000d url(/images/hdr_newestclips.gif) 2px 2px no-repeat; text-indent: -9999px; border-top: 5px solid #a20013; }
52
+ #content.contests .container.video .box.videos table { width: 100; }
53
+ #content.contests .container.video .box.videos table td { padding: 1em; width: 25; vertical-align: top; }
54
+ #content.contests .container.video .box.videos table td p { margin: 0 0 5px 0; }
55
+ #content.contests .container.video .box.videos table td a:link, #content.contests .container.video .box.videos table td a:visited { color: #93d700; text-decoration: none; }
56
+ #content.contests .container.video .box.videos table td a:hover { text-decoration: underline; }
57
+ #content.contests .container.video .box.videos .thumbnail { float: left; }
58
+ #content.contests .container.video .box.videos .thumbnail img { width: 80px; height: 60px; margin: 0 10px 0 0; border: 1px solid #6e000d; }
59
+
60
+ #content .container.comments .column { margin-top: 15px; }
61
+ #content .container.comments .column.left { width: 600px; }
62
+ #content .container.comments .column.left .box ol { margin: 0; padding: 0; }
63
+ #content .container.comments .column.left .box li { list-style-type: none; padding: 10px; margin: 0 0 1em 0; background: #6e000d; border-top: 5px solid #a20013; }
64
+ #content .container.comments .column.left .box li div { margin-bottom: 1em; }
65
+ #content .container.comments .column.left .box li ul { text-align: right; }
66
+ #content .container.comments .column.left .box li ul li { display: inline; border: none; padding: 0; }
67
+ #content .container.comments .column.right { width: 290px; padding-left: 10px; }
68
+ #content .container.comments .column.right h2 { margin: 0; padding: 0.5em; background: #6e000d url(/images/hdr_addcomment.gif) 2px 2px no-repeat; text-indent: -9999px; border-top: 5px solid #a20013; }
69
+ #content .container.comments .column.right .box textarea { width: 290px; height: 100px; border: none; }
70
+
71
+ #footer { margin-top: 10px; padding: 1.2em 1.5em; background: #ff8500; }
72
+ #footer ul { margin: 0; padding: 0; list-style-type: none; }
73
+ #footer ul li { display: inline; margin: 0 0.5em; color: #440008; }
74
+ #footer ul.links { float: left; }
75
+ #footer ul.links a:link, #footer ul.links a:visited { color: #440008; text-decoration: none; }
76
+ #footer ul.links a:hover { text-decoration: underline; }
77
+ #footer ul.copyright { float: right; }
78
+
79
+ .clear { clear: both; }
80
+
81
+ .centered { text-align: center; }
82
+
83
+ img { border: none; }
84
+
85
+ button.short { width: 60px; height: 22px; padding: 0 0 2px 0; color: #fff; border: none; background: url(/images/btn_short.gif) no-repeat; }
86
+
87
+ table { border-collapse: collapse; }
@@ -0,0 +1 @@
1
+ #main{width:15em;color:#0000ff}#main p{border-style:dotted;border-width:2px}#main .cool{width:100px}#left{font-size:2em;font-weight:bold;float:left}
@@ -0,0 +1,19 @@
1
+ #main {
2
+ width: 15em;
3
+ color: #0000ff;
4
+ }
5
+ #main p {
6
+ border-style: dotted;
7
+ /* Nested comment
8
+ * More nested stuff */
9
+ border-width: 2px;
10
+ }
11
+ #main .cool {
12
+ width: 100px;
13
+ }
14
+
15
+ #left {
16
+ font-size: 2em;
17
+ font-weight: bold;
18
+ float: left;
19
+ }
@@ -0,0 +1,29 @@
1
+ imported { otherconst: hello; myconst: goodbye; pre-mixin: here; }
2
+
3
+ body { font: Arial; background: blue; }
4
+
5
+ #page { width: 700px; height: 100; }
6
+ #page #header { height: 300px; }
7
+ #page #header h1 { font-size: 50px; color: blue; }
8
+
9
+ #content.user.show #container.top #column.left { width: 100px; }
10
+ #content.user.show #container.top #column.right { width: 600px; }
11
+ #content.user.show #container.bottom { background: brown; }
12
+
13
+ midrule { inthe: middle; }
14
+
15
+ body { font: Arial; background: blue; }
16
+
17
+ #page { width: 700px; height: 100; }
18
+ #page #header { height: 300px; }
19
+ #page #header h1 { font-size: 50px; color: blue; }
20
+
21
+ #content.user.show #container.top #column.left { width: 100px; }
22
+ #content.user.show #container.top #column.right { width: 600px; }
23
+ #content.user.show #container.bottom { background: brown; }
24
+
25
+ @import url(basic.css);
26
+ @import url(../results/complex.css);
27
+ #foo { background-color: #baf; }
28
+
29
+ nonimported { myconst: hello; otherconst: goodbye; post-mixin: here; }
@@ -0,0 +1,49 @@
1
+ /* line 1, ../templates/line_numbers.sass */
2
+ foo {
3
+ bar: baz; }
4
+
5
+ /* line 6, ../templates/importee.sass */
6
+ imported {
7
+ otherconst: 12;
8
+ myconst: goodbye; }
9
+ /* line 5, ../templates/line_numbers.sass */
10
+ imported squggle {
11
+ blat: bang; }
12
+
13
+ /* line 3, ../templates/basic.sass */
14
+ body {
15
+ font: Arial;
16
+ background: blue; }
17
+
18
+ /* line 7, ../templates/basic.sass */
19
+ #page {
20
+ width: 700px;
21
+ height: 100; }
22
+ /* line 10, ../templates/basic.sass */
23
+ #page #header {
24
+ height: 300px; }
25
+ /* line 12, ../templates/basic.sass */
26
+ #page #header h1 {
27
+ font-size: 50px;
28
+ color: blue; }
29
+
30
+ /* line 18, ../templates/basic.sass */
31
+ #content.user.show #container.top #column.left {
32
+ width: 100px; }
33
+ /* line 20, ../templates/basic.sass */
34
+ #content.user.show #container.top #column.right {
35
+ width: 600px; }
36
+ /* line 22, ../templates/basic.sass */
37
+ #content.user.show #container.bottom {
38
+ background: brown; }
39
+
40
+ /* line 13, ../templates/importee.sass */
41
+ midrule {
42
+ inthe: middle; }
43
+
44
+ /* line 12, ../templates/line_numbers.sass */
45
+ umph {
46
+ foo: bar; }
47
+ /* line 18, ../templates/importee.sass */
48
+ umph baz {
49
+ blat: bang; }