edgurgel / mimic

A mocking library for Elixir
https://hexdocs.pm/mimic
Apache License 2.0
426 stars 34 forks source link

Provide a way to raise an error when calling a copied function #19

Closed vinibrsl closed 4 months ago

vinibrsl commented 4 years ago

When mocking external service calling modules, such as HTTP and gRPC, we might not want to these to be called without being mocked.

It would be nice to have a way to configure Mimic to raise an error when calling a copied function, such as WebMock (https://github.com/bblimke/webmock) does on Ruby with WebMock.disable_net_connect!, to block real web requests.

edgurgel commented 4 years ago

One way to achieve this today is creating a common test case using ExUnit.CaseTemplate and calling stub(TheModule). Then you just have to ensure that your tests are using this test case.

If we change Mimic to stub on copy we would probably need to have a way to "reset" and remove the stub as users may want to execute the original functions for some tests but stub for the majority? 🤔

dylan-chong commented 2 years ago

stale?