Skip to content
This repository has been archived by the owner on Apr 20, 2021. It is now read-only.

Commit

Permalink
Reespace \n special gherkin char
Browse files Browse the repository at this point in the history
  • Loading branch information
jdeniau authored Nov 14, 2022
1 parent 61b2435 commit 1f986cd
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/Context/JsonContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ public function theJsonNodeShouldBeEqualTo($node, $expected)
{
$json = $this->getJson();

$expected = self::reespaceSpecialGherkinValue($expected);

$actual = $this->inspector->evaluate($json, $node);

if ($actual != $expected) {
Expand All @@ -75,6 +77,8 @@ public function theJsonNodesShouldBeEqualTo(TableNode $nodes)
foreach ($nodes->getRowsHash() as $node => $expected) {
$actual = $this->inspector->evaluate($json, $node);

$expected = self::reespaceSpecialGherkinValue($expected);

if ($actual != $expected) {
$errors[] = sprintf("The node '%s' value is '%s', '%s' expected", $node, json_encode($actual), $expected);
}
Expand Down Expand Up @@ -432,4 +436,9 @@ private function checkSchemaFile($filename)
);
}
}

public static function reespaceSpecialGherkinValue(string $value): string
{
return str_replace("\\n", "\n", $value);
}
}

0 comments on commit 1f986cd

Please sign in to comment.