我无法让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'
没有差异
支持/ 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
答案 0 :(得分:1)
您是否注意到错误config.include SessionsHelper, :type => :controller
有会话
,而您的模块module SessionHelpers
有会话