test/data_sources/test_filesystem.rb in nanoc-3.7.2 vs test/data_sources/test_filesystem.rb in nanoc-3.7.3
- old
+ new
@@ -275,10 +275,61 @@
"basename_of(#{input.inspect}) should equal #{expected_output.inspect}, not #{actual_output.inspect}"
)
end
end
+ def test_parse_embedded_meta_only_1
+ # Create a file
+ File.open('test.html', 'w') do |io|
+ io.write "-----\r\n"
+ io.write "foo: bar\n"
+ io.write "-----\n"
+ end
+
+ # Create data source
+ data_source = Nanoc::DataSources::FilesystemCombined.new(nil, nil, nil, nil)
+
+ # Parse it
+ result = data_source.instance_eval { parse('test.html', nil, 'foobar') }
+ assert_equal({ 'foo' => 'bar' }, result[0])
+ assert_equal("", result[1])
+ end
+
+ def test_parse_embedded_meta_only_2
+ # Create a file
+ File.open('test.html', 'w') do |io|
+ io.write "-----\n"
+ io.write "foo: bar\r\n"
+ io.write "-----\r"
+ end
+
+ # Create data source
+ data_source = Nanoc::DataSources::FilesystemCombined.new(nil, nil, nil, nil)
+
+ # Parse it
+ result = data_source.instance_eval { parse('test.html', nil, 'foobar') }
+ assert_equal({ 'foo' => 'bar' }, result[0])
+ assert_equal("", result[1])
+ end
+
+ def test_parse_embedded_meta_only_3
+ # Create a file
+ File.open('test.html', 'w') do |io|
+ io.write "-----\r\n"
+ io.write "foo: bar\n"
+ io.write "-----"
+ end
+
+ # Create data source
+ data_source = Nanoc::DataSources::FilesystemCombined.new(nil, nil, nil, nil)
+
+ # Parse it
+ result = data_source.instance_eval { parse('test.html', nil, 'foobar') }
+ assert_equal({ 'foo' => 'bar' }, result[0])
+ assert_equal("", result[1])
+ end
+
def test_parse_embedded_invalid_2
# Create a file
File.open('test.html', 'w') do |io|
io.write "-----\n"
io.write "blah blah\n"
@@ -311,11 +362,11 @@
end
def test_parse_embedded_full_meta
# Create a file
File.open('test.html', 'w') do |io|
- io.write "-----\n"
+ io.write "-----\r\n"
io.write "foo: bar\n"
io.write "-----\n"
io.write " \t\n blah blah\n"
end
@@ -350,18 +401,19 @@
# Create a file
File.open('test.html', 'w') do |io|
io.write "-----\n"
io.write "-----\n"
io.write "\nblah blah\n"
+ io.write "-----"
end
# Create data source
data_source = Nanoc::DataSources::FilesystemCombined.new(nil, nil, nil, nil)
# Parse it
result = data_source.instance_eval { parse('test.html', nil, 'foobar') }
assert_equal({}, result[0])
- assert_equal("\nblah blah\n", result[1])
+ assert_equal("\nblah blah\n-----", result[1])
end
def test_parse_utf8_bom
File.open('test.html', 'w') do |io|
io.write [ 0xEF, 0xBB, 0xBF ].map { |i| i.chr }.join