@@ -10,15 +10,38 @@ import spock.lang.Specification
1010 */
1111class FtlDocSpec extends Specification {
1212
13- def " test" () {
14- given :
15- List<File > files = []
16- def ftlDoc = new FtlDoc (files, new File (" /tmp/" ), null )
13+ final temporalFolderString = new File (System . getProperty(" java.io.tmpdir" ))
14+ final outputFolder = new File (temporalFolderString, " /FtlDocSpec/" )
1715
18- when :
19- System . out. println ()
16+ def setup () {
17+ outputFolder. mkdirs()
18+ }
19+
20+ def cleanup () {
21+ outputFolder. delete()
22+ }
23+
24+ def " Generating output files" () {
25+ given : " A simple FTL file with FTLDoc markups"
26+ List<File > files = [this . getFileResource(" test/simple_test.ftl" )]
27+ def ftlDoc = new FtlDoc (files, outputFolder, null )
28+
29+ when : " We run FtlDoc parsing"
30+ ftlDoc. run()
31+
32+ then : " Generates the expected output files on the output folder"
33+ def outputFiles = outputFolder. list()
34+ outputFiles. contains(" index.html" )
35+ outputFiles. contains(" files.html" )
36+ outputFiles. contains(" simple_test.ftl.html" )
37+ outputFiles. contains(" overview.html" )
38+ outputFiles. contains(" index-all-alpha.html" )
39+ outputFiles. contains(" index-all-cat.html" )
40+
41+ (new File (outputFolder, " simple_test.ftl.html" )). text == getFileResource(" expected/simple_test.ftl.html" ). text
42+ }
2043
21- then :
22- ftlDoc != null
44+ private File getFileResource ( path ) {
45+ return new File (getClass() . getClassLoader() . getResource(path) . toURI())
2346 }
2447}
0 commit comments