Hello, when passing the test an uninitialized constant Devise :: Test (NameError) error occurs. I added lines to spec_hepler and rails_helper:

config.include Devise::Test::ControllerHelpers, type: :controller config.include Devise::Test::ControllerHelpers, type: :view 

Test:

 require 'spec_helper' include Devise::Test::ControllerHelpers RSpec.describe CommentsController do describe "create action" do @user = User.where(email: "123123@test.com") sign_in @user it "redirect to place_path if place is save" do post :create, comment: { body: "Comment test body", user_id: 1 } response.should redirect_to place_path(assigns(:comment)) end it "redirect to rot_path if validation fail" do post :create, comment: { body: "", user_id: 1 } response.should redirect_to root_path end end end 

Rspec - 3.4.4

Devise - 4.1.0

spec_helper

 ENV["RAILS_ENV"] ||= 'test' require File.expand_path("../../config/environment", __FILE__) require 'rspec/rails' require 'rspec/autorun' RSpec.configure do |config| config.include FactoryGirl::Syntax::Methods config.raise_errors_for_deprecations! config.infer_spec_type_from_file_location! config.include Devise::Test::ControllerHelpers, type: :controller config.include Devise::Test::ControllerHelpers, type: :view config.expect_with :rspec do |expectations| expectations.include_chain_clauses_in_custom_matcher_descriptions = true end config.mock_with :rspec do |mocks| mocks.verify_partial_doubles = true end end 
  • spec_helper and rails_helper . Most likely, nothing inside the test is known about Devise - MAXOPKA
  • What version of Rspec and devise ? - anoam
  • + In the specs of the current RSpec , it seems to include rails_helper and not spec_helper . - anoam
  • 2
    There is no such module in Devise 4.1. Read the documentation , and it is to your version . - D-side
  • Thanks, corrected. - Maxim Cherevatov

1 answer 1

Corrected the error using the documentation for the desired version of Devise.

Lines in speck_helper:

  config.include Devise::Test::ControllerHelpers, type: :controller config.include Devise::Test::ControllerHelpers, type: :view 

Replaced with:

  config.include Devise::TestHelpers, type: :controller config.include Devise::TestHelpers, type: :view 

Also in the test itself

  include Devise::Test::ControllerHelpers 

Replaced by

  include Devise::TestHelpers 
  • Although the link can find the answer to the question, it is better to point out the most important thing here, and give the link as a source. If the page to which the link leads will be changed, the response link may become invalid. - From the queue of checks - Alex
  • @Alex corrected) - Maxim Cherevatov