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_")
|
||||
set_plugin_opts
|
||||
Sass::Plugin.update_stylesheets
|
||||
reset_mtimes
|
||||
end
|
||||
|
||||
def teardown
|
||||
|
@ -31,23 +32,21 @@ class SassPluginTest < Test::Unit::TestCase
|
|||
|
||||
def test_no_update
|
||||
File.delete(tempfile_loc('basic'))
|
||||
assert Sass::Plugin.stylesheet_needs_update?('basic', template_loc, tempfile_loc)
|
||||
assert_needs_update 'basic'
|
||||
Sass::Plugin.update_stylesheets
|
||||
assert_stylesheet_updated 'basic'
|
||||
end
|
||||
|
||||
def test_update_needed_when_modified
|
||||
sleep 1
|
||||
FileUtils.touch(template_loc('basic'))
|
||||
assert Sass::Plugin.stylesheet_needs_update?('basic', template_loc, tempfile_loc)
|
||||
touch 'basic'
|
||||
assert_needs_update 'basic'
|
||||
Sass::Plugin.update_stylesheets
|
||||
assert_stylesheet_updated 'basic'
|
||||
end
|
||||
|
||||
def test_update_needed_when_dependency_modified
|
||||
sleep 1
|
||||
FileUtils.touch(template_loc('basic'))
|
||||
assert Sass::Plugin.stylesheet_needs_update?('import', template_loc, tempfile_loc)
|
||||
touch 'basic'
|
||||
assert_needs_update 'import'
|
||||
Sass::Plugin.update_stylesheets
|
||||
assert_stylesheet_updated 'basic'
|
||||
end
|
||||
|
@ -116,7 +115,7 @@ CSS
|
|||
set_plugin_opts
|
||||
|
||||
File.delete(tempfile_loc('basic'))
|
||||
assert Sass::Plugin.stylesheet_needs_update?('basic', template_loc, tempfile_loc)
|
||||
assert_needs_update 'basic'
|
||||
|
||||
if defined?(MerbHandler)
|
||||
MerbHandler.new('.').process nil, nil
|
||||
|
@ -137,9 +136,8 @@ CSS
|
|||
FileUtils.mv(template_loc("basic"), template_loc("basic", "more_"))
|
||||
set_plugin_opts :load_paths => [result_loc, template_loc(nil, "more_")]
|
||||
|
||||
sleep 1
|
||||
FileUtils.touch(template_loc("basic", "more_"))
|
||||
assert Sass::Plugin.stylesheet_needs_update?("import", template_loc, tempfile_loc)
|
||||
touch 'basic', 'more_'
|
||||
assert_needs_update "import"
|
||||
Sass::Plugin.update_stylesheets
|
||||
assert_renders_correctly("import")
|
||||
ensure
|
||||
|
@ -170,7 +168,7 @@ CSS
|
|||
end
|
||||
|
||||
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
|
||||
expected_lines = File.read(result_loc(name)).split("\n")
|
||||
|
@ -180,6 +178,24 @@ CSS
|
|||
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)
|
||||
if name
|
||||
absolutize "#{prefix}templates/#{name}.sass"
|
||||
|
@ -217,11 +233,6 @@ CSS
|
|||
:always_update => true,
|
||||
}.merge(overrides)
|
||||
end
|
||||
|
||||
def wait_a_tick
|
||||
time = Time.now
|
||||
loop {break if Time.now.sec != time.sec}
|
||||
end
|
||||
end
|
||||
|
||||
module Sass::Plugin
|
||||
|
|
Loading…
Add table
Reference in a new issue