Sha256: c7484001d5178a8ed772f1d00b8eb3145e93e19da76e3885392642eff198f87e

Contents?: true

Size: 825 Bytes

Versions: 4

Compression:

Stored size: 825 Bytes

Contents

# frozen_string_literal: true

RSpec.describe Authorizy::Config, '#redirect_url' do
  let!(:config) { described_class.new }

  context 'when uses default value' do
    context 'when context responds to root_url' do
      let!(:context) { OpenStruct.new(root_url: '/root') }

      it 'is called' do
        expect(config.redirect_url.call(context)).to eq('/root')
      end
    end

    context 'when context does not respond to root_url' do
      let!(:context) { 'context' }

      it 'returns just a slash' do
        expect(config.redirect_url.call(context)).to eq('/')
      end
    end
  end

  context 'when uses custom value' do
    it 'executes what you want' do
      config.redirect_url = ->(context) { context[:value] }

      expect(config.redirect_url.call({ value: 'value' })).to eq('value')
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
authorizy-0.3.0 spec/authorizy/config/redirect_url_spec.rb
authorizy-0.2.2 spec/authorizy/config/redirect_url_spec.rb
authorizy-0.2.1 spec/authorizy/config/redirect_url_spec.rb
authorizy-0.2.0 spec/authorizy/config/redirect_url_spec.rb