Repatch - Everything you need for mocking and patching

Hi, thanks for the feedback, I appreciate it

  1. isolate_env option is an option to isolate application env. That’s to limit the scope of Application.get_env and Application.put_env functions. See Repatch.Application — Repatch v1.6.1
  2. You should pass a mode option to the expect call, like
    expect(Date, :utc_today, [mode: :shared, exactly: 2], fn -> ~D[2023-04-06] end)
    

So

  • I will improve the documentation about this isolate_env option.

  • And since I can see that you wanted to pass the default mode option on the use Repatch.ExUnit I think I will consider something like default_mode option, but I my biggest argument against this is that it is less explicit and reader of the test will be confused if this patch is local, shared or global unless they check one of the many line in the head of the module

    Perhaps I can implement some setup in the use Repatch.ExUnit to take the mode from test tag, like

    @tag repatch_mode: :shared
    test "..." do
      Repatch.patch(DateTime, :utc_now, fn -> :ok end) # <- this patch is shared mode now
    end
    

Share your ideas if you have any

2 Likes