StubbedIOMethod
Representation of stubbed method
CatsEffectStubs interface provides implicit conversion from selected method to StubbedMethodIO.
trait Foo:
def foo0: IO[String]
def foo(x: Int): IO[String]
def bar(x: Int, y: String): IO[Int]
val foo = stub[Foo]
Scala 3
val foo0Stubbed: StubbedMethod[Unit, IO[String]] = foo.foo0
val fooStubbed: StubbedMethod[Int, IO[String]] = foo.foo
val barStubbed: StubbedMethod[(Int, String), IO[Int]] = foo.bar
Scala 2
val foo0Stubbed: StubbedMethod[Unit, IO[String]] = foo.foo0
val fooStubbed: StubbedMethod[Int, IO[String]] = foo.foo _
val barStubbed: StubbedMethod[(Int, String), IO[Int]] = foo.bar _
Attributes
- Graph
-
- Supertypes
-
trait StubbedMethod[A, R]class Objecttrait Matchableclass Any
Members list
Value members
Concrete methods
Returns string representation of method. Representation currently depends on scala version.
Returns string representation of method. Representation currently depends on scala version.
Attributes
Allows to get arguments with which method was executed. Returns multiple arguments as tuple. One list item per call.
Allows to get arguments with which method was executed. Returns multiple arguments as tuple. One list item per call.
Scala 3
for
_ <- foo.foo.returnsIO(x => IO(5))
_ <- foo.foo(1)
_ <- foo.foo(100)
yield foo.foo.calls == List(1, 100) // true
Scala 2
for {
_ <- (foo.foo _).returnsIO(x => IO(5))
_ <- foo.foo(1)
_ <- foo.foo(100)
} yield (foo.foo _).calls == List(1, 100) // true
Attributes
Allows to get arguments with which method was executed. Returns IO
Allows to get arguments with which method was executed. Returns IO
Returns multiple arguments as tuple. One list item per call.
Scala 3
for {
_ <- foo.bar.returnsIO(_ => IO(5))
_ <- foo.bar(1, "foo")
_ <- foo.bar(2, "bar")
calls <- foo.bar.callsIO
} yield calls == List((1, "foo"), (2, "bar")) // true
Scala 2
for {
_ <- (foo.bar _).returnsIO(_ => IO(5))
_ <- foo.bar(1, "foo")
_ <- foo.bar(2, "bar")
calls <- (foo.bar _).callsIO
} yield calls == List((1, "foo"), (2, "bar")) // true
Attributes
Returns true if this method was called after other method.
Returns true if this method was called after other method.
Attributes
Returns true if this method was called before other method.
Returns true if this method was called before other method.
Attributes
Allows raise error for method without arguments. Returns IO.
Allows raise error for method without arguments. Returns IO.
for {
_ <- foo.fooIO.failsWith(1)
} yield ()
Attributes
Allows to set result for method with arguments.
Allows to set result for method with arguments.
Scala 3
foo.bar.returns((x, y) => IO(1))
Scala 2
(foo.bar _).returns((x, y) => IO(1))
Attributes
Allows to set result for method with arguments. Returns IO
Allows to set result for method with arguments. Returns IO
Scala 3
for
_ <- foo.bar.returnsIO((x, y) => IO(1))
yield ()
Scala 2
for {
_ <- (foo.bar _).returnsIO((x, y) => IO(1))
} yield ()
Attributes
Allows to set result depending on call number starting from 1. Returns IO
Allows to set result depending on call number starting from 1. Returns IO
Scala 3
for
_ <- foo.bar.returnsIOOnCall:
case 1 | 2 => IO(0)
case _ => IO(1)
yield ()
Scala 2
for {
_ <- foo.bar.returnsIOOnCall {
case 1 | 2 => IO(0)
case _ => IO(1)
}
} yield ()
Attributes
Allows to set result for method with arguments. Returns IO
Allows to set result for method with arguments. Returns IO
Scala 3
for
_ <- foo.bar.returnsIOWith(IO(1))
yield ()
Scala 2
for {
_ <- (foo.bar _).returnsIOWith(IO(1))
} yield ()
Attributes
Allows to set result depending on call number starting from 1
Allows to set result depending on call number starting from 1
Scala 3
foo.bar.returnsOnCall:
case 1 | 2 => IO(0)
case _ => IO(1)
- Scala 2
(foo.bar _).returnsOnCall {
case 1 | 2 => IO(0)
case _ => IO(1)
}
Attributes
Allows to set result for method with arguments.
Allows to set result for method with arguments.
Scala 3
foo.bar.returnsWith(IO(1))
Scala 2
(foo.bar _).returnsWith(IO(1))
Attributes
Allows to set success for method with arguments. Returns IO.
Allows to set success for method with arguments. Returns IO.
Scala 3
for
_ <- foo.bar.succeedsWith(1)
yield ()
Scala 2
for {
_ <- (foo.bar _).succeedsWith(1)
} yield ()
Attributes
Allows to get number of times method was executed.
Allows to get number of times method was executed.
Scala 3
for
_ <- foo.foo.returnsIO(x => IO(5))
_ <- foo.foo(1)
_ <- foo.foo(100)
yield foo.foo.times == 2 // true
Scala 2
for {
_ <- (foo.foo _).returnsIO(x => IO(5))
_ <- foo.foo(1)
_ <- foo.foo(100)
} yield (foo.foo _).times == 2 // true
Attributes
Allows to get number of times method was executed with specific arguments. Returns IO
Allows to get number of times method was executed with specific arguments. Returns IO
Scala 3
for
_ <- foo.bar.returnsIO(_ => IO(1))
_ <- foo.bar(1, "foo")
_ <- foo.bar(2, "bar")
barTimes <- foo.bar.timesIO
yield barTimes == 2 // true
Scala 2
for {
_ <- (foo.bar _).returnsIO(_ => IO(1))
_ <- foo.bar(1, "foo")
_ <- foo.bar(2, "bar")
barTimes <- (foo.bar _).timesIO
} yield barTimes == 2 // true
Attributes
Allows to get number of times method was executed with specific arguments. Returns IO
Allows to get number of times method was executed with specific arguments. Returns IO
Scala 3
for
_ <- foo.bar.returnsIO(_ => IO(1))
_ <- foo.bar(1, "foo")
_ <- foo.bar(2, "bar")
barTimes <- foo.bar.timesIO((1, "foo"))
yield barTimes == 1 // true
Scala 2
for {
_ <- (foo.bar _).returnsIO(_ => IO(1))
_ <- foo.bar(1, "foo")
_ <- foo.bar(2, "bar")
barTimes <- (foo.bar _).timesIO((1, "foo"))
} yield barTimes == 1 // true
Attributes
Returns a string representation of the object.
Returns a string representation of the object.
The default representation is platform dependent.
Attributes
- Returns
-
a string representation of the object.
- Definition Classes
-
Any
Inherited methods
Allows to get number of times method was executed with specific arguments.
Allows to get number of times method was executed with specific arguments.
Scala 3
foo.foo.returns(_ => 5)
foo.foo(1)
foo.foo.times(1) // 1
foo.foo.times(100) // 0
Scala 2
(foo.foo _).returns(_ => 5)
foo.foo(1)
(foo.foo _).times(1) // 1
(foo.foo _).times(100) // 0
Attributes
- Inherited from:
- StubbedMethod