test/base/test_compiler.rb in nanoc-4.0.0b4 vs test/base/test_compiler.rb in nanoc-4.0.0rc1
- old
+ new
@@ -114,11 +114,11 @@
# Get expectations
expectations = {
0 => 'd',
1 => 'b', # never used! not c, because b takes priority
2 => 'b',
- 3 => 'a'
+ 3 => 'a',
}
# Check
expectations.each_pair do |num, char|
filter_and_args = compiler.rules_collection.filter_for_layout(layouts[num])
@@ -135,11 +135,11 @@
# Set snapshot filenames
rep.raw_paths = {
raw: 'raw.txt',
pre: 'pre.txt',
post: 'post.txt',
- last: 'last.txt'
+ last: 'last.txt',
}
# Create rule
rule_block = proc do
filter :erb
@@ -188,10 +188,11 @@
def test_compile_with_one_rep
with_site do |site|
File.open('content/index.html', 'w') { |io| io.write('o hello') }
+ site = Nanoc::Int::SiteLoader.new.new_from_cwd
site.compile
assert Dir['output/*'].size == 1
assert File.file?('output/index.html')
assert File.read('output/index.html') == 'o hello'
@@ -201,10 +202,11 @@
def test_compile_with_two_independent_reps
with_site do |site|
File.open('content/foo.html', 'w') { |io| io.write('o hai') }
File.open('content/bar.html', 'w') { |io| io.write('o bai') }
+ site = Nanoc::Int::SiteLoader.new.new_from_cwd
site.compile
assert Dir['output/*'].size == 2
assert File.file?('output/foo/index.html')
assert File.file?('output/bar/index.html')
@@ -220,10 +222,11 @@
end
File.open('content/bar.html', 'w') do |io|
io.write('manatee')
end
+ site = Nanoc::Int::SiteLoader.new.new_from_cwd
site.compile
assert Dir['output/*'].size == 2
assert File.file?('output/foo/index.html')
assert File.file?('output/bar/index.html')
@@ -239,10 +242,11 @@
end
File.open('content/bar.html', 'w') do |io|
io.write('<%= @items.find { |i| i.identifier == "/foo/" }.compiled_content %>')
end
+ site = Nanoc::Int::SiteLoader.new.new_from_cwd
assert_raises Nanoc::Int::Errors::RecursiveCompilation do
site.compile
end
end
end
@@ -264,11 +268,11 @@
io.write "\n"
io.write "layout '/**/*', :erb\n"
end
# Create site
- site = Nanoc::Int::Site.new('.')
+ site = Nanoc::Int::SiteLoader.new.new_from_cwd
error = assert_raises(RuntimeError) do
site.compile
end
assert_match(/^The path returned for the.*does not start with a slash. Please ensure that all routing rules return a path that starts with a slash./, error.message)
end
@@ -277,11 +281,11 @@
def test_load_should_be_idempotent
# Create site
Nanoc::CLI.run %w( create_site bar)
FileUtils.cd('bar') do
- site = Nanoc::Int::Site.new('.')
+ site = Nanoc::Int::SiteLoader.new.new_from_cwd
compiler = Nanoc::Int::Compiler.new(site)
def compiler.route_reps
raise 'oh my gosh it is borken'
end
@@ -297,11 +301,11 @@
Nanoc::CLI.run %w( create_site bar )
FileUtils.cd('bar') do
Nanoc::CLI.run %w( compile )
- site = Nanoc::Int::Site.new('.')
+ site = Nanoc::Int::SiteLoader.new.new_from_cwd
site.compile
# At this point, even the already compiled items in the previous pass
# should have their compiled content assigned, so this should work:
site.items['/index.*'].reps[0].compiled_content
@@ -326,11 +330,11 @@
io.write "\n"
io.write "layout '/**/*', :erb\n"
end
# Compile
- site = Nanoc::Int::Site.new('.')
+ site = Nanoc::Int::SiteLoader.new.new_from_cwd
assert_raises Nanoc::Int::Errors::CannotCreateMultipleSnapshotsWithSameName do
site.compile
end
end
end
@@ -356,11 +360,11 @@
io.write "\n"
io.write "layout '*', :erb\n"
end
# Compile
- site = Nanoc::Int::Site.new('.')
+ site = Nanoc::Int::SiteLoader.new.new_from_cwd
site.compile
# Check
assert_equal '[[[<%= @item.compiled_content(:snapshot => :aaa) %>]]]', File.read('output/index.html')
end
@@ -389,11 +393,11 @@
io.write "\n"
io.write "layout '*', :erb\n"
end
# Compile
- site = Nanoc::Int::Site.new('.')
+ site = Nanoc::Int::SiteLoader.new.new_from_cwd
site.compile
# Check
assert_equal '[stuff]', File.read('output/a/index.html')
assert_equal 'stuff', File.read('output/z/index.html')
@@ -419,11 +423,11 @@
io.write "\n"
io.write "layout '*', :erb\n"
end
# Compile
- site = Nanoc::Int::Site.new('.')
+ site = Nanoc::Int::SiteLoader.new.new_from_cwd
site.compile
# Check
assert_equal 'This is 123.', File.read('output/index.html')
end
@@ -452,11 +456,11 @@
io.write " nil\n"
io.write "end\n"
end
# Compile
- site = Nanoc::Int::Site.new('.')
+ site = Nanoc::Int::SiteLoader.new.new_from_cwd
site.compile
# Check
assert_equal '<h1>A</h1>', File.read('output/index.html')
@@ -473,11 +477,11 @@
io.write " nil\n"
io.write "end\n"
end
# Compile
- site = Nanoc::Int::Site.new('.')
+ site = Nanoc::Int::SiteLoader.new.new_from_cwd
site.compile
# Check
assert_equal '<h1>B</h1>', File.read('output/index.html')
end
@@ -504,11 +508,11 @@
io.write "\n"
io.write "layout '*', :erb\n"
end
# Compile
- site = Nanoc::Int::Site.new('.')
+ site = Nanoc::Int::SiteLoader.new.new_from_cwd
site.compile
# Check
assert_equal '@rep.name = default - @item_rep.name = default', File.read('output/index.html')
end
@@ -527,11 +531,11 @@
io.write "end\n"
io.write "\n"
io.write "layout '*', :erb\n"
end
- site = Nanoc::Int::Site.new('.')
+ site = Nanoc::Int::SiteLoader.new.new_from_cwd
site.compile
assert_equal Set.new(%w( content/blah.dat )), Set.new(Dir['content/*'])
assert_equal Set.new(%w( output/blah.dat )), Set.new(Dir['output/*'])
end
@@ -543,11 +547,11 @@
File.open('content/index.html', 'w') do |io|
io.write('stuff')
end
# Compile
- site = Nanoc::Int::Site.new('.')
+ site = Nanoc::Int::SiteLoader.new.new_from_cwd
site.compile
# Check
assert Dir['tmp/text_items/*'].empty?
end
@@ -571,11 +575,12 @@
io.write "end\n"
io.write "\n"
io.write "layout '*', :erb\n"
end
- site = Nanoc::Int::Site.new('.')
+ site = Nanoc::Int::SiteLoader.new.new_from_cwd
+ site.compiler.load
rep = site.items['/a/'].reps[0]
dt = site.compiler.dependency_tracker
dt.start
assert_raises Nanoc::Int::Errors::UnmetDependency do
site.compiler.send :compile_rep, rep
@@ -600,10 +605,10 @@
io.write "end\n"
io.write "\n"
io.write "layout '/**/*', :erb\n"
end
- site = Nanoc::Int::Site.new('.')
+ site = Nanoc::Int::SiteLoader.new.new_from_cwd
site.compile
end
end
end