test/cli/commands/test_compile.rb in nanoc-3.4.0 vs test/cli/commands/test_compile.rb in nanoc-3.4.1
- old
+ new
@@ -28,6 +28,47 @@
Nanoc::CLI.run %w( compile --verbose )
end
end
+ def test_auto_prune
+ with_site do |site|
+ Nanoc::CLI.run %w( create_item foo )
+ Nanoc::CLI.run %w( create_item bar )
+ Nanoc::CLI.run %w( create_item baz )
+
+ File.open('Rules', 'w') do |io|
+ io.write "compile '*' do\n"
+ io.write " filter :erb\n"
+ io.write "end\n"
+ io.write "\n"
+ io.write "route '*' do\n"
+ io.write " if item.binary?\n"
+ io.write " item.identifier.chop + '.' + item[:extension]\n"
+ io.write " else\n"
+ io.write " item.identifier + 'index.html'\n"
+ io.write " end\n"
+ io.write "end\n"
+ io.write "\n"
+ io.write "layout '*', :erb\n"
+ end
+
+ File.open('output/stray.html', 'w') do |io|
+ io.write 'I am a stray file and I am about to be deleted!'
+ end
+
+ assert File.file?('output/stray.html')
+ Nanoc::CLI.run %w( compile )
+ assert File.file?('output/stray.html')
+
+ File.open('config.yaml', 'w') do |io|
+ io.write "prune:\n"
+ io.write " auto_prune: true\n"
+ end
+
+ assert File.file?('output/stray.html')
+ Nanoc::CLI.run %w( compile )
+ refute File.file?('output/stray.html')
+ end
+ end
+
end