我有一个工厂,例如:
FactoryGirl.define do
factory :page do
title 'Fake Title For Page'
end
end
和一个测试:
describe "LandingPages" do
it "should load the landing page with the correct data" do
page = FactoryGirl.create(:page)
visit page_path(page)
end
end
我的 spec_helper.rb 包含:
require 'factory_girl_rails'
但我不断得到:
LandingPages should load the landing page with the correct data
Failure/Error: page = FactoryGirl.create(:page)
NameError:
uninitialized constant Page
# ./spec/features/landing_pages_spec.rb:5:in `block (2 levels) in <top (required)>'
这是一个新项目,所以我不相信测试实际上是问题所在。我相信它可能设置不正确。关于尝试和/或在哪里解决这个问题的任何想法?
我平静的 pages.rb 文件:
class Pages < ActiveRecord::Base
# attr_accessible :title, :body
end