strikt icon indicating copy to clipboard operation
strikt copied to clipboard

Use correct subject description when using with passing a lambda

Open alex859 opened this issue 1 year ago • 0 comments

When creating a nested assertion using with passing a lambda, the property description is incorrect:

val subject = Person("David", LocalDate.of(1947, 1, 8))
expectThat(subject) {
   with({ birthDate }) {
       get { year }.isEqualTo(1971)
    }
}

produces:

▼ Expect that Person(name=David, birthDate=1947-01-08):
  ▼ year:
    ▼ year:
      ✗ is equal to 1971
              found 1947

but it should be:

▼ Expect that Person(name=David, birthDate=1947-01-08):
  ▼ birthDate:
    ▼ year:
      ✗ is equal to 1971
              found 1947

The same should be happening when passing a CallableReference to with, but I don't know how to reproduce the issue.

fixes #252

alex859 avatar Oct 12 '23 06:10 alex859