1
我有一個助手使用CURRENT_USER如下:如何訪問測試(設計)助手中的current_user?
module InvestorsHelper
def single?
binding.pry
current_user.kyc.marital_status == 'Single'
end
def married?
current_user.kyc.marital_status == 'Married'
end
def politically_exposed?
current_user.kyc.is_politically_exposed.present?
end
def tax_residency?
current_user.kyc.is_tax_residency.present?
end
end
但是我怎麼測試在rspec的測試那些方法?
我寫了下面的代碼的RSpec:
context "Investors Helper" do
before(:each) do
puts "Befpre exljfgd"
current_user = @user ||= FactoryGirl.create(:user)
@kyc ||= FactoryGirl.create(:kyc, user_id: @user.id)
end
describe InvestorsHelper, '#single?' do
it 'returns status of current user' do
result = InvestorsHelper.single?
binding.pry
end
end
末 結束
但它返回的錯誤:NameError:
undefined local variable or method `current_user' for InvestorsHelper:Module
我在做什麼錯?