rake test:units / test:functionals blasts the test database away and
rebuilds the schema from the development database (aka, no data). This does
*not* use migrations; it uses db/schema.rb. If you want data in the test db,
you need to either use fixtures or manually create the data in your tests
(basically the same thing, when you think about it).
Jason
On 4/16/07, nuno
<rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:>
>
> Hello, even after several months of Rails development I''m still
facing
> few problems with unit testing.
>
> 1) Inserting records during migration
>
> My migration.rb is
> def self.up
> create_table :rubriques do |t|
> t.column "libelle", :string
> t.column "rubrique_id", :integer
> t.column "visible", :boolean
> end
>
> Rubrique.create(:libelle => ''root'', :rubrique_id =>
nil, :visible =>
> true)
> end
>
> Problem is : the ''root'' record is never inserted in the
test database
> even when using rake db:migrate RAILS_ENV="test" or rake
test:purge and
> then rake test:units
>
> Why ? No idea
>
> 2) Second common problem :
> I use fixtures which are loaded accordingly during unit testing. But
> when running functional tests which don''t use any :fixtures
statement,
> it''s common to have the fixtures datas still loaded in the test
> database.
> The only solution I found was adding delete_existing_fixtures() in the
> setup() method... No the ''right'' way in my point of
view...
>
>
>
>
> Any help appreciated, thank you !
>
> --
> Posted via http://www.ruby-forum.com/.
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---