【发布时间】:2011-09-16 06:56:12
【问题描述】:
这是我的问题。如果我使用 ruby 命令运行测试,则测试全部通过。但是,如果我使用 rake test:functionals,它们都会失败并出现以下错误。我不确定在使用 rake 任务时我必须采取哪些不同的措施才能让他们通过,但我非常感谢您提供的任何指导。
#tasks_controller_test.rb
require File.dirname(__FILE__) + '/../test_helper'
class TasksControllerTest < ActionController::TestCase
set_fixture_class :Action => 'Task'
fixtures :Action
setup :initialize_test
test "the truth" do
assert true
end
private
def initialize_test
@user = users :one
sign_in @user
@user.confirm!
@task = Action :one # Here's the line that is throwing the error.
end
end
1) Error:
test_the_truth(TasksControllerTest):
FixtureClassNotFound: No class attached to find.
test/functional/tasks_controller_test.rb:20:in `initialize_test'
【问题讨论】:
-
如果我理解正确,您有一个
Task模型,其表名为Action。这意味着您应该拥有app/models/task.rb和test/fixtures/Action.yml(或csv)。我说对了吗?
标签: ruby-on-rails-3 functional-testing