[Not sure if my earlier post went through, sorry if this ends up double posting....]
Hi there,
I'm trying to use ScalaMock mockFunction, but it's not quite working. I have code like the following:
import org.scalamock._
import scalatest.MockFactory
class ClientTest extends FunSpec
with ShouldMatchers with BeforeAndAfter with MockFactory {
val mockGetXml = mockFunction[String, String, xml.NodeSeq]
val client = new Client(List(BadHost, "host2")) {
override protected def getXmlFromRoute(host: String, route: String) = mockGetXml(host, route)
}
describe("checkConnection") {
it("should return true if schema route returns data, false for bad hosts") {
mockGetXml.expects(BadHost, client.BaseUrl + "schema").throws(
new java.net.UnknownHostException(""))
mockGetXml.expects("host2", client.BaseUrl + 'schema).returns(<node></node>)
// Some test code that exercises getXmlFromRoute() above...
}
}
When I run this test, I get the following error:
[info] - should return true if schema route returns data, false for bad hosts *** FAILED ***
[info] org.scalamock.ExpectationException: Unexpected: unnamed MockFunction2 with arguments: (host2, gds/v1/ipinfo/schema)
[info] at org.scalamock.MockFactoryBase$class.handleUnexpectedCall(MockFactoryBase.scala:129)
..
help?
thanks.