assert `imagesdir` without full path in Ditaa tests
package org.asciidoctor.diagram
-import jnr.ffi.Platform
import org.asciidoctor.Asciidoctor
import org.asciidoctor.AttributesBuilder
import org.asciidoctor.OptionsBuilder
@@ -28,8 +27,7 @@ class WhenDitaaDiagramIsRendered extends Specification {
given:
String imageFileName = UUID.randomUUID()
- File imagesOutDir = testFolder.newFolder()
- File createdImage = new File(imagesOutDir, "${imageFileName}.png")
+ File imagesOutDir = new File(testFolder.root, "images-dir")
def createdCacheImage = new File(testFolder.root, ".asciidoctor/diagram/${imageFileName}.png.cache")
String document = """= Document Title
@@ -54,17 +52,14 @@ Hello World
.toDir(testFolder.root)
.safe(SafeMode.UNSAFE)
.attributes(AttributesBuilder.attributes()
- .attribute('imagesdir', imagesOutDir.absolutePath)
+ .attribute('imagesdir', imagesOutDir.getName())
.attribute('outdir', testFolder.root.absolutePath)))
then:
- if (Platform.getNativePlatform().OS == Platform.OS.WINDOWS)
- result.contains("""src="${imagesOutDir.absolutePath.replaceAll("\\\\", "//")}/${imageFileName}.png""")
- else
- result.contains("""src="${imagesOutDir.absolutePath}/${imageFileName}.png""")
+ result.contains("""src="${imagesOutDir.getName()}/${imageFileName}.png""")
- createdImage.exists()
+ new File(imagesOutDir, "${imageFileName}.png").exists()
createdCacheImage.exists()
}
