Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 240
the_ Avatar asked Jun 13 '14 03:06

the_


1 Answers

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
like image 55
Sachin Singh Avatar answered Oct 03 '22 01:10

Sachin Singh