Skip to content
No description, website, or topics provided.
Elixir
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
config
lib
test
.formatter.exs
.gitignore
README.md
mix.exs
mix.lock

README.md

FunWithFlags - InMemory Adapter

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

Installation

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

Configuration

Configure FunWithFlags to use this adapter while in test mode:

# config/test.exs

config :fun_with_flags, :persistence,
  adapter: FunWithFlags.Store.Persistent.InMemory

Usage

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
You can’t perform that action at this time.