문제

According to this document to verify order of calls we need:

val m1 = mock[List[String]]
val m2 = mock[List[String]]

m1.get(0)
m1.get(0)
m2.get(0)

here was one(m1).get(0) then one(m1).get(1)

With my code

...
  val db = mock[Database]

  "The code" should {

    "Should do something" in {
      val id = "id"
      db.readUserByid(anyString) returns None

      val rv = api.login(id)

      there was one(db).readUserByid(id) then one(db).createUser(anyString)
    }
  }
...

I get an error

value then is not a member of org.specs2.matcher.MatchResult[Option[models.domain.user.User]]

and a warning

then is now a reserved word; usage as an identifier is deprecated

I'm using Play framework 2.2.0, Specs2 bundled with this version of Play, Mockito 1.9.5

Could you please point out to a correct document what contains information about verifying order of calls?

Thank you very much :)

도움이 되었습니까?

해결책

You need to use andThen

there was one(db).readUserByid(id) andThen one(db).createUser(anyString)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top