mercredi 20 janvier 2016

Testing current user in helper spec

I have this pretty basic helper which relies on current_user variable provided by Sorcery in controllers and helpers

def current_user_link
    user_link current_user
end

How can I test this helper?

describe UsersHelper do
  describe '#current_user_link' do
    it 'should return a link to the current user' do
      expected_link = link_to current_user.name, current_user
      ???

      expect(current_user_link).to eq expected_link
    end
  end

Do I need to stub current_user somehow? Is it even worth testing?

Aucun commentaire:

Enregistrer un commentaire