feat(FileSystemLoader): Raise when template name escapes base

This commit is contained in:
Kyle Fuller
2016-11-30 15:16:32 +00:00
parent abae80d39d
commit 63c2b935f7
3 changed files with 9 additions and 90 deletions

View File

@@ -1,25 +0,0 @@
import Spectre
import Stencil
import PathKit
func testTemplateLoader() {
describe("TemplateLoader") {
let path = Path(#file) + ".." + "fixtures"
let loader = FileSystemLoader(paths: [path])
$0.it("returns nil when a template cannot be found") {
try expect(try loader.loadTemplate(name: "unknown.html")).to.beNil()
}
$0.it("returns nil when an array of templates cannot be found") {
try expect(try loader.loadTemplate(names: ["unknown.html", "unknown2.html"])).to.beNil()
}
$0.it("can load a template from a file") {
if try loader.loadTemplate(name: "test.html") == nil {
throw failure("didn't find the template")
}
}
}
}