Note that there are some explanatory texts on larger screens.

plurals
  1. POFactory Girl: NameError unintialized constant for one of the factories
    primarykey
    data
    text
    <p>So I have a strange problem where I have 3 factories declared out of which only 1 factory is intialized fine and rest of them are giving Unintialized constant. I don't know what I am doing wrong. I know this question has been asked so many times, but none of the answers are solving my problem.</p> <p>here is my spec/factories/sample_factory.rb</p> <pre><code>require 'faker' FactoryGirl.define do factory :early_access do email {Faker::Internet.email} end factory :login do email {Faker::Internet.email} password "password" end factory :user do display_name {Faker::Internet.name} email {Faker::Internet.email} username {Faker::Internet.username} password "password" end </code></pre> <p>here is the model spec file spec/models/sample.rb</p> <pre><code>require 'spec_helper.rb' describe EarlyAccess do it "has a valid factory" do FactoryGirl.build(:early_access).should be_valid end it "has a valid factory login" do FactoryGirl.build(:login).should be_valid end end it "has valid factory user" do FactoryGirl.build(:user).should be_valid end end </code></pre> <p>Out of these, only first one <code>early_access</code> passes and rest of them fail</p> <pre><code>.FF Failures: 1) EarlyAccess has a valid factory 2 Failure/Error: FactoryGirl.build(:login).should be_valid NameError: uninitialized constant Login # ./spec/models/sample.rb:10:in `block (2 levels) in &lt;top (required)&gt;' 2) EarlyAccess has valid factory user Failure/Error: NameError: uninitialized constant User # ./spec/models/sample.rb:16:in `block (2 levels) in &lt;top (required)&gt;' </code></pre> <p>I have included factory_girl_rails in my spec_helper.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload