[rspec-devel] Rspec blowing away my initial data
Scott Taylor
mailing_lists at railsnewbie.com
Fri Jun 6 20:52:01 EDT 2008
On Jun 6, 2008, at 4:31 PM, Maurício Linhares wrote:
> This isn't an rspec feature, every time you run your rails app tests
> it will drop the whole database and rebuild it again (based on the
> development database) but only the structure will be copied, no data
> will be copied and no migrations are run.
>
> If you want to add test data to your specs you should use fixtures
> instead or just add your data in a "before" block and remove it in an
> "after" block.
>
Actually, you won't need to destroy it in the after block as long as
you have transactional_fixtures = false in spec_helper.rb
Scott
> On Fri, Jun 6, 2008 at 5:21 PM, weexpectedthis <weexpectedthis at gmail.com
> > wrote:
>>
>> I have this code in the only migration I have in my app:
>>
>> create_table :states do |generic_table|
>> generic_table.with_options :null => false do |t|
>> t.string :name
>> t.datetime :created_at, :updated_at
>> end
>> end
>>
>> State.create!(:name => 'New')
>> State.create!(:name => 'Submitting')
>> State.create!(:name => 'Reviewing')
>> State.create!(:name => 'Implementing')
>> State.create!(:name => 'Finished')
>>
>> When I run `rake test` it builds my test database with the
>> migration I have
>> correctly. But then when I run `rake spec` and look at the
>> database, the
>> initial data (all of the States) are missing.
>>
>> So my questions are:
>> 1) Does rspec blow away my initial data before it runs tests?
>>
>> 2) How can I get it to stop doing that?
>
>
>
> --
> Maurício Linhares
> http://alinhavado.wordpress.com/ (pt-br) | http://
> blog.codevader.com/ (en)
> João Pessoa, PB, +55 83 8867-7208
> _______________________________________________
> rspec-devel mailing list
> rspec-devel at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-devel
More information about the rspec-devel
mailing list