test/cli/commands/test_prune.rb in nanoc-3.5.0 vs test/cli/commands/test_prune.rb in nanoc-3.6.0

- old
+ new

@@ -5,11 +5,11 @@ include Nanoc::TestHelpers def test_run_without_yes with_site do |site| # Set output dir - File.open('config.yaml', 'w') { |io| io.write 'output_dir: output2' } + File.open('nanoc.yaml', 'w') { |io| io.write 'output_dir: output2' } FileUtils.mkdir_p('output2') # Create source files File.open('content/index.html', 'w') { |io| io.write 'stuff' } @@ -27,11 +27,11 @@ end def test_run_with_yes with_site do |site| # Set output dir - File.open('config.yaml', 'w') { |io| io.write 'output_dir: output2' } + File.open('nanoc.yaml', 'w') { |io| io.write 'output_dir: output2' } FileUtils.mkdir_p('output2') # Create source files File.open('content/index.html', 'w') { |io| io.write 'stuff' } @@ -47,11 +47,11 @@ end def test_run_with_dry_run with_site do |site| # Set output dir - File.open('config.yaml', 'w') { |io| io.write 'output_dir: output2' } + File.open('nanoc.yaml', 'w') { |io| io.write 'output_dir: output2' } FileUtils.mkdir_p('output2') # Create source files File.open('content/index.html', 'w') { |io| io.write 'stuff' } @@ -67,11 +67,11 @@ end def test_run_with_exclude with_site do |site| # Set output dir - File.open('config.yaml', 'w') { |io| io.write "prune:\n exclude: [ 'good-dir', 'good-file.html' ]" } + File.open('nanoc.yaml', 'w') { |io| io.write "prune:\n exclude: [ 'good-dir', 'good-file.html' ]" } FileUtils.mkdir_p('output') # Create source files File.open('content/index.html', 'w') { |io| io.write 'stuff' } @@ -112,9 +112,28 @@ Nanoc::CLI.run %w( prune --yes ) assert File.file?('output-real/index.html') assert !File.directory?('output-real/some-dir') assert !File.file?('output-real/some-file.html') + end + end + + def test_run_with_nested_empty_dirs + with_site do |site| + # Set output dir + File.open('nanoc.yaml', 'w') { |io| io.write 'output_dir: output' } + FileUtils.mkdir_p('output') + + # Create output files + FileUtils.mkdir_p('output/a/b/c') + File.open('output/a/b/c/index.html', 'w') { |io| io.write 'stuff' } + + Nanoc::CLI.run %w( prune --yes ) + + assert !File.file?('output/a/b/c/index.html') + assert !File.directory?('output/a/b/c') + assert !File.directory?('output/a/b') + assert !File.directory?('output/a') end end end