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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With