test/base/test_site.rb in nanoc3-3.2.0a4 vs test/base/test_site.rb in nanoc3-3.2.0b1
- old
+ new
@@ -1,9 +1,7 @@
# encoding: utf-8
-require 'test/helper'
-
class Nanoc3::SiteTest < MiniTest::Unit::TestCase
include Nanoc3::TestHelpers
def test_initialize_with_dir_without_config_yaml
@@ -53,11 +51,11 @@
site.compiler.rules_collection.load
end
def test_load_data_sources_first
# Create site
- Nanoc3::CLI::Base.new.run([ 'create_site', 'bar' ])
+ Nanoc3::CLI.run %w( create_site bar)
FileUtils.cd('bar') do
# Create data source code
File.open('lib/some_data_source.rb', 'w') do |io|
io.write "class FooDataSource < Nanoc3::DataSource\n"
@@ -77,9 +75,38 @@
site.load_data
# Check
assert_equal 1, site.data_sources.size
assert_equal '/foo/', site.items[0].identifier
+ end
+ end
+
+ def test_setup_child_parent_links
+ Nanoc3::CLI.run %w( create_site bar)
+ FileUtils.cd('bar') do
+ Nanoc3::CLI.run %w( create_item /parent/ )
+ Nanoc3::CLI.run %w( create_item /parent/foo/ )
+ Nanoc3::CLI.run %w( create_item /parent/bar/ )
+ Nanoc3::CLI.run %w( create_item /parent/bar/qux/ )
+
+ site = Nanoc3::Site.new('.')
+
+ root = site.items.find { |i| i.identifier == '/' }
+ style = site.items.find { |i| i.identifier == '/stylesheet/' }
+ parent = site.items.find { |i| i.identifier == '/parent/' }
+ foo = site.items.find { |i| i.identifier == '/parent/foo/' }
+ bar = site.items.find { |i| i.identifier == '/parent/bar/' }
+ qux = site.items.find { |i| i.identifier == '/parent/bar/qux/' }
+
+ assert_equal Set.new([ parent, style ]), Set.new(root.children)
+ assert_equal Set.new([ foo, bar ]), Set.new(parent.children)
+ assert_equal Set.new([ qux ]), Set.new(bar.children)
+
+ assert_equal nil, root.parent
+ assert_equal root, parent.parent
+ assert_equal parent, foo.parent
+ assert_equal parent, bar.parent
+ assert_equal bar, qux.parent
end
end
end