简体   繁体   中英

Unitialized Constant Devise RSPEC

I'm using a Rails 4 App with RSpec and Capybara.

My gemfile looks like:

source 'https://rubygems.org'
gem 'rails', '4.0.0'
gem 'pg'
gem 'devise'
gem 'sass-rails', '~> 4.0.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails'
gem 'jquery-turbolinks'
gem 'turbolinks'
gem "rspec-rails", :group => [:test, :development]
group :test do 
  gem "factory_girl_rails", "~> 4.0"
  gem "capybara"
  gem "guard-rspec"
end

My spec_helper.rb file looks like:

require "capybara/rspec"
include Capybara::DSL

RSpec.configure do |config|
   config.include Devise::TestHelpers, :type => :controller
   config.extend ControllerMacros, :type => :controller
end

But for some reason I'm getting the error: uninitialized constant Devise (NameError) . In my app, Devise is working correctly, though, and I have the ControllerMacros file in spec/support.

try this out:

your spec_helper should be like

ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment",__FILE__)
require 'rspec/rails'
require "capybara/rspec"
include Capybara::DSL

RSpec.configure do |config|
config.include Devise::TestHelpers, :type => :controller
config.extend ControllerMacros, :type => :controller
end

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM