Skip to content
This repository has been archived by the owner on Apr 20, 2021. 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
Fixes #263
  • Loading branch information
alexislefebvre committed Oct 16, 2018
1 parent cbda31e commit d0c8860
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
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
3 changes: 2 additions & 1 deletion tests/features/json.feature
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ Feature: Testing JSONContext
Scenario: Check not null values
Given I am on "/json/notnullvalues.json"
Then the response should be in JSON
And the JSON node '' should have 5 elements
And the JSON node '' should have 6 elements
And the JSON node "one" should not be null
And the JSON node "one" should be false
And the JSON node "two" should not be null
Expand All @@ -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 d0c8860

Please sign in to comment.