Rspec 加载支持文件失败

Rspec fails to load support files

我无法rspec加载支持文件,试过:

config.include SessionHelper, :type => :controller

在 spec_helper 文件中,这给了我

NameError: uninitialized constant SessionsSpecHelper

添加:

Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }

给我:

NoMethodError: undefined method `join' for nil:NilClass

添加:

require 'support/session_helpers.rb'

没有区别

support/session_helper.rb:

module SessionHelpers
def sign_up_with(email, password)
  visit sign_up_path
  fill_in 'Email', with: email
  fill_in 'Password', with: password
  click_button 'Sign up'
end

def sign_in
  user = create(:user)
  visit sign_in_path
  fill_in 'Email', with: user.email
  fill_in 'Password', with: user.password
  click_button 'Sign in'
end
end

你注意到错误了吗config.include SessionsHelper, :type => :controller 有会话

而您的模块 module SessionHelpers 有 Session