gpt4 book ai didi

ruby-on-rails - "rake test"不加载灯具?

转载 作者:行者123 更新时间:2023-11-28 20:19:27 26 4
gpt4 key购买 nike

当我运行时

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)

为什么它不加载固定装置(我认为这是默认行为)以及如何让它在执行测试之前加载固定装置???

附:

我的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)

最佳答案

如果您像您一样指定 fixtures :all,则

rake test 会加载 fixture。治具有问题吗?

尝试 rake db:fixtures:load 并检查是否出现任何错误。

此外,我强烈建议跳过固定装置以支持工厂。

关于ruby-on-rails - "rake test"不加载灯具?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2690037/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com