EctoFactory v0.1.0 EctoFactory View Source
Link to this section Summary
Functions
Create a map with randomly generated of the passed in Ecto schema
generate a random value
Create a struct of the passed in factory
Link to this section Functions
Create a map with randomly generated of the passed in Ecto schema
generate a random value
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"
}