I’ve defined a factory called admin_user but I am getting an error when I try to use it:
factories/user_factory.rb:
FactoryGirl.define do
factory :user do
email "example_user@example"
password "password"
end
factory :admin_user do
email "admin_user@example.com"
password "admin_password"
end
end
authentication_steps.rb:
Given /^I have a valid admin account$/ do
@user = FactoryGirl.create(:admin_user)
end
I am getting the following error when I run that step:
uninitialized constant AdminUser (NameError)
Is there some syntax I’m not following correctly?
Thanks
You should specify the class of
:user_admin:Explanations:
When you use
factory :admin_user do, FactoryGirl looks automatically for the AdminUser class, which doesn’t exist.Thus, you have to tell it which class to use by adding
:class => User.