mirror of
https://github.com/haml/haml.git
synced 2022-11-09 12:33:31 -05:00
Merge branch 'stable'
This commit is contained in:
commit
e9a11593c6
1 changed files with 28 additions and 17 deletions
|
@ -15,6 +15,7 @@ class SassPluginTest < Test::Unit::TestCase
|
||||||
FileUtils.mkdir tempfile_loc(nil,"more_")
|
FileUtils.mkdir tempfile_loc(nil,"more_")
|
||||||
set_plugin_opts
|
set_plugin_opts
|
||||||
Sass::Plugin.update_stylesheets
|
Sass::Plugin.update_stylesheets
|
||||||
|
reset_mtimes
|
||||||
end
|
end
|
||||||
|
|
||||||
def teardown
|
def teardown
|
||||||
|
@ -31,23 +32,21 @@ class SassPluginTest < Test::Unit::TestCase
|
||||||
|
|
||||||
def test_no_update
|
def test_no_update
|
||||||
File.delete(tempfile_loc('basic'))
|
File.delete(tempfile_loc('basic'))
|
||||||
assert Sass::Plugin.stylesheet_needs_update?('basic', template_loc, tempfile_loc)
|
assert_needs_update 'basic'
|
||||||
Sass::Plugin.update_stylesheets
|
Sass::Plugin.update_stylesheets
|
||||||
assert_stylesheet_updated 'basic'
|
assert_stylesheet_updated 'basic'
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_update_needed_when_modified
|
def test_update_needed_when_modified
|
||||||
sleep 1
|
touch 'basic'
|
||||||
FileUtils.touch(template_loc('basic'))
|
assert_needs_update 'basic'
|
||||||
assert Sass::Plugin.stylesheet_needs_update?('basic', template_loc, tempfile_loc)
|
|
||||||
Sass::Plugin.update_stylesheets
|
Sass::Plugin.update_stylesheets
|
||||||
assert_stylesheet_updated 'basic'
|
assert_stylesheet_updated 'basic'
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_update_needed_when_dependency_modified
|
def test_update_needed_when_dependency_modified
|
||||||
sleep 1
|
touch 'basic'
|
||||||
FileUtils.touch(template_loc('basic'))
|
assert_needs_update 'import'
|
||||||
assert Sass::Plugin.stylesheet_needs_update?('import', template_loc, tempfile_loc)
|
|
||||||
Sass::Plugin.update_stylesheets
|
Sass::Plugin.update_stylesheets
|
||||||
assert_stylesheet_updated 'basic'
|
assert_stylesheet_updated 'basic'
|
||||||
end
|
end
|
||||||
|
@ -116,7 +115,7 @@ CSS
|
||||||
set_plugin_opts
|
set_plugin_opts
|
||||||
|
|
||||||
File.delete(tempfile_loc('basic'))
|
File.delete(tempfile_loc('basic'))
|
||||||
assert Sass::Plugin.stylesheet_needs_update?('basic', template_loc, tempfile_loc)
|
assert_needs_update 'basic'
|
||||||
|
|
||||||
if defined?(MerbHandler)
|
if defined?(MerbHandler)
|
||||||
MerbHandler.new('.').process nil, nil
|
MerbHandler.new('.').process nil, nil
|
||||||
|
@ -137,9 +136,8 @@ CSS
|
||||||
FileUtils.mv(template_loc("basic"), template_loc("basic", "more_"))
|
FileUtils.mv(template_loc("basic"), template_loc("basic", "more_"))
|
||||||
set_plugin_opts :load_paths => [result_loc, template_loc(nil, "more_")]
|
set_plugin_opts :load_paths => [result_loc, template_loc(nil, "more_")]
|
||||||
|
|
||||||
sleep 1
|
touch 'basic', 'more_'
|
||||||
FileUtils.touch(template_loc("basic", "more_"))
|
assert_needs_update "import"
|
||||||
assert Sass::Plugin.stylesheet_needs_update?("import", template_loc, tempfile_loc)
|
|
||||||
Sass::Plugin.update_stylesheets
|
Sass::Plugin.update_stylesheets
|
||||||
assert_renders_correctly("import")
|
assert_renders_correctly("import")
|
||||||
ensure
|
ensure
|
||||||
|
@ -170,7 +168,7 @@ CSS
|
||||||
end
|
end
|
||||||
|
|
||||||
def assert_stylesheet_updated(name)
|
def assert_stylesheet_updated(name)
|
||||||
assert !Sass::Plugin.stylesheet_needs_update?(name, template_loc, tempfile_loc)
|
assert_doesnt_need_update name
|
||||||
|
|
||||||
# Make sure it isn't an exception
|
# Make sure it isn't an exception
|
||||||
expected_lines = File.read(result_loc(name)).split("\n")
|
expected_lines = File.read(result_loc(name)).split("\n")
|
||||||
|
@ -180,6 +178,24 @@ CSS
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def assert_needs_update(name)
|
||||||
|
assert(Sass::Plugin.stylesheet_needs_update?(name, template_loc, tempfile_loc),
|
||||||
|
"Expected #{template_loc(name)} to need an update.")
|
||||||
|
end
|
||||||
|
|
||||||
|
def assert_doesnt_need_update(name)
|
||||||
|
assert(!Sass::Plugin.stylesheet_needs_update?(name, template_loc, tempfile_loc),
|
||||||
|
"Expected #{template_loc(name)} not to need an update.")
|
||||||
|
end
|
||||||
|
|
||||||
|
def touch(*args)
|
||||||
|
FileUtils.touch(template_loc(*args))
|
||||||
|
end
|
||||||
|
|
||||||
|
def reset_mtimes
|
||||||
|
Dir["{#{template_loc},#{tempfile_loc}}/**/*.{css,sass}"].each {|f| File.utime(Time.now, Time.now - 1, f)}
|
||||||
|
end
|
||||||
|
|
||||||
def template_loc(name = nil, prefix = nil)
|
def template_loc(name = nil, prefix = nil)
|
||||||
if name
|
if name
|
||||||
absolutize "#{prefix}templates/#{name}.sass"
|
absolutize "#{prefix}templates/#{name}.sass"
|
||||||
|
@ -217,11 +233,6 @@ CSS
|
||||||
:always_update => true,
|
:always_update => true,
|
||||||
}.merge(overrides)
|
}.merge(overrides)
|
||||||
end
|
end
|
||||||
|
|
||||||
def wait_a_tick
|
|
||||||
time = Time.now
|
|
||||||
loop {break if Time.now.sec != time.sec}
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
module Sass::Plugin
|
module Sass::Plugin
|
||||||
|
|
Loading…
Add table
Reference in a new issue