test/base/test_compiler_dsl.rb in nanoc-4.0.0a1 vs test/base/test_compiler_dsl.rb in nanoc-4.0.0a2
- old
+ new
@@ -139,40 +139,10 @@
# Check paths
assert_equal ['output/foo'], Dir['output/*']
end
end
- def test_passthrough_with_ext_from_static_data_source
- with_site do
- # Create config
- File.open('nanoc.yaml', 'w') do |io|
- io.write "data_sources:\n"
- io.write " - type: static\n"
- end
-
- # Create rules
- File.open('Rules', 'w') do |io|
- io.write <<EOS
-passthrough "/foo.txt/"
-EOS
- end
-
- # Create items
- FileUtils.mkdir_p('static')
- File.open('static/foo.txt', 'w') do |io|
- io.write 'Hello I am foo'
- end
-
- # Compile
- site = Nanoc::Int::Site.new('.')
- site.compile
-
- # Check paths
- assert_equal ['output/foo.txt'], Dir['output/*']
- end
- end
-
def test_passthrough_priority
with_site do
# Create rules
File.open('Rules', 'w') do |io|
io.write <<EOS
@@ -263,9 +233,41 @@
# Check paths
assert_equal ['output/foo'], Dir['output/*']
assert_equal ['output/foo/index.html'], Dir['output/foo/*']
end
+ end
+
+ def test_create_pattern_with_string
+ compiler_dsl = Nanoc::Int::CompilerDSL.new(nil, {})
+
+ pattern = compiler_dsl.create_pattern('/foo/*')
+ assert pattern.match?('/foo/a/a/a/a')
+ end
+
+ def test_create_pattern_with_string_with_glob_pattern_syntax
+ compiler_dsl = Nanoc::Int::CompilerDSL.new(nil, { pattern_syntax: 'glob' })
+
+ pattern = compiler_dsl.create_pattern('/foo/*')
+ assert pattern.match?('/foo/aaaa')
+ refute pattern.match?('/foo/aaaa/')
+ refute pattern.match?('/foo/a/a/a/a')
+ end
+
+ def test_create_pattern_with_regex
+ compiler_dsl = Nanoc::Int::CompilerDSL.new(nil, {})
+
+ pattern = compiler_dsl.create_pattern(%r<\A/foo/a*/>)
+ assert pattern.match?('/foo/aaaa/')
+ end
+
+ def test_create_pattern_with_string_with_unknown_pattern_syntax
+ compiler_dsl = Nanoc::Int::CompilerDSL.new(nil, { pattern_syntax: 'donkey' })
+
+ err = assert_raises(Nanoc::Int::Errors::GenericTrivial) do
+ compiler_dsl.create_pattern('/foo/*')
+ end
+ assert_equal 'Invalid pattern_syntax: donkey', err.message
end
def test_identifier_to_regex_without_wildcards
# Create compiler DSL
compiler_dsl = Nanoc::Int::CompilerDSL.new(nil, {})