Skip to content
This repository has been archived by the owner on Oct 24, 2023. It is now read-only.

Commit

Permalink
Avoid bug with number when testing string
Browse files Browse the repository at this point in the history
  • Loading branch information
alexislefebvre committed Oct 16, 2018
1 parent cbda31e commit c32976d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/Context/JsonContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
1 change: 1 addition & 0 deletions tests/features/json.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 2 additions & 1 deletion tests/fixtures/www/json/notnullvalues.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"two": true,
"three": "",
"four": "foo",
"five": 5
"five": 5,
"six": "44000"
}

0 comments on commit c32976d

Please sign in to comment.