Skip to content

Commit

Permalink
fix: fixed a compilation error in the mockito guide
Browse files Browse the repository at this point in the history
  • Loading branch information
symbiont-eric-torreborre committed Jun 18, 2020
1 parent 2b5390a commit a15d57f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions guide/src/test/scala/org/specs2/guide/UseMockito.scala
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ m.get(argThat(===(123))) returns "one"
### Callbacks

In some rare cases, it is necessary to have the return value depend on the parameters passed to the mocked method: ${snippet{
m.get(anyInt) answers { i => "The parameter is " + i.toString }
m.get(anyInt).answers { (i: Any) => "The parameter is " + i.toString }
}}

The function passed to `answers` will be called with each parameter passed to the stubbed method: ${snippet{
Expand All @@ -126,7 +126,7 @@ m.get(1) // the second call returns a different value: "The parameter is 1"
}}

To use specific a type of argument: ${snippet{
m.get(anyInt) answers { _ match { case i: Int => (i + 1).toString } }
m.get(anyInt).answers { (a: Any) => a match { case i: Int => (i + 1).toString } }
}}

Or more concisely: ${snippet{
Expand Down

0 comments on commit a15d57f

Please sign in to comment.