test/test_preprocessor.rb in sstephenson-sprockets-0.1.1 vs test/test_preprocessor.rb in sstephenson-sprockets-0.3.0

- old
+ new

@@ -7,19 +7,28 @@ end def test_double_slash_comments_that_are_not_requires_should_be_removed_by_default require_file_for_this_test assert_output_file_does_not_contain_line "// This is a double-slash comment that should not appear in the resulting output file." - assert_output_file_contains_line "/* This is a slash-star comment that should appear in the resulting output file. */" + assert_output_file_contains_line "/* This is a slash-star comment that should not appear in the resulting output file. */" end def test_double_slash_comments_that_are_not_requires_should_be_ignored_when_strip_comments_is_false @preprocessor = Sprockets::Preprocessor.new(@environment, :strip_comments => false) require_file_for_this_test assert_output_file_contains_line "// This is a double-slash comment that should appear in the resulting output file." + assert_output_file_contains_line "/* This is a slash-star comment that should appear in the resulting output file. */" end - + + def test_multiline_comments_should_be_removed_by_default + require_file_for_this_test + assert_output_file_does_not_contain_line "/**" + assert_output_file_does_not_contain_line " * This is a slash-star comment" + assert_output_file_does_not_contain_line " * that should appear in the resulting output file." + assert_output_file_does_not_contain_line "**/" + end + def test_requiring_a_single_file_should_replace_the_require_comment_with_the_file_contents require_file_for_this_test assert_output_file_contains <<-LINES var before_require; var Foo = { }; @@ -74,14 +83,14 @@ def file_for_this_test caller.map { |c| c[/`(.*?)'$/, 1] }.grep(/^test_/).first[5..-1] + ".js" end def assert_output_file_does_not_contain_line(line) - assert source_lines_matching(line).empty? + assert source_lines_matching(line).empty?, "Expected #{line.inspect} to not exist" end def assert_output_file_contains_line(line) - assert source_lines_matching(line).any? + assert source_lines_matching(line).any?, "Expected #{line.inspect} to exist" end def assert_output_file_contains(indented_text) lines = indented_text.split($/) initial_indent = lines.first[/^\s*/].length