EctoFactory (EctoFactory v0.2.3) View Source
Link to this section Summary
Functions
Create a map with randomly generated of the passed in Ecto schema. The keys of this map are Strings
Create a map with randomly generated of the passed in Ecto schema. The keys of this map are atoms
Generate a random value. gen/1 will return a value of the atom or tuple to pass it.
Create a struct of the passed in factory
Link to this section Functions
Specs
Create a map with randomly generated of the passed in Ecto schema. The keys of this map are Strings
Specs
Create a map with randomly generated of the passed in Ecto schema. The keys of this map are atoms
Specs
gen(atom() | tuple()) :: integer() | binary() | float() | boolean() | list() | Time | NaiveDateTime | Date | DateTime
Generate a random value. gen/1 will return a value of the atom or tuple to pass it.
Specs
Create a struct of the passed in factory
After configuring a factory
config :ecto_factory, factories: [
user: User,
user_with_default_username: { User,
username: "mrmicahcooper"
}
]You can build a struct with the attributes from your factory as defaults.
EctoFactory.schema(:user_with_default_username)
%User{
age: 124309132# random number
username: "mrmicahcooper"
}And you can pass in your own attributes of course:
EctoFactory.schema(:user, age: 99, username: "hashrocket")
%User{
age: 99,
username: "hashrocket"
}