-
-
Notifications
You must be signed in to change notification settings - Fork 28
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
Add FactoryGirl integration #17
Conversation
@joshuaclayton @derekprior @gabebw @pbrisbin Mind taking a look at this? |
fill_with_factory(:user, factory_arguments: [:registered, name: 'Frank']) | ||
``` | ||
|
||
Which is roughly equivalent to calling: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
roughly, or exactly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm hesitant to say exactly. The result is the same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then I'd remove "roughly". That word makes me think "What exactly is different, and how is the developer's cleverness going to bite me in a month?" In this case, you're not being Too Clever®, so I'd just remove "roughly".
Introduce optional FactoryGirl syntax that makes it easier to use Formulaic to fill in attributes from a factory with a single argument: `fill_with_factory(:user)`; limit the attributes from a factory: `fill_with_factory(:user, :name, :address)`; and even pass arguments to the factory, such as traits and overrides: `fill_with_factory(:user, :name, :address, factory_arguments: [:with_verified_address]`. Resolves #11.
Which has the same result as calling: | ||
|
||
```ruby | ||
fill_form(:user, attributes_for(:user, :registered, name: 'Frank')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All these examples are well and good, but they make me wonder what the hell the message signature of fill_with_factory
is. Could you get away with showing the signature and then these examples (perhaps with less text explaining each one)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah let me take a run at something like that instead.
Overall looks fine to me. As I mentioned, I'm mostly interested to see how my actual usage patterns with formulaic and factory girl play out to determine what the right choice between factory args and whitelist args is. Is it worth pulling this out into formulaic-factory_girl? I suspect this might be somewhat volatile. Having said that, formulaic itself is only at 0.0.5, so maybe that's premature. |
Introduce optional FactoryGirl syntax that makes it easier to use Formulaic
to fill in attributes from a factory with a single argument:
fill_with_factory(:user)
; limit the attributes from a factory:fill_with_factory(:user, :name, :address)
; and even pass arguments to thefactory, such as traits and overrides:
fill_with_factory(:user, :name, :address, factory_arguments: [:with_verified_address]
.