An adapter for fun_with_flags
that uses a GenServer to keep everything in memory.
Useful for unit testing your code without having to mock FunWithFlags
If available in Hex, the package can be installed
by adding fun_with_flags_in_memory
to your list of dependencies in mix.exs
:
def deps do
[
{:fun_with_flags_in_memory, "~> 0.1.0"}
]
end
Configure FunWithFlags
to use this adapter while in test mode:
# config/test.exs
config :fun_with_flags, :persistence,
adapter: FunWithFlags.Store.Persistent.InMemory
The adapter doesn't clean up by itself automatically after each test.
The current aproach is to manually clean up each flag. For example:
defmodule Tests do
describe "a disabled feature" do
setup do
Flags.enable(:my_feature_flag)
on_exit fn ->
Flags.clear(:my_feature_flag)
end
end
end
end