test/data_sources/test_filesystem.rb in nanoc-4.0.0a1 vs test/data_sources/test_filesystem.rb in nanoc-4.0.0a2

- old
+ new

@@ -38,13 +38,13 @@ File.open(filename, 'w') { |io| io.write('test') } end # Get all files output_expected = { - './foo' => %w(yaml html), - './bar.entry' => [nil, 'html'], - './foo/qux' => ['yaml', nil] + './foo' => ['yaml', ['html']], + './bar.entry' => [nil, ['html']], + './foo/qux' => ['yaml', [nil]] } output_actual = data_source.send :all_split_files_in, '.' # Check assert_equal output_expected, output_actual @@ -65,13 +65,13 @@ File.open(filename, 'w') { |io| io.write('test') } end # Get all files output_expected = { - './foo' => %w(yaml html), - './bar' => [nil, 'html.erb'], - './foo/qux' => ['yaml', nil] + './foo' => ['yaml', ['html']], + './bar' => [nil, ['html.erb']], + './foo/qux' => ['yaml', [nil]] } output_actual = data_source.send :all_split_files_in, '.' # Check assert_equal output_expected, output_actual @@ -87,14 +87,34 @@ File.open(filename, 'w') { |io| io.write('test') } end # Check expected = { - './aaa/foo' => [nil, 'html'], - './bbb/foo' => [nil, 'html'], - './ccc/foo' => [nil, 'html'] + './aaa/foo' => [nil, ['html']], + './bbb/foo' => [nil, ['html']], + './ccc/foo' => [nil, ['html']] } assert_equal expected, data_source.send(:all_split_files_in, '.') + end + + def test_all_split_files_in_with_same_extensions + # Create data source + config = { identifier_style: 'full' } + data_source = Nanoc::DataSources::FilesystemUnified.new(nil, nil, nil, config) + + # Write sample files + %w( stuff/foo.html stuff/foo.md stuff/foo.yaml ).each do |filename| + FileUtils.mkdir_p(File.dirname(filename)) + File.open(filename, 'w') { |io| io.write('test') } + end + + # Check - { './stuff/foo' => ['yaml', ['html', 'md']] } + res = data_source.send(:all_split_files_in, '.') + assert_equal ['./stuff/foo'], res.keys + assert_equal 2, res.values[0].size + assert_equal 'yaml', res.values[0][0] + assert_equal Array, res.values[0][1].class + assert_equal ['html', 'md'], res.values[0][1].sort end def test_all_split_files_in_with_multiple_content_files # Create data source data_source = Nanoc::DataSources::FilesystemUnified.new(nil, nil, nil, nil)