Sha256: 74be78292912bddf1dcaf515c987690a4c26f7c335e88d51dca2ba09a34e92e7

Contents?: true

Size: 778 Bytes

Versions: 3

Compression:

Stored size: 778 Bytes

Contents

require 'spec_helper'

describe Foyer::API::Helpers do
  class IncludesFoyerAPIHelpers
    def request
      @request ||= Struct.new(:authorization).new('Bearer _')
    end

    include Foyer::API::Helpers
  end

  subject { IncludesFoyerAPIHelpers.new }

  describe '.set_token_finder' do
    it 'sets the :token_finder configuration to the provided block' do
      expect do
        subject.class_eval do
          set_token_finder do |token|
            token
          end
        end
      end.to change(Foyer, :token_finder)
    end
  end

  describe '#current_user' do
    it 'calls the token_finder method' do
      @called = false
      Foyer.token_finder = ->(_) { @called = true }

      subject.send :current_user

      expect(@called).to eq true
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
foyer-0.5.0 spec/foyer/api/helpers_spec.rb
foyer-0.4.0 spec/foyer/api/helpers_spec.rb
foyer-0.3.1 spec/foyer/api/helpers_spec.rb