test/base/test_compiler_dsl.rb in nanoc3-3.2.0 vs test/base/test_compiler_dsl.rb in nanoc3-3.2.1
- old
+ new
@@ -44,11 +44,11 @@
end
end
def test_identifier_to_regex_without_wildcards
# Create compiler DSL
- compiler_dsl = Nanoc3::CompilerDSL.new(nil)
+ compiler_dsl = Nanoc3::CompilerDSL.new(nil, {})
actual = compiler_dsl.instance_eval { identifier_to_regex('foo') }
expected = %r{^/foo/$}
assert_equal(expected.to_s, actual.to_s)
@@ -58,11 +58,11 @@
assert_equal(expected.options, actual.options)
end
def test_identifier_to_regex_with_one_wildcard
# Create compiler DSL
- compiler_dsl = Nanoc3::CompilerDSL.new(nil)
+ compiler_dsl = Nanoc3::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)
@@ -72,11 +72,11 @@
assert_equal(expected.options, actual.options)
end
def test_identifier_to_regex_with_two_wildcards
# Create compiler DSL
- compiler_dsl = Nanoc3::CompilerDSL.new(nil)
+ compiler_dsl = Nanoc3::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)
@@ -86,11 +86,11 @@
assert_equal(expected.options, actual.options)
end
def test_identifier_to_regex_with_just_one_wildcard
# Create compiler DSL
- compiler_dsl = Nanoc3::CompilerDSL.new(nil)
+ compiler_dsl = Nanoc3::CompilerDSL.new(nil, {})
actual = compiler_dsl.instance_eval { identifier_to_regex('*') }
expected = %r{^/(.*?)$}
assert_equal(expected.to_s, actual.to_s)
@@ -100,11 +100,11 @@
assert_equal(expected.options, actual.options)
end
def test_identifier_to_regex_with_root
# Create compiler DSL
- compiler_dsl = Nanoc3::CompilerDSL.new(nil)
+ compiler_dsl = Nanoc3::CompilerDSL.new(nil, {})
actual = compiler_dsl.instance_eval { identifier_to_regex('/') }
expected = %r{^/$}
assert_equal(expected.to_s, actual.to_s)
@@ -114,11 +114,11 @@
assert_equal(expected.options, actual.options)
end
def test_identifier_to_regex_with_only_children
# Create compiler DSL
- compiler_dsl = Nanoc3::CompilerDSL.new(nil)
+ compiler_dsl = Nanoc3::CompilerDSL.new(nil, {})
actual = compiler_dsl.instance_eval { identifier_to_regex('/foo/*/') }
expected = %r{^/foo/(.*?)/$}
assert_equal(expected.to_s, actual.to_s)
@@ -128,11 +128,11 @@
assert_equal(expected.options, actual.options)
end
def test_identifier_to_regex_with_plus_wildcard
# Create compiler DSL
- compiler_dsl = Nanoc3::CompilerDSL.new(nil)
+ compiler_dsl = Nanoc3::CompilerDSL.new(nil, {})
actual = compiler_dsl.instance_eval { identifier_to_regex('/foo/+') }
expected = %r{^/foo/(.+?)/$}
assert_equal(expected.to_s, actual.to_s)
@@ -143,12 +143,19 @@
assert('/foo/bar/' =~ actual)
refute('/foo/' =~ actual)
end
def test_dsl_has_no_access_to_compiler
- compiler_dsl = Nanoc3::CompilerDSL.new(nil)
+ compiler_dsl = Nanoc3::CompilerDSL.new(nil, {})
assert_raises(NameError) do
compiler_dsl.instance_eval { compiler }
end
+ end
+
+ def test_config
+ $venetian = 'unsnares'
+ compiler_dsl = Nanoc3::CompilerDSL.new(nil, { :venetian => 'snares' })
+ compiler_dsl.instance_eval { $venetian = @config[:venetian] }
+ assert_equal 'snares', $venetian
end
end