One of the reasons I prefer factories over fixtures is that my tests
express better.
login_user = Factory.create :user
login_as login_user
...
In this case, someone reading this test knows that it only matters that
a user is being created. It shouldn't have any special attributes.
But if I do something like this:
login_user = Factory.create :user, name: 'Rodrigo'
Then I know that the name attribute of the user is relevant for that test.
Another reason is that I only load the records needed by my tests, not
lots of unrelated data that could have some side effect on the tests.
Best,
Rodrigo.
Em 05-07-2012 16:50, DHH escreveu:
I continue to use and love fixtures. I don't see them going anywhere.
I've been entirely unconvinced by all the factory approaches I've seen
so far.
But I'm always willing to look at good before/after code if someone
wants to pitch this further.
On Thursday, July 5, 2012 1:48:45 PM UTC-5, Olek Janiszewski wrote:
Hi guys,
I've noticed the trend of trimming the fat from Rails in
preparation for version 4 (which I appreciate).
Do you think it'd make sense to also remove the test fixtures
engine from Rails 4? From what I've seen, it's now more common to
use more advanced solutions, with FactoryGirl leading the pack,
and it's usually more practical to use Ruby to define fixtures,
rather than YAML.
More specifically:
- would the core team approve of such effort?
- how much work would it mean?
- (related) how tightly are fixtures actually used within Rails'
tests?
It's hard to me to estimate the overall value/cost ratio, but if
it's high enough, I'd be willing to take a shot at it.
--
Bye,
Olek Janiszewski (exviva)
--
You received this message because you are subscribed to the Google Groups "Ruby on
Rails: Core" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-core?hl=en.