Reputation: 1644
Here is my factories/admin_user.rb code
FactoryGirl.define do
factory :admin_user do |admin|
admin.sequence(:email) { |n| "admin#{n}@example.com" }
admin.password "123456789"
admin.password_confirmation { |u| u.password }
end
end
When I run this code I got this Error
uninitialized constant FactoryGirl (NameError)
Any Help??
Upvotes: 0
Views: 1731
Reputation: 24815
The problem should be gem not loaded. You can check if FactoryGirl is correctly defined in Gemfile. And also check if ENV is correct as FactoryGirl is supposed to run under Test env.
Add
Maybe test generator is not set correctly? You can check if you have put the following content in config/application.rb
config.generators do |g|
g.test_framework :rspec,
fixtures: true,
view_specs: false,
helper_specs: false,
routing_specs: false,
controller_specs: true,
request_specs: true
g.fixture_replacement :factory_girl, dir: "spec/factories"
end
The last line about fixture should be important to your case. Then you can try to remove your hack setting.
Upvotes: 1