I have used current_user in a helper as following:
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
But how do I test those methods in rspec testing?
I wrote the following rspec code:
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
end end
But it returns the error: NameError:
undefined local variable or method `current_user' for InvestorsHelper:Module
What am I doing wrong?
Aucun commentaire:
Enregistrer un commentaire