views:

16

answers:

1

when i run

rake test --trace

here's what happens

** Invoke test (first_time)
** Execute test
** Invoke test:units (first_time)
** Invoke db:test:prepare (first_time)
** Invoke db:abort_if_pending_migrations (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:abort_if_pending_migrations
** Execute db:test:prepare
** Invoke db:test:load (first_time)
** Invoke db:test:purge (first_time)
** Invoke environment 
** Execute db:test:purge
** Execute db:test:load
** Invoke db:schema:load (first_time)
** Invoke environment 
** Execute db:schema:load
** Execute test:units
/usr/bin/ruby1.8 -I"lib:test".... (and after that fails because there's no fixtures loaded)

why doesn't it load fixtures (i thought that would be default behaviour) and how do i make it load fixtures before executing tests???

p.s.

my test/test_helper.rb content is:

ENV["RAILS_ENV"] = "test"
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
require 'test_help'

class ActiveSupport::TestCase
 self.use_transactional_fixtures = true
 self.use_instantiated_fixtures  = false
 fixtures :all
end

(rails 2.3.4)

A: 

rake test loads fixtures if you specify fixtures :all as you did. Is there any problem with the fixtures?

Try to rak rake fixtures:load and check if any error is raised.

Also, I strongly suggest to skip fixtures in favor of factories.

Simone Carletti
thank you for your answer - i just realized that everything executes properly. my problem is that models code is checked before fixtures are loaded, and some of my models validations rely on existing records (like validates_attachment_size :body, :less_than => AdminOptions.first.max_file_size.megabytes).
Pavel K.