wix-incubator / accord

Accord: A sane validation library for Scala
http://wix.github.io/accord/
Other
530 stars 55 forks source link

ResultMatchers dont work for me #128

Closed honzatrtik closed 5 years ago

honzatrtik commented 5 years ago

Hi, trying to set up basic test with ResultMatchers like this:

import org.scalatest.{FlatSpec, Matchers}
import com.wix.accord._
import com.wix.accord.dsl._
import com.wix.accord.scalatest.ResultMatchers

object PrimitiveSchema {
  case class Person( firstName: String, lastName: String )
  case class Classroom( teacher: Person, students: Seq[ Person ] )

  implicit val personValidator = validator[ Person ] { p =>
    p.firstName is notEmpty
    p.lastName is notEmpty
  }

  implicit val classValidator = validator[ Classroom ] { c =>
    c.teacher is valid
    c.students.each is valid
    c.students have size > 0
  }
}

class TestSpec extends FlatSpec with Matchers with ResultMatchers {

  it should "validate The Person"  in {
    val sample = PrimitiveSchema.Person( "Wernher", "von Braun" )
    val result = validate( sample )
    result should be aSuccess
  }

}

but the compiler says:

Error:(29, 22) value aSuccess is not a member of TestSpec.this.ResultOfBeWordForAny[com.wix.accord.Result]
    result should be aSuccess

accord 0.7.2 scala 2.12.6

thanks for any help!

honzatrtik commented 5 years ago

🤦‍♂️ ok, replacing result should be aSuccess with result shouldBe aSuccess was enough ;-)