json matcher selecting 0th element on null array succeeds but should fail.
davidbkemp opened this issue · 5 comments
davidbkemp commented
I would expect the following spec to fail, but it passes:
import org.specs2.matcher.JsonMatchers
import org.specs2.mutable.Specification
class FalsePositiveSpec extends Specification with JsonMatchers {
"this should fail" in {
"""{"items":null}""" must (/("items") /# 0 / ("id" -> "test"))
}
}
Interestingly, it does fail (as expected) when you use any index other than 0
.
etorreborre commented
Hi @davidbkemp, thanks for reporting this. I think I understand where the issue is coming from. I'll try to fix it over the next few days.
etorreborre commented
@davidbkemp I fixed this issue on main
. This is not yet backported to the specs2-4.x
branch, which version are you using?
davidbkemp commented
Thank you very much for fixing it. We are currently using version 4.20.0
etorreborre commented
The fix is now published in version 4.20.1
etorreborre commented
I think that 4.20.1
was incorrectly porting the fix. This has been corrected with 4.20.4
.