我跑的时候
rake test --trace
这是发生的事情
** 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)
为什么它不加载灯具(我认为这将是默认行为)以及如何在执行测试之前使其加载灯具???
P.S。
我的test / test_helper.rb内容是:
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)
答案 0 :(得分:5)
rake test
,则 fixtures :all
会加载灯具。
夹具有什么问题吗?
尝试rake db:fixtures:load
并检查是否有任何错误。
另外,我强烈建议跳过固定装置以支持工厂。