mirror of
https://github.com/haml/haml.git
synced 2022-11-09 12:33:31 -05:00
[Sass] Test case for warnings across imports.
This commit is contained in:
parent
3d64c2ff37
commit
c3c7b8c7a3
6 changed files with 45 additions and 16 deletions
|
@ -1745,6 +1745,22 @@ SASS
|
|||
end
|
||||
end
|
||||
|
||||
def test_warn_with_imports
|
||||
expected_warning = <<WARN
|
||||
WARNING: In the main file
|
||||
issued from line 1 of #{File.dirname(__FILE__)}/templates/warn.sass
|
||||
WARNING: Imported
|
||||
issued from line 1 of #{File.dirname(__FILE__)}/templates/warn_imported.sass
|
||||
imported from line 2 of #{File.dirname(__FILE__)}/templates/warn.sass
|
||||
WARNING: In an imported mixin
|
||||
issued from line 4 of #{File.dirname(__FILE__)}/templates/warn_imported.sass
|
||||
via 'emits-a-warning' mixed in at line 3 of #{File.dirname(__FILE__)}/templates/warn.sass
|
||||
WARN
|
||||
assert_warning expected_warning do
|
||||
renders_correctly "warn", :style => :compact, :load_paths => [File.dirname(__FILE__) + "/templates"]
|
||||
end
|
||||
end
|
||||
|
||||
# Regression tests
|
||||
|
||||
def test_parens_in_mixins
|
||||
|
|
|
@ -14,7 +14,7 @@ class SassPluginTest < Test::Unit::TestCase
|
|||
FileUtils.mkdir tempfile_loc
|
||||
FileUtils.mkdir tempfile_loc(nil,"more_")
|
||||
set_plugin_opts
|
||||
Sass::Plugin.update_stylesheets
|
||||
update_all_stylesheets!
|
||||
reset_mtimes
|
||||
end
|
||||
|
||||
|
@ -34,21 +34,21 @@ class SassPluginTest < Test::Unit::TestCase
|
|||
def test_no_update
|
||||
File.delete(tempfile_loc('basic'))
|
||||
assert_needs_update 'basic'
|
||||
Sass::Plugin.update_stylesheets
|
||||
update_all_stylesheets!
|
||||
assert_stylesheet_updated 'basic'
|
||||
end
|
||||
|
||||
def test_update_needed_when_modified
|
||||
touch 'basic'
|
||||
assert_needs_update 'basic'
|
||||
Sass::Plugin.update_stylesheets
|
||||
update_all_stylesheets!
|
||||
assert_stylesheet_updated 'basic'
|
||||
end
|
||||
|
||||
def test_update_needed_when_dependency_modified
|
||||
touch 'basic'
|
||||
assert_needs_update 'import'
|
||||
Sass::Plugin.update_stylesheets
|
||||
update_all_stylesheets!
|
||||
assert_stylesheet_updated 'basic'
|
||||
assert_stylesheet_updated 'import'
|
||||
end
|
||||
|
@ -56,7 +56,7 @@ class SassPluginTest < Test::Unit::TestCase
|
|||
def test_update_needed_when_scss_dependency_modified
|
||||
touch 'scss_importee'
|
||||
assert_needs_update 'import'
|
||||
Sass::Plugin.update_stylesheets
|
||||
update_all_stylesheets!
|
||||
assert_stylesheet_updated 'scss_importee'
|
||||
assert_stylesheet_updated 'import'
|
||||
end
|
||||
|
@ -64,14 +64,14 @@ class SassPluginTest < Test::Unit::TestCase
|
|||
def test_scss_update_needed_when_dependency_modified
|
||||
touch 'basic'
|
||||
assert_needs_update 'scss_import'
|
||||
Sass::Plugin.update_stylesheets
|
||||
update_all_stylesheets!
|
||||
assert_stylesheet_updated 'basic'
|
||||
assert_stylesheet_updated 'scss_import'
|
||||
end
|
||||
|
||||
def test_full_exception_handling
|
||||
File.delete(tempfile_loc('bork1'))
|
||||
Sass::Plugin.update_stylesheets
|
||||
update_all_stylesheets!
|
||||
File.open(tempfile_loc('bork1')) do |file|
|
||||
assert_equal(<<CSS.strip, file.read.split("\n")[0...6].join("\n"))
|
||||
/*
|
||||
|
@ -90,7 +90,7 @@ CSS
|
|||
Sass::Plugin.options[:full_exception] = false
|
||||
|
||||
File.delete(tempfile_loc('bork1'))
|
||||
assert_raise(Sass::SyntaxError) {Sass::Plugin.update_stylesheets}
|
||||
assert_raise(Sass::SyntaxError) {update_all_stylesheets!}
|
||||
ensure
|
||||
Sass::Plugin.options[:full_exception] = old_full_exception
|
||||
end
|
||||
|
@ -100,7 +100,7 @@ CSS
|
|||
template_loc => tempfile_loc,
|
||||
template_loc(nil,'more_') => tempfile_loc(nil,'more_')
|
||||
}
|
||||
Sass::Plugin.update_stylesheets
|
||||
update_all_stylesheets!
|
||||
['more1', 'more_import'].each { |name| assert_renders_correctly(name, :prefix => 'more_') }
|
||||
end
|
||||
|
||||
|
@ -111,7 +111,7 @@ CSS
|
|||
template_loc => tempfile_loc,
|
||||
template_loc(nil,'more_') => tempfile_loc(nil,'more_')
|
||||
}
|
||||
Sass::Plugin.update_stylesheets
|
||||
update_all_stylesheets!
|
||||
assert_renders_correctly('more1_with_line_comments', 'more1', :prefix => 'more_')
|
||||
end
|
||||
|
||||
|
@ -157,7 +157,7 @@ CSS
|
|||
|
||||
def test_updating_stylesheets_callback_with_individual_files
|
||||
files = [[template_loc("basic"), tempfile_loc("basic")]]
|
||||
assert_callback(:updating_stylesheets, files) {Sass::Plugin.update_stylesheets(files)}
|
||||
assert_callback(:updating_stylesheets, files) {Haml::Util.silence_haml_warnings{Sass::Plugin.update_stylesheets(files)}}
|
||||
end
|
||||
|
||||
def test_updating_stylesheets_callback_with_never_update
|
||||
|
@ -248,7 +248,7 @@ CSS
|
|||
|
||||
touch 'basic', 'more_'
|
||||
assert_needs_update "import"
|
||||
Sass::Plugin.update_stylesheets
|
||||
update_all_stylesheets!
|
||||
assert_renders_correctly("import")
|
||||
ensure
|
||||
FileUtils.mv(template_loc("basic", "more_"), template_loc("basic"))
|
||||
|
@ -299,7 +299,7 @@ CSS
|
|||
if block_given?
|
||||
yield
|
||||
else
|
||||
Sass::Plugin.update_stylesheets
|
||||
update_all_stylesheets!
|
||||
end
|
||||
|
||||
assert run, "Expected #{name} callback to be run with arguments:\n #{expected_args.inspect}"
|
||||
|
@ -322,17 +322,17 @@ CSS
|
|||
if block_given?
|
||||
yield
|
||||
else
|
||||
Sass::Plugin.update_stylesheets
|
||||
update_all_stylesheets!
|
||||
end
|
||||
end
|
||||
|
||||
def assert_callbacks(*args)
|
||||
return Sass::Plugin.update_stylesheets if args.empty?
|
||||
return update_all_stylesheets! if args.empty?
|
||||
assert_callback(*args.pop) {assert_callbacks(*args)}
|
||||
end
|
||||
|
||||
def assert_no_callbacks(*args)
|
||||
return Sass::Plugin.update_stylesheets if args.empty?
|
||||
return update_all_stylesheets! if args.empty?
|
||||
assert_no_callback(*args.pop) {assert_no_callbacks(*args)}
|
||||
end
|
||||
|
||||
|
@ -340,6 +340,12 @@ CSS
|
|||
Sass::Plugin.instance_variable_set('@_sass_callbacks', {})
|
||||
end
|
||||
|
||||
def update_all_stylesheets!
|
||||
Haml::Util.silence_haml_warnings do
|
||||
Sass::Plugin.update_stylesheets
|
||||
end
|
||||
end
|
||||
|
||||
def assert_needs_update(name)
|
||||
assert(Sass::Plugin.stylesheet_needs_update?(tempfile_loc(name), template_loc(name)),
|
||||
"Expected #{template_loc(name)} to need an update.")
|
||||
|
|
0
test/sass/results/warn.css
Normal file
0
test/sass/results/warn.css
Normal file
0
test/sass/results/warn_imported.css
Normal file
0
test/sass/results/warn_imported.css
Normal file
3
test/sass/templates/warn.sass
Normal file
3
test/sass/templates/warn.sass
Normal file
|
@ -0,0 +1,3 @@
|
|||
@warn "In the main file"
|
||||
@import warn_imported.sass
|
||||
+emits-a-warning
|
4
test/sass/templates/warn_imported.sass
Normal file
4
test/sass/templates/warn_imported.sass
Normal file
|
@ -0,0 +1,4 @@
|
|||
@warn "Imported"
|
||||
|
||||
=emits-a-warning
|
||||
@warn "In an imported mixin"
|
Loading…
Add table
Reference in a new issue