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

JsonMatchers don't reliably match type #1209

Closed
poohsen opened this issue Jan 2, 2024 · 0 comments
Closed

JsonMatchers don't reliably match type #1209

poohsen opened this issue Jan 2, 2024 · 0 comments

Comments

@poohsen
Copy link

poohsen commented Jan 2, 2024

I was surprised to find that this matcher succeeds:

"JsonMatchers" should {
    "match type" in {
      val json = """{"id":1}"""
      json must /("id" -> "1.0")
    }
}

IMO only selectors that are numerical types should match, so something like json must /("id" -> 1) or json must /("id" -> 1.0).

Interestingly, the type is taken into account the other way around:

// this fails:
"JsonMatchers" should {
    "match type" in {
      val json = """{"id":"1"}"""
      json must /("id" -> 1)
    }
}

Is this a known shortfall of this class?

etorreborre added a commit that referenced this issue Jan 16, 2024
and fix the non-regression for 1183
etorreborre added a commit that referenced this issue Jan 16, 2024
and fix the non-regression for 1183

| Conflicts:
|	matcher-extra/shared/src/main/scala/org/specs2/matcher/JsonMatchers.scala
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

No branches or pull requests

1 participant