mardi 30 janvier 2018

RSpec: NameError: uninitialized constant

I am new in RSpec and I'd just like to test my controller. I wrote my test that way:

RSpec.describe ServicesController do
  describe "GET index" do
    it "renders the index template" do
      get :index
      expect(response).to render_template("index")
    end
  end
end

But my controller isn't recognized by RSpec, I get this error:

NameError: uninitialized constant ServicesController

In found examples I can find require line, which maybe could solve this problem, but as far as I can see, it concerns only files in lib folder, while my controller path is app/controllers/services_controller.rb. I tried to add it with path ../app/controllers/services_controller.rb, to go out from lib folder, but that doesn't work. What should I do? That's very basic case, but I wasn't able to find any help on the Web.

Aucun commentaire:

Enregistrer un commentaire