Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/edisonywh/manu
Manu is a proof-of-concept to see how would it look like to use changesets in Ecto tests.
https://github.com/edisonywh/manu
Last synced: 8 days ago
JSON representation
Manu is a proof-of-concept to see how would it look like to use changesets in Ecto tests.
- Host: GitHub
- URL: https://github.com/edisonywh/manu
- Owner: edisonywh
- Created: 2020-06-20T05:27:39.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-06-20T05:30:12.000Z (over 4 years ago)
- Last Synced: 2023-03-02T23:25:57.182Z (almost 2 years ago)
- Language: Elixir
- Size: 4.88 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Manu
## WARNING 🚨: Manu is a proof-of-concept to see how it would look like to use changesets with our test factories.
Manu allow you to create your test data and associations with custom changesets.
# Why Manu?
ExMachina is the popular alternative, but it does not come with good changeset support, and that is what Manu is trying to solve.
Disclaimer: I am not a heavy user of ExMachina so perhaps there are ways/patterns to make it work, I just find it peculiar that people seem to dislike it and I'd like to understand why and maybe start a conversation around it.
For reference: https://github.com/thoughtbot/ex_machina/pull/78
# What does Manu do different from ExMachina?
- Everything is validated with changesets.
- Encourages use of changesets, which is good to do.
- Allows you to specify a changeset to be used while building a struct.# Cons
- Usage can potentially get ugly, for example, the calls can look like so:
- build(User)
- build(User, :default)
- build(User, :with_gmail)
- build(User, :default, %{name: "new_name"})
- build(User, :default, %{}, with: &User.email_changeset/2)# Caveat
- Take `cast_assoc` and `put_assoc` for example, `cast` expects a map and `put` expects a struct, Manu follows the same way, so you need to be mindful about using `build` vs `params_for`.# Example
For examples, look over in `manu_tests.exs`