1
votes

I am using Ruby on Rails 3.2.2, cucumber-rails-1.3.0 and rspec-rails-2.8.1. Since I have some "system" data stored in the database, and since I would like to test my application that needs that data in order to properly work, I would like to seed the test database before to run Cucumber features.

How can I make that? What do you advice about?

2
that depends largelt on your deployment ands testing process and toools. FOr instance i use simple groovy scripts to dump some SQL into my database when it starts. - Eddie
@Eddie - What are those "groovy scripts"? Where I should put those? - Backo

2 Answers

0
votes

Rails has a feature called Fixtures which prepopulates the test database before testing. Fixtures uses YAML to seed a table of the same name with data.

The Ruby on Rails guides have a low down on fixtures that may be beneficial to have a look at.

0
votes

Thare is also FactoryGirl. It can read from any place but generally uses features/factories.rb or features/factories/*.rb

See RailsCast 275. Ryan uses it with RSpec, but the principles are the same. Note FactoryGirl has had a major revision since then, so all the API has evolved.