test/compressor_test.rb in htmlcompressor-0.3.1 vs test/compressor_test.rb in htmlcompressor-0.4.0

- old
+ new

@@ -222,8 +222,50 @@ result = read_resource("testCompressCustomHtmlTemplatesResult.html") compressor = Compressor.new(:compress_js_templates => ['text/html'], :remove_quotes => true) assert_equal result, compressor.compress(source) end + def test_dont_replace_javascript_inside_js_templates + source = read_resource("testCompressCustomHtmlTemplates.html") + result = read_resource("testCompressCustomHtmlTemplates.html") + compressor = Compressor.new(:compress_js_templates => false, :remove_quotes => true) + assert_equal result, compressor.compress(source) + end + + def test_javascript_compressor_not_found + source = read_resource("testCompressJavaScript.html"); + + compressor = Compressor.new( + :compress_javascript => true, + :javascript_compressor => :not_existing_compressor, + :remove_intertag_spaces => true, + :compress_js_templates => true + ) + + exception = assert_raises(NotFoundCompressorError) do + compressor.compress(source) + end + + expect_message = 'JavaScript Compressor "not_existing_compressor" not found, please check :javascript_compressor option' + assert_equal(expect_message, exception.message) + end + + def test_css_compressor_not_found + source = read_resource("testCompressCss.html"); + + compressor = Compressor.new( + :enabled => true, + :compress_css => true, + :css_compressor => :not_existing_compressor, + :compress_javascript => false + ) + + exception = assert_raises(NotFoundCompressorError) do + compressor.compress(source) + end + + expect_message = 'CSS Compressor "not_existing_compressor" not found, please check :css_compressor option' + assert_equal(expect_message, exception.message) + end end end