【发布时间】:2013-01-18 00:00:02
【问题描述】:
我有一个工厂,例如:
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
【问题讨论】:
标签: ruby-on-rails ruby-on-rails-3 rspec2 factory-bot