Releases: sonerdy/double
v0.8.2
Allow concurrent eval
This helps to eliminate a bottleneck for highly concurrent usage of the library.
v0.7.0
This release adds the new stub syntax which is a great improvement over the old double/allow syntax. stub
combines both into one function now:
dbl = ModuleOrBehavior
|> stub(:function_name, fn(x) -> x end)
|> stub(:another_function, fn(x) -> x end)
dbl.function_name("hello")
assert_receive({ModuleOrBehavior, :function_name, ["hello"]})
You'll notice that the message now contains the module or behavior atom that the stub is built against. This prevents conflicts w/ function names between different modules and is another improvement that the stub
syntax provides.
The old double/allow syntax is no longer documented, but isn't marked as deprecated yet. We may consider that in the future, or maybe even dropping support for it in version 1.0.
For more details on the new syntax, please read the docs!
v0.6.6
v0.6.5
This is only a documentation update.
v0.6.4
Fixes warnings for Elixir 1.6 and applies new built-in code formatter. Credit to @take-five
v0.6.3
This release includes a fix for the typespec on allow/3
.
v0.6.2
This release fixes an issue with verifications on module based doubles that have macros. Macros can now be stubbed whereas they would have thrown a verification error before.
For example, Logger.info/1 is a macro that you can now stub and it will be properly verified.
logger_stub = Logger
|> double()
|> allow(:info, fn(_msg) -> :ok end)
v0.6.1
This release will start essential Double services as part of an OTP application. This should help with with intermittent errors with starting and stopping services. Thanks @take-five!
v0.6.0
Clearing Stubbed Functions
Occasionally it's useful to clear the stubs for an existing double. This is useful when you have
a shared setup and a test needs to change the way a double is stubbed without recreating the whole thing.
stub = IO
|> double
|> allow(:puts, fn(_) -> :ok end)
|> allow(:inspect, fn(_) -> :ok end)
# later
stub |> clear(:puts) # clear an individual function
stub |> clear([:puts, :inspect]) # clear a list of functions
stub |> clear() # clear all functions