ExMachina strategy for Mnemonics.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
config
lib
test
.credo.exs
.formatter.exs
.gitignore
.travis.yml
LICENSE
README.md
mix.exs
mix.lock

README.md

Mnemonics.ExMachina

ExMachina strategy for Mnemonics.

Hex.pm Build Status

Usage

Just like ExMachina.Ecto. Instead of use ExMachina or use ExMachina.Ecto, we add use Mnemonics.ExMachina.

Currently we need an id column.

defmodule Example do
  use Mnemonics, table_name: :examples

  defstruct id: "0"
end

defmodule ExampleFactory do
  use Mnemonics.ExMachina

  def example_factory, do: %Example{id: sequence("")}
end

defmodule ExampleTest do
  import ExampleFactory

  use ExUnit.Case

  test "insert" do
    example = insert(:example)
    assert [{example.id, example}] === :ets.lookup(Example.table_name(), example.id)
  end
end

Document.

Installation

Add :mnemonics_ex_machina at mix.exs :

def deps do
  [
    {:mnemonics_ex_machina, "~> 0.2"}
  ]
end