Skip to main content

I have an error of the following form and I am unable to point out the error.

Testing • Asked by Ananya Singh
 Unable to autoload constant CONSTANT_NAME, expected TESTING_FILE_PATH to define it

Without more information and background on what you're doing it's hard to say.  A google search turns up a ton of SO articles on this, some related to testing, some not.  Can you give more detail?

Following is the whole error:
An error occurred while loading ./spec/models/completed_lesson_spec.rb.
Failure/Error:
  RSpec.describe Completed_lesson, type: :model do
    it "has a user_id" do
      completed_lesson = Completed_lesson.create!(user_id: 1)

      second_completed_lesson = Completed_lesson.create!(user_id: 2)

       expect(second_completed_lesson.user_id).to eq(2)
    end
  end

LoadError:
  Unable to autoload constant Completed_lesson, expected C:/Sites/SM-rails/app/models/completed_lesson.rb to define it
# ./spec/models/completed_lesson_spec.rb:3:in `<top (required)>'
No examples found.

Change your class name from `Completed_lesson` to 
CompletedLesson
Its a naming convention in Rails.

Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 24,647+ developers who get early access to new screencasts, articles, guides, updates, and more.

    By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

    More of a social being? We're also on Twitter and YouTube.