-
Notifications
You must be signed in to change notification settings - Fork 146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Idea: Enums #223
Comments
Wouldn't Something like: Enum.random(["owner", "admin", "guest"]) in def role_factory do
%Role{
name: Enum.random(["owner", "admin", "guest"])
}
end |
Yeah, kind of - but I was thinking of cases where you need at least 1 struct for each value. Besides creating a user for each role, another use-case for me is to build a struct per day of the week. def schedule_factory do
%Schedule{
day_of_week: enum(["Sun", "Mon", "Tue", ...]),
start_time: Ecto.Time.cast!("12:00:00Z"),
end_time: Ecto.Time.cast!("3:00:00Z")
}
end The ability to go in order would nice for that situation. |
Please have a look at this PR #227,
|
suhrawardi
added a commit
to suhrawardi/ex_machina
that referenced
this issue
Jun 29, 2017
Looks great! Thanks @suhrawardi. Closing this issue. |
germsvel
pushed a commit
that referenced
this issue
Oct 20, 2017
Can use lists in sequences. Fixes #223 ``` def user_factory do %MyApp.User{ name: "Jane Smith", email: sequence(:email, &"email-#{&1}@example.com"), role: sequence(:role, ["admin", "user", "other"]), } end ```
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It would be great if we could do something like:
which would behave like:
The text was updated successfully, but these errors were encountered: