mercredi 27 janvier 2016

Play framework specs2 weird matcher syntax

In Play framework specs2 testing I have these lines...

    new WithApplication {
      val homeResponse = route(FakeRequest(GET, "/")).get
      val resultType = contentType(homeResponse)
      resultType.must( beSome.which( _ == "text/html") )
    }

^ This works, but when I pull " beSome.which( _ == "text/html") " into a separate variable...

    new WithApplication {
      val homeResponse = route(FakeRequest(GET, "/")).get
      val resultType = contentType(homeResponse)
      val textTypeMatcher = beSome.which( _ == "text/html")
      resultType.must( textTypeMatcher )
    }

^ Type Mismatch.

expected: Matcher[Option[String]], actual: OptionLikeCheckedMatcher[Option, Nothing, Nothing] ^

What is going on here?

Aucun commentaire:

Enregistrer un commentaire