I'm using rspec-rails (3.7.1)
with rails (5.1.4)
All the tests run successfully, but after adding namespace to routes.rb
file, I got this error:
An error occurred while loading ./spec/controllers/stores_controller_spec.rb.
Failure/Error:
RSpec.describe StoresController, type: :controller do
NameError:
uninitialized constant StoresController
and this is my routes.rb
file:
namespace 'api' do
namespace 'v1' do
resources :stores
end
end
where my stores_controller_spec.rb
is
require 'rails_helper'
RSpec.describe StoresController, type: :controller do
let(:store) { FactoryBot.create(:store) }
describe "GET index" do
it 'has a 200 status code' do
request.headers.merge!(auth_headers)
get :index
expect(response.status).to eq(200)
end
end
end
Api::V1::StoresController
. - Jagdeep Singh