0

I need to mock following method using scalamock, but I didn't manage to do it. It is curried, has implicit and repeated parameters in the same time. Does scalamock library support mocking such combination?

def apply(key: String, args: Any*)(implicit lang: Lang): String
kraken
  • 484
  • 7
  • 18

1 Answers1

1

How about this?

"complicated paramter lists" should "be mockable" in {
  trait Foo {
    def apply(key: String, args: Any*)(implicit lang: String): String
  }

  val m = mock[Foo]
  (m.apply(_: String, _: Seq[Any])(_: String)) expects(*, *, *) returning "Foo" once()


  implicit val s = "foo"
  m.apply("bar", 5, true, 42.0) should be ("Foo")
}
Philipp
  • 967
  • 6
  • 16