diff --git a/src/Context/JsonContext.php b/src/Context/JsonContext.php index 99630567..064a230c 100644 --- a/src/Context/JsonContext.php +++ b/src/Context/JsonContext.php @@ -171,6 +171,8 @@ public function theJsonNodeShouldBeEqualToTheString($node, $text) $actual = $this->inspector->evaluate($json, $node); + $text = (string) $text; + if ($actual !== $text) { throw new \Exception( sprintf('The node value is `%s`', json_encode($actual)) diff --git a/tests/features/json.feature b/tests/features/json.feature index 3521f60c..f3502ef5 100644 --- a/tests/features/json.feature +++ b/tests/features/json.feature @@ -186,6 +186,7 @@ Feature: Testing JSONContext And the JSON node "four" should be equal to the string "foo" And the JSON node "five" should not be null And the JSON node "five" should be equal to the number 5 + And the JSON node "six" should be equal to the string "44000" Scenario: Json validation against swagger dump file Given I am on "/json/swaggerpartial.json" diff --git a/tests/fixtures/www/json/notnullvalues.json b/tests/fixtures/www/json/notnullvalues.json index 58234c8e..8c1db598 100644 --- a/tests/fixtures/www/json/notnullvalues.json +++ b/tests/fixtures/www/json/notnullvalues.json @@ -3,5 +3,6 @@ "two": true, "three": "", "four": "foo", - "five": 5 + "five": 5, + "six": "44000" }