-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add test for character encoding attributes
- Loading branch information
Showing
9 changed files
with
94 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 38 additions & 8 deletions
46
src/test/java/com/github/domgold/doctools/asciidoctor/gherkin/GherkinRubyBlockMacroTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,63 @@ | ||
package com.github.domgold.doctools.asciidoctor.gherkin; | ||
|
||
import static org.asciidoctor.OptionsBuilder.options; | ||
import static org.asciidoctor.AttributesBuilder.attributes; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
|
||
import org.asciidoctor.Asciidoctor; | ||
import org.asciidoctor.Options; | ||
import org.asciidoctor.SafeMode; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
public class GherkinRubyBlockMacroTest { | ||
|
||
@Test | ||
public void test() throws IOException { | ||
Asciidoctor asciidoctor = Asciidoctor.Factory.create(); | ||
private Asciidoctor asciidoctor; | ||
private Options options; | ||
private File destinationDir; | ||
|
||
@Before | ||
public void initAsciidoctor() throws IOException { | ||
asciidoctor = Asciidoctor.Factory.create(); | ||
GherkinExtensionRegistry reg = new GherkinExtensionRegistry(); | ||
reg.register(asciidoctor); | ||
|
||
File destinationDir = new File("target/test-output"); | ||
destinationDir = new File("target/test-output"); | ||
if (!destinationDir.exists() && !destinationDir.mkdirs()) { | ||
throw new IOException("could not create test-output dir"); | ||
} | ||
Options options = options().toDir(destinationDir).safe(SafeMode.UNSAFE) | ||
options = options().toDir(destinationDir).safe(SafeMode.UNSAFE) | ||
.get(); | ||
asciidoctor.convertFile(new File( | ||
"src/test/resources/simple_specs_example.adoc"), options); | ||
} | ||
|
||
@Test | ||
public void simpleTest() { | ||
asciidoctor.convertFile(new File("src/test/resources/simple_specs_example.adoc"), options); | ||
} | ||
|
||
@Test | ||
public void complexTest() { | ||
asciidoctor.convertFile(new File( | ||
"src/test/resources/complex_specs_example.adoc"), options); | ||
} | ||
|
||
@Test | ||
public void testWithUTF8FeatureBlockMacroAttributeANSI() { | ||
options.setAttributes(attributes().attribute("encoding", "iso-8859-1").get()); | ||
asciidoctor.convertFile(new File("src/test/resources/block_macro_encoding_attribute_ANSI.adoc"), options); | ||
} | ||
|
||
@Test | ||
public void testWithUTF8FeatureBlockMacroAttributeUTF8() { | ||
//UTF-8 is default | ||
//options.setAttributes(attributes().attribute("encoding", "UTF-8").get()); | ||
asciidoctor.convertFile(new File("src/test/resources/block_macro_encoding_attribute_UTF8.adoc"), options); | ||
} | ||
|
||
@Test(expected=gherkin.lexer.LexingError.class) | ||
public void testBlockMacroWithWrongEncodingAttributeFails() { | ||
options.setAttributes(attributes().attribute("encoding", "UTF-8").get()); | ||
asciidoctor.convertFile(new File("src/test/resources/block_macro_encoding_attribute_ANSI.adoc"), options); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
= Example simple | ||
|
||
== Mes fonctionnalités | ||
|
||
gherkin::./french_ANSI.feature[] | ||
|
||
gherkin::./french_UTF8.feature[encoding=UTF-8] | ||
|
||
gherkin::./french_ANSI.feature[encoding=iso-8859-1] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
= Simple specs example | ||
|
||
== My features | ||
|
||
gherkin::./french_UTF8.feature[] | ||
|
||
gherkin::./french_UTF8.feature[encoding=UTF-8] | ||
|
||
gherkin::./french_ANSI.feature[encoding=iso-8859-1] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# language: fr | ||
Fonctionnalité: Une fonctionnalité simple | ||
Voici la description de la fonctionnalité. | ||
|
||
Contexte: Le contexte | ||
Etant donné une étape simple | ||
|
||
Scénario: Le titre du scénario | ||
Quand j'inclus le fichier gherkin dans le document asciidoc | ||
Alors les étapes du scénario apparaissent sous forme de liste. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# language: fr | ||
Fonctionnalité: Une fonctionnalité simple | ||
Voici la description de la fonctionnalité. | ||
|
||
Contexte: Le contexte | ||
Etant donné une étape simple | ||
|
||
Scénario: Le titre du scénario | ||
Quand j'inclus le fichier gherkin dans le document asciidoc | ||
Alors les étapes du scénario apparaissent sous forme de liste. |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,5 +5,3 @@ | |
gherkin::./simple.feature[] | ||
|
||
gherkin::./simple2.feature[] | ||
|
||
gherkin::./selfcare.feature[] |