我正在尝试在 Ruby on Rails 中使用 Test::Unit 和 Shoulda 设置 Factory Girl。我已经安装了 gem,在 test/factories 目录下创建了我的工厂文件,并在 test/models 目录下创建了我的规范文件。我得到的当前错误是“ArgumentError:没有这样的工厂:测试”,这让我相信 test_factory.rb 文件没有被加载?关于我应该改变什么的任何想法?
这是我的文件。
#test/factories/test_factory.rb
Factory.define :test do |t|
t.name 'test_spotlight'
t.label 'test spotlight label'
end
和
#test/modes/test_spec.rb
require 'test_helper'
require 'factory_girl'
class TestTest < Test::Unit::TestCase
def setup
@test = Factory.build(:test)
end
context "A test" do
should "save with the minimum requirements" do
assert @test.save
end
end
end