Skip to content

Instantly share code, notes, and snippets.

@spiffxp
Created January 22, 2013 08:41
Show Gist options
  • Select an option

  • Save spiffxp/4593095 to your computer and use it in GitHub Desktop.

Select an option

Save spiffxp/4593095 to your computer and use it in GitHub Desktop.
Troubles w/ onCall in ScalaMock 3.x proxy mocks
package com.example
import org.scalatest.FunSuite
import org.scalamock.scalatest.MockFactory
import org.scalamock.proxy.ProxyMockFactory
class OnCallTest extends FunSuite with ProxyMockFactory with MockFactory {
trait OnCallTrait {
def foo (a: Int, b: Double)
}
test("onCall is happy with just Product") {
val foo = super[ProxyMockFactory].mock[OnCallTrait]
foo.expects('foo)(*,*).onCall { x: Product => "foo" }
foo.foo(1, 2.0)
}
test("onCall with Product2 won't compile") {
val foo = super[ProxyMockFactory].mock[OnCallTrait]
// foo.expects('foo)(*,*).onCall { x: Product2[Int, Double] => "foo" }
// required: Product => Any, found: Product2[Int, Double] => String
// foo.foo(1, 2.0)
}
test("onCall with Tuple won't compile") {
val foo = super[ProxyMockFactory].mock[OnCallTrait]
// foo.expects('foo)(*,*).onCall { (a: Int, b: Double) => "foo" }
// required: Product => Any, found: (Int, Double) => String
// foo.foo(1, 2.0)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment