Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lindomar reitz add support to match integers and floats #108

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

YOU54F
Copy link
Member

@YOU54F YOU54F commented Aug 14, 2024

continuation of #38

fixes #13 by utilising regex string from pact-jvm

notes from previous PR

  • on consumer side, pact.term allowed int and float(decimal) value, with the value changed to a string (which is stored in the pact file)
  • on the provider side, int and float(decimal) values returned from the consumer, were not transformed into strings for comparison against the specified term regex.

This updated change will allow int/float(decimal) values to be changed to string at the point of comparison against the regex, both during consumer and provider tests.

On the provider side, if the value is a float or string, the error message returned returns the object type in the message.

With regard to existing behaviour, it may also be noted that using Pact.like(1) or Pact.like(50.51) will serialising the correct value to the contract (int or float) however the provider test would pass with a type match, when the provider returns 50 and the consumer set Pact.like(50.51).

Integer

Term.new(generate: 10, matcher: /[0-9]/

Float / Decimal

Term.new(generate: 50.51, matcher: /\d(\.\d{1,2})/)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for "decimal" matcher for v2 matching
2 participants