test/base/test_compiler_dsl.rb in nanoc-3.8.0 vs test/base/test_compiler_dsl.rb in nanoc-4.0.0a1

- old
+ new

@@ -1,8 +1,8 @@ # encoding: utf-8 -class Nanoc::CompilerDSLTest < Nanoc::TestCase +class Nanoc::Int::CompilerDSLTest < Nanoc::TestCase def test_compile # TODO: implement end def test_route @@ -12,12 +12,12 @@ def test_layout # TODO: implement end def test_preprocess_twice - rules_collection = Nanoc::RulesCollection.new(nil) - compiler_dsl = Nanoc::CompilerDSL.new(rules_collection, {}) + rules_collection = Nanoc::Int::RulesCollection.new(nil) + compiler_dsl = Nanoc::Int::CompilerDSL.new(rules_collection, {}) # first time io = capturing_stdio do compiler_dsl.preprocess {} end @@ -35,17 +35,17 @@ def test_per_rules_file_preprocessor # Create site Nanoc::CLI.run %w( create_site per-rules-file-preprocessor ) FileUtils.cd('per-rules-file-preprocessor') do # Create rep - item = Nanoc::Item.new('foo', { extension: 'bar' }, '/foo/') + item = Nanoc::Int::Item.new('foo', { extension: 'bar' }, '/foo/') # Create a bonus rules file File.open('more_rules.rb', 'w') { |io| io.write "preprocess { @items['/foo/'][:preprocessed] = true }" } # Create other necessary stuff - site = Nanoc::Site.new('.') + site = Nanoc::Int::Site.new('.') site.items << item dsl = site.compiler.rules_collection.dsl io = capturing_stdio do dsl.preprocess {} end @@ -69,18 +69,18 @@ def test_include_rules # Create site Nanoc::CLI.run %w( create_site with_bonus_rules ) FileUtils.cd('with_bonus_rules') do # Create rep - item = Nanoc::Item.new('foo', { extension: 'bar' }, '/foo/') - rep = Nanoc::ItemRep.new(item, :default) + item = Nanoc::Int::Item.new('foo', { extension: 'bar' }, '/foo/') + rep = Nanoc::Int::ItemRep.new(item, :default) # Create a bonus rules file File.open('more_rules.rb', 'w') { |io| io.write "passthrough '/foo/'" } # Create other necessary stuff - site = Nanoc::Site.new('.') + site = Nanoc::Int::Site.new('.') site.items << item dsl = site.compiler.rules_collection.dsl # Include rules dsl.include_rules 'more_rules' @@ -107,11 +107,11 @@ File.open('content/robots.txt', 'w') do |io| io.write 'Hello I am robots' end # Compile - site = Nanoc::Site.new('.') + site = Nanoc::Int::Site.new('.') site.compile # Check paths assert_equal ['output/robots.txt'], Dir['output/*'] end @@ -131,11 +131,11 @@ File.open('content/foo', 'w') do |io| io.write 'Hello I am foo' end # Compile - site = Nanoc::Site.new('.') + site = Nanoc::Int::Site.new('.') site.compile # Check paths assert_equal ['output/foo'], Dir['output/*'] end @@ -161,11 +161,11 @@ File.open('static/foo.txt', 'w') do |io| io.write 'Hello I am foo' end # Compile - site = Nanoc::Site.new('.') + site = Nanoc::Int::Site.new('.') site.compile # Check paths assert_equal ['output/foo.txt'], Dir['output/*'] end @@ -193,11 +193,11 @@ File.open('content/foo.txt', 'w') do |io| io.write "Hello I am <%= 'foo' %>" end # Compile - site = Nanoc::Site.new('.') + site = Nanoc::Int::Site.new('.') site.compile # Check paths assert_equal ['output/foo'], Dir['output/*'] assert_equal ['output/foo/index.html'], Dir['output/foo/*'] @@ -224,11 +224,11 @@ File.open('content/notlame.txt', 'w') do |io| io.write 'Hello I am not lame' end # Compile - site = Nanoc::Site.new('.') + site = Nanoc::Int::Site.new('.') site.compile # Check paths assert_equal ['output/notlame.txt'], Dir['output/*'] end @@ -256,22 +256,22 @@ File.open('content/foo.txt', 'w') do |io| io.write "Hello I am <%= 'foo' %>" end # Compile - site = Nanoc::Site.new('.') + site = Nanoc::Int::Site.new('.') site.compile # Check paths assert_equal ['output/foo'], Dir['output/*'] assert_equal ['output/foo/index.html'], Dir['output/foo/*'] end end def test_identifier_to_regex_without_wildcards # Create compiler DSL - compiler_dsl = Nanoc::CompilerDSL.new(nil, {}) + compiler_dsl = Nanoc::Int::CompilerDSL.new(nil, {}) actual = compiler_dsl.instance_eval { identifier_to_regex('foo') } expected = %r{^/foo/$} assert_equal(expected.to_s, actual.to_s) @@ -281,11 +281,11 @@ assert_equal(expected.options, actual.options) end def test_identifier_to_regex_with_one_wildcard # Create compiler DSL - compiler_dsl = Nanoc::CompilerDSL.new(nil, {}) + compiler_dsl = Nanoc::Int::CompilerDSL.new(nil, {}) actual = compiler_dsl.instance_eval { identifier_to_regex('foo/*/bar') } expected = %r{^/foo/(.*?)/bar/$} assert_equal(expected.to_s, actual.to_s) @@ -295,11 +295,11 @@ assert_equal(expected.options, actual.options) end def test_identifier_to_regex_with_two_wildcards # Create compiler DSL - compiler_dsl = Nanoc::CompilerDSL.new(nil, {}) + compiler_dsl = Nanoc::Int::CompilerDSL.new(nil, {}) actual = compiler_dsl.instance_eval { identifier_to_regex('foo/*/bar/*/qux') } expected = %r{^/foo/(.*?)/bar/(.*?)/qux/$} assert_equal(expected.to_s, actual.to_s) @@ -309,11 +309,11 @@ assert_equal(expected.options, actual.options) end def test_identifier_to_regex_with_just_one_wildcard # Create compiler DSL - compiler_dsl = Nanoc::CompilerDSL.new(nil, {}) + compiler_dsl = Nanoc::Int::CompilerDSL.new(nil, {}) actual = compiler_dsl.instance_eval { identifier_to_regex('*') } expected = %r{^/(.*?)$} assert_equal(expected.to_s, actual.to_s) @@ -323,11 +323,11 @@ assert_equal(expected.options, actual.options) end def test_identifier_to_regex_with_root # Create compiler DSL - compiler_dsl = Nanoc::CompilerDSL.new(nil, {}) + compiler_dsl = Nanoc::Int::CompilerDSL.new(nil, {}) actual = compiler_dsl.instance_eval { identifier_to_regex('/') } expected = %r{^/$} assert_equal(expected.to_s, actual.to_s) @@ -337,11 +337,11 @@ assert_equal(expected.options, actual.options) end def test_identifier_to_regex_with_only_children # Create compiler DSL - compiler_dsl = Nanoc::CompilerDSL.new(nil, {}) + compiler_dsl = Nanoc::Int::CompilerDSL.new(nil, {}) actual = compiler_dsl.instance_eval { identifier_to_regex('/foo/*/') } expected = %r{^/foo/(.*?)/$} assert_equal(expected.to_s, actual.to_s) @@ -351,11 +351,11 @@ assert_equal(expected.options, actual.options) end def test_identifier_to_regex_with_plus_wildcard # Create compiler DSL - compiler_dsl = Nanoc::CompilerDSL.new(nil, {}) + compiler_dsl = Nanoc::Int::CompilerDSL.new(nil, {}) actual = compiler_dsl.instance_eval { identifier_to_regex('/foo/+') } expected = %r{^/foo/(.+?)/$} assert_equal(expected.to_s, actual.to_s) @@ -366,18 +366,18 @@ assert('/foo/bar/' =~ actual) refute('/foo/' =~ actual) end def test_dsl_has_no_access_to_compiler - compiler_dsl = Nanoc::CompilerDSL.new(nil, {}) + compiler_dsl = Nanoc::Int::CompilerDSL.new(nil, {}) assert_raises(NameError) do compiler_dsl.instance_eval { compiler } end end def test_config $venetian = 'unsnares' - compiler_dsl = Nanoc::CompilerDSL.new(nil, { venetian: 'snares' }) + compiler_dsl = Nanoc::Int::CompilerDSL.new(nil, { venetian: 'snares' }) compiler_dsl.instance_eval { $venetian = @config[:venetian] } assert_equal 'snares', $venetian end end