EctoFactory v0.0.1 EctoFactory

Summary

Functions

Create a struct of the passed in factory

Functions

build(model_name, attrs \\ %{})

Create a struct of the passed in factory

After configuring a factory

config :ecto_factory, factories: [
  user_with_default_username: { User,
    username: "mrmicahcooper"
  }
]

You can build a struct with the attributes from my factory as defaults.

iex> EctoFactory.build(:user_with_default_username)
%User{
  age: 1,
  username: "mrmicahcooper",
  date_of_birth: Ecto.DateTime.utc
}

And you can pass in your own attributes of course:

iex> EctoFactory.build(:user, age: 99, username: "hashrocket")
%User{
  age: 99,
  username: "hashrocket",
  date_of_birth: Ecto.DateTime.utc
}