File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed
Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -459,7 +459,14 @@ defmodule Mimic do
459459 ```
460460 """
461461 @ spec set_mimic_global ( map ( ) ) :: :ok
462- def set_mimic_global ( _context \\ % { } ) , do: Server . set_global_mode ( self ( ) )
462+ def set_mimic_global ( _context \\ % { } )
463+
464+ def set_mimic_global ( % { async: true } ) do
465+ raise "Mimic cannot be set to global mode when the ExUnit case is async. " <>
466+ "If you want to use Mimic in global mode, remove \" async: true\" when using ExUnit.Case"
467+ end
468+
469+ def set_mimic_global ( _context ) , do: Server . set_global_mode ( self ( ) )
463470
464471 @ doc """
465472 Chooses the mode based on ExUnit context. If `async` is `true` then
Original file line number Diff line number Diff line change @@ -1280,4 +1280,11 @@ defmodule Mimic.Test do
12801280 end
12811281 end
12821282 end
1283+
1284+ describe "set_mimic_global/1" do
1285+ test "raises if the test case is async" do
1286+ message = ~r/ Mimic cannot be set to global mode when the ExUnit case is async/
1287+ assert_raise RuntimeError , message , fn -> set_mimic_global ( % { async: true } ) end
1288+ end
1289+ end
12831290end
You can’t perform that action at this time.
0 commit comments