I am running into a "undefined method `setup' for Object:Class (NoMethodError)" when testing with Rails. I am getting this error when running any of my tests.
I am using the test setup from the Ruby on Rails Tutorial and in addition have included Devise::Test::IntegrationHelpers (for integration tests) and Devise::Test::ControllerHelpers (for controller tests) in my test files.
This is the error I am getting: .rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/devise4.4.3/lib/devise/test/controller_helpers.rb:30:in block in <module:ControllerHelpers>': undefined method
setup' for Object:Class (NoMethodError)
This is the line from the controller_helpers file the error refers to:
module Devise
module Test
module ControllerHelpers
extend ActiveSupport::Concern
included do
setup :setup_controller_for_warden, :warden
end
.
.
.
These are my test gems:
group :test do
gem 'rails-controller-testing', '1.0.2'
gem 'minitest-reporters', '1.1.14'
gem 'guard', '2.13.0'
gem 'guard-minitest', '2.4.4'
end
This is my test_helper.rb file:
ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
require "minitest/reporters"
Minitest::Reporters.use!
class ActiveSupport::TestCase
fixtures :all
end
This is one of my tests:
require 'test_helper'
class UsersControllerTest < ActionController::TestCase
include Devise::Test::ControllerHelpers
setup do
@user = users(:one)
end
test "should get index" do
get users_url
assert_response :success
end
test "should get new" do
get new_user_url
assert_response :success
end
.
.
.
end
Any help with this issue would be appreciated. Thank you.
Aucun commentaire:
Enregistrer un commentaire