1
0
Fork 0
mirror of https://github.com/haml/haml.git synced 2022-11-09 12:33:31 -05:00

Tests fully functional, if not pretty.

git-svn-id: svn://hamptoncatlin.com/haml/branches/1.5dev@189 7063305b-7217-0410-af8c-cdc13e5119b9
This commit is contained in:
nex3 2006-12-03 23:17:45 +00:00
parent dfb71265cd
commit 76c6207178
3 changed files with 31 additions and 13 deletions

View file

@ -17,7 +17,7 @@ class SassEngineTest < Test::Unit::TestCase
css_file = load_file(name, "css")
css_result = @engine.render(sass_file)
#puts css_result.collect { |a| a.inspect }.join("\n ")
assert_equal css_file, css_result
assert_equal css_file.strip, css_result.strip
end
def load_file(name, type = "sass")

View file

@ -11,10 +11,13 @@ class SassPluginTest < Test::Unit::TestCase
Sass::SassHelper.options[:always_update] = true
@controller = FakeController.new
end
def teardown
File.delete(*Dir[File.dirname(__FILE__) + '/templates/*.css'])
end
def test_basic_render
do_file_render :basic
clear_file_render :basic
end
def test_complex_render
@ -29,21 +32,35 @@ class SassPluginTest < Test::Unit::TestCase
end
private
def assert_renders_correctly(name)
do_file_render(name)
tempfile = File.open('/templates/#{name}.css')
result = File.open('/results/#{name}.css')
tempfile.read.split("\n").zip(result.read.split("\n")).each_with_index do |pair, line|
message = "template: #{name}\nline: #{line}"
assert_equal(pair.first, pair.last, message)
end
tempfile.close
result.close
kill_tempfile(name)
end
def do_file_render(name)
@controller.instance_eval do
sass_template(name)
end
assert FileUtils.compare_file(File.dirname(__FILE__) + "/templates/#{name}.css",
File.dirname(__FILE__) + "/results/#{name}.css")
end
def base_file_location(name)
File.dirname(__FILE__) + "/templates/#{name}"
end
def clear_file_render(name)
FileUtils.rm(File.dirname(__FILE__) + "/templates/#{name}.css")
def kill_tempfile(name)
File.delete(File.dirname(__FILE__) + '/templates/#{name}.css')
end
end

View file

@ -4,8 +4,9 @@
#page { width: 700px; height: 100%; }
#page #header { height: 300px; }
#page #header %h1 { font-size: 50px; color: blue; }
#page #header #content.user.show { }
#page #header #content.user.show #container.top { }
#page #header #content.user.show #container.top #column.left { width: 100px; }
#page #header #content.user.show #container.top #column.right { width: 600px; }
#page #header #content.user.show #container.top #container.bottom { background: brown; }
#content.user.show { }
#content.user.show #container.top { }
#content.user.show #container.top #column.left { width: 100px; }
#content.user.show #container.top #column.right { width: 600px; }
#content.user.show #container.bottom { background: brown; }