Sha256: 0f7cc1caad6aaf74e5bfed75054563306a03900d9bf5f4594732c9ca53ad2028

Contents?: true

Size: 777 Bytes

Versions: 5

Compression:

Stored size: 777 Bytes

Contents

require 'spec_helper'

describe Foyer::Grape::Helpers do
  class IncludesFoyerGrapeHelpers
    def headers
      @headers ||= { 'Authorization' => 'Bearer _' }
    end

    include Foyer::Grape::Helpers
  end

  subject { IncludesFoyerGrapeHelpers.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

5 entries across 5 versions & 1 rubygems

Version Path
foyer-0.5.0 spec/foyer/grape/helpers_spec.rb
foyer-0.4.0 spec/foyer/grape/helpers_spec.rb
foyer-0.3.1 spec/foyer/grape/helpers_spec.rb
foyer-0.2.2 spec/foyer/grape/helpers_spec.rb
foyer-0.2.1 spec/foyer/grape/helpers_spec.rb