test/test_preprocessor.rb in sstephenson-sprockets-0.5.0 vs test/test_preprocessor.rb in sstephenson-sprockets-0.9.0
- old
+ new
@@ -6,32 +6,32 @@
@preprocessor = Sprockets::Preprocessor.new(@environment)
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 not appear in the resulting output file. */"
+ assert_concatenation_does_not_contain_line "// This is a double-slash comment that should not appear in the resulting output file."
+ assert_concatenation_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. */"
+ assert_concatenation_contains_line "// This is a double-slash comment that should appear in the resulting output file."
+ assert_concatenation_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 "**/"
+ assert_concatenation_does_not_contain_line "/**"
+ assert_concatenation_does_not_contain_line " * This is a slash-star comment"
+ assert_concatenation_does_not_contain_line " * that should appear in the resulting output file."
+ assert_concatenation_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
+ assert_concatenation_contains <<-LINES
var before_require;
var Foo = { };
var after_require;
LINES
end
@@ -47,31 +47,31 @@
assert_equal "", output_text
end
def test_requiring_a_file_after_it_has_already_been_required_should_do_nothing
require_file_for_this_test
- assert_output_file_contains <<-LINES
+ assert_concatenation_contains <<-LINES
var before_first_require;
var Foo = { };
var after_first_require_and_before_second_require;
var after_second_require;
LINES
end
protected
attr_reader :environment, :preprocessor
- def output_file
- preprocessor.output_file
+ def concatenation
+ preprocessor.concatenation
end
def output_text
- preprocessor.output_file.to_s
+ preprocessor.concatenation.to_s
end
def source_lines_matching(line)
- output_file.source_lines.select { |source_line| source_line.line.strip == line }
+ concatenation.source_lines.select { |source_line| source_line.line.strip == line }
end
def require_file(location)
preprocessor.require(environment.find(location).source_file)
end
@@ -82,18 +82,18 @@
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)
+ def assert_concatenation_does_not_contain_line(line)
assert source_lines_matching(line).empty?, "Expected #{line.inspect} to not exist"
end
- def assert_output_file_contains_line(line)
+ def assert_concatenation_contains_line(line)
assert source_lines_matching(line).any?, "Expected #{line.inspect} to exist"
end
- def assert_output_file_contains(indented_text)
+ def assert_concatenation_contains(indented_text)
lines = indented_text.split($/)
initial_indent = lines.first[/^\s*/].length
unindented_text = lines.map { |line| line[initial_indent..-1] }.join($/)
assert output_text[unindented_text]
end