Skip to content

Commit

Permalink
fix ScalaMocks#withExpectations and use the new trait in our tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fmonniot committed Dec 9, 2023
1 parent c01ebd5 commit c9f29e2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
9 changes: 8 additions & 1 deletion core/src/main/scala/eu/monniot/scala3mock/ScalaMocks.scala
@@ -1,5 +1,7 @@
package eu.monniot.scala3mock

import eu.monniot.scala3mock.context.MockContext

object ScalaMocks extends ScalaMocks

/** Helper trait that provide access to all components (mandatory or optional)
Expand All @@ -10,4 +12,9 @@ trait ScalaMocks
with macros.Mocks
with matchers.Matchers:

export main.withExpectations
// apparently using export in 3.2.2 lose the default value of the
// parameter. That might have been fixed in 3.3+, but we can't use
// that version so for now we will duplicate the definition.
def withExpectations[A](verifyAfterRun: Boolean = true)(
f: MockContext ?=> A
): A = main.withExpectations(verifyAfterRun)(f)
15 changes: 3 additions & 12 deletions core/src/test/scala/eu/monniot/scala3mock/mock/MockSuite.scala
@@ -1,19 +1,10 @@
package mock

import eu.monniot.scala3mock.main.withExpectations
import eu.monniot.scala3mock.functions.MockFunctions
import eu.monniot.scala3mock.main.TestExpectationEx
import eu.monniot.scala3mock.matchers.MatchAny
import eu.monniot.scala3mock.macros.*
import fixtures.*
import eu.monniot.scala3mock.handlers.CallHandler1
import eu.monniot.scala3mock.functions.MockFunction1
import eu.monniot.scala3mock.context.MockContext
import eu.monniot.scala3mock.ScalaMocks
import eu.monniot.scala3mock.main.Default
import fixtures.*

class MockSuite extends munit.FunSuite with MockFunctions {

def * = new MatchAny
class MockSuite extends munit.FunSuite with ScalaMocks {

case class TestException() extends RuntimeException
case class AnotherTestException() extends RuntimeException
Expand Down

0 comments on commit c9f29e2

Please sign in to comment.