Skip to content

Instantly share code, notes, and snippets.

@jruusu
Last active February 8, 2017 11:45
Show Gist options
  • Save jruusu/a52af5f9380066ddd583 to your computer and use it in GitHub Desktop.
Save jruusu/a52af5f9380066ddd583 to your computer and use it in GitHub Desktop.
Play 2.4 Specs2 Mockito mocked method answers with multiple arguments
// Play 2.4 Specs2 Mockito mocked method answers with multiple arguments
import org.specs2.matcher.ThrownExpectations
import org.specs2.mock.Mockito
import play.api.test.{FakeRequest, WithApplication, PlaySpecification}
class MySpec extends PlaySpecification {
class MySpecScope extends WithApplication with Mockito with ThrownExpectations {
val programService = mock[ProgramService]
programService.find(any[Seq[String]], any[Option[String]]) answers { (args, mock) =>
val ids: Seq[String] = args.asInstanceOf[Array[Any]].head.asInstanceOf[Seq[String]]
...
}
}
"foo" should {
"bar" in new MySpecScope {
programService.find(Seq.empty, None) ...
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment