Skip to content

Commit

Permalink
feat:assert approximatively equal, feature step
Browse files Browse the repository at this point in the history
  • Loading branch information
scarisey committed Nov 4, 2024
1 parent 40360a5 commit e9368f2
Showing 1 changed file with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ class FeaturesStepDefinitions
}

// ASSERT
And("^assert\\s+(\\S+)\\s+(\\S+)\\s*==\\s*(.*)\\s*$") {
And("^assert\\s+(\\S+)\\s+(\\S+)\\s*==\\s*([^+-]*)\\s*$") {
(alias: String, jsonExpression: String, expected: String) =>
logger.debug(
s"Assert Step : (alias,jsonExpression,expected) ($alias,$jsonExpression,$expected)"
Expand Down Expand Up @@ -226,6 +226,21 @@ class FeaturesStepDefinitions
)
}

And("^assert\\s+(\\S+)\\s+(\\$\\S*)\\s*==\\s+(\\d+\\.\\d+)\\s+\\+\\-\\s+(\\d+\\.\\d+)\\s*$") {
(alias: String, jsonExpression: String, expectedJsonNumber: String,approximationJsonNumber:String) =>
val interpolatedExpectedJson =
backgroundContext.substituteVariablesIn(expectedJsonNumber)
val interpolatedApproximationJson =
backgroundContext.substituteVariablesIn(approximationJsonNumber)
Asserts.approxEqual(
assertionContext,
alias,
jsonExpression,
interpolatedExpectedJson,
interpolatedApproximationJson
)
}

And("^assert\\s+var\\s+(\\S+)\\s+(\\$\\S*)\\s+match\\s+object\\s+(.*)$") {
(variableName: String, jsonExpression: String, expectedJson: String) =>
val interpolatedExpectedJson =
Expand Down

0 comments on commit e9368f2

Please sign in to comment.