Why won't my rail work?

When I try to run my spec, I get an uninitialized persistent error. My specification is as follows:

describe Facility do 
  it { should have_many(:units) }
  it { should have_many(:facilities_users) }
  it { should have_many(:administrators) }
  it { should have_many(:facility_employees) }
end

Mistake: facility_spec.rb:1:in `<top (required)>': uninitialized constant Facility (NameError)

Of course, I have a Facility model, so I'm not sure why this will happen.

+2
source share
4 answers

You should try running rake specinstead rspec spec. But both can work.

If you are not working, try bundle exec rspec specor bundle exec rake spec.

Source: When I try to start rspec, I get an uninitialized constant .

+2
source

Add the following to the top of the file:

require 'spec_helper'
0
source

rspec-rails,

rails g rspec:install

spec/spec_helper.rb ( , ActiveRecord, ).

, :

require 'spec_helper'

, , :

  • lib/. , , (config/application.rb → autoload_paths) .
  • . .
0

, Facility.

0

All Articles