I'm trying to run a test file for a controller, but I'm running into this error:
/home/mariana/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:274:in `require': cannot load such file -- ./controllers/users_controller (LoadError)
I think rspec can't find the actual files it's supposed to test.
The test file, users_controller_spec.rb:
require 'rails_helper'
require './controllers/users_controller'
describe UsersController do
describe '#create' do
...
end
end
The header/preamble of rails_helper.rb, that deals with file paths (I think):
ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../../config/environment', __FILE__)
abort("The Rails environment is running in production mode!") if Rails.env.production?
require 'spec_helper'
require 'rspec/rails'
The section of the Gemfile that deals with rspec and development/test-specific stuff:
group :development, :test do
gem 'spring'
gem 'rspec', '~>3.5'
gem 'rspec-rails', '~>3.5'
end
The project tree:
->project
->app
->controllers
->users_controller.rb
->spec
->controllers
->users_controller_spec.rb
I've tried messing around with the require File.expand_path(...) line on rails_helper.rb. I also tried adding the rspec gem to the Gemfile alongside rspec-rails (the problem also existed when it was just rspec-rails).
Any suggestions?
Aucun commentaire:
Enregistrer un commentaire