Requiring records in the DB before testing

Is there any way I can require a small set of data be in the test
database before any tests are run? (unit, functional, integration,
cucumber, etc)
Any way besides using fixtures, that is.
Overload a rake task?
Modify test_helper?
Any ideas?
(Simple Case: I have to have a minimal set of user roles defined
before any users can be created)

Look at rake db:seed as one alternative.

Steve R. wrote:

On Jan 29, 2010, at 11:22 AM, kkohrt wrote:

Is there any way I can require a small set of data be in the test
database before any tests are run? (unit, functional, integration,
cucumber, etc)
Any way besides using fixtures, that is.
Overload a rake task?
Modify test_helper?
Any ideas?
(Simple Case: I have to have a minimal set of user roles defined
before any users can be created)

I use fixture replacements such as Fixjour or machinist. So,

1.upto(10) do
Model.make # Machinist
end

That sort of thing. It’s good to put in a setup step.

Yes, factories are generally the best solution.

Best,

Marnen Laibow-Koser
http://www.marnen.org
[email protected]

Hi
Chek this
http://github.com/thoughtbot/factory_girl

and its RDoc at
http://rdoc.info/projects/thoughtbot/factory_girl

Sijo

On Jan 29, 2010, at 11:22 AM, kkohrt wrote:

Is there any way I can require a small set of data be in the test
database before any tests are run? (unit, functional, integration,
cucumber, etc)
Any way besides using fixtures, that is.
Overload a rake task?
Modify test_helper?
Any ideas?
(Simple Case: I have to have a minimal set of user roles defined
before any users can be created)

I use fixture replacements such as Fixjour or machinist. So,

1.upto(10) do
Model.make # Machinist
end

That sort of thing. It’s good to put in a setup step.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs