0
我周围未初始化的恒定误差strugging与FactoryGirlFactoryGirl未初始化不断
NameError: uninitialized constant Usernotactivated
我已经在我的factories.rb文件
FactoryGirl.define do
factory :usernotactivated do
name "foonotactiv"
email "[email protected]"
password "secretnot"
activated false
end
end
以下,并在我的规格如下
it "should redirect to activation alert when it signs me in with an inactivated account" do
user = FactoryGirl.build(:usernotactivated)
visit login_path
fill_in 'Email', :with => usernotactivated.email
fill_in 'Password', :with => usernotactivated.password
click_button 'Sign in'
expect(page).to have_content 'your account is not activated'
end
在这两个文件中rails_helper.rb和spec_helper.rb我已经添加了这些行:
require 'factory_girl_rails'
我也试过
require 'factory_girl'
不知怎的,我变“usernotactivated”与“用户”我没有得到这个未初始化的常量错误,但我不知道是否是因为“用户”可能是受保护的名称。任何人都可以告诉我应该在哪里调查此问题?你能不能告诉我rails_helper文件(我需要所有规范)和spec_helper文件之间的区别?谢谢。
的API已经改变,语法现在是'factory:user_not_activated,class:User do' – smeshko