I have code like the following:
import scalatest.MockFactory
class SomeScalaTest extends FunSpec with MockFactory {
val mockGetXml = mockFunction[String, String, xml.NodeSeq]
val classUnderTest = new SomeClass(..) { override def getXml(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 code that exercises classUnderTest.getXml()
}
}
When I run the test above, I get errors like these:
[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)
[
Any ideas?
thanks,
Evan