I have a method which returns Either[Exception, String]
class A {
def validate(a: Any) = {
case a: String => Left(...some.. exception)
case a: Any => Right(a)
}
}
class B(a: A) {
def callValidate(any: Any) = {
a.validate(any)
}
}
Now I write tests for class B and I stub method validate
class BTest {
val param: Any = "22"
val a = mock[A]
(a.validate _).expects(param).returning(....someValue...) // . this value should be Right(....) of either function.
}
Is it possible to stub it that way to return Right(.....) of Either
function ?