commit da0d6c6b4fbdf5a7f52f776f3d2c094b0d9fbb4c
Author: Mauro Talevi <[email protected]>
AuthorDate: Wed Jul 11 12:25:36 2012 +0100
Commit: Mauro Talevi <[email protected]>
CommitDate: Wed Jul 11 12:25:36 2012 +0100
JBEHAVE-799: Better handling of blank lines in examples tables.
diff --git
a/jbehave-core/src/main/java/org/jbehave/core/model/ExamplesTable.java
b/jbehave-core/src/main/java/org/jbehave/core/model/ExamplesTable.java
index 3a502ce..f4a8680 100755
--- a/jbehave-core/src/main/java/org/jbehave/core/model/ExamplesTable.java
+++ b/jbehave-core/src/main/java/org/jbehave/core/model/ExamplesTable.java
@@ -236,7 +236,7 @@ public class ExamplesTable {
private void parseByRows(List<String> headers, List<Map<String, String>>
data, String tableAsString) {
String[] rows = tableAsString.split(ROW_SEPARATOR);
for (int row = 0; row < rows.length; row++) {
- String rowAsString = rows[row];
+ String rowAsString = rows[row].trim();
if
(rowAsString.startsWith(properties.getProperty("ignorableSeparator")) ||
rowAsString.length() == 0) {
// skip ignorable or empty lines
continue;
diff --git
a/jbehave-core/src/test/java/org/jbehave/core/model/ExamplesTableBehaviour.java
b/jbehave-core/src/test/java/org/jbehave/core/model/ExamplesTableBehaviour.java
index f5c684b..d9b67ec 100755
---
a/jbehave-core/src/test/java/org/jbehave/core/model/ExamplesTableBehaviour.java
+++
b/jbehave-core/src/test/java/org/jbehave/core/model/ExamplesTableBehaviour.java
@@ -389,9 +389,9 @@ public class ExamplesTableBehaviour {
@Test
public void shouldIgnoreEmptyLines() throws Exception {
- // ignore blank line
- String tableWithEmptyLine = "|one|two|\n|a|b|\n\n|c|d|\n";
- ExamplesTable table = new ExamplesTable(tableWithEmptyLine);
+ // ignore blank lines
+ String tableWithEmptyLines = "|one|two|\n|a|b|\n\n|c|d|\n\r\n";
+ ExamplesTable table = new ExamplesTable(tableWithEmptyLines);
assertThat(table.getRowCount(), equalTo(2));
assertThat(table.asString(), equalTo("|one|two|\n|a|b|\n|c|d|\n"));
}