Sha256: cabffa479c2d685ed6cade527e47cd0782d1973ab5267d07aff85fddf091b2e1

Contents?: true

Size: 1.66 KB

Versions: 1

Compression:

Stored size: 1.66 KB

Contents

require 'rails_helper'

RSpec.describe TokenAction do
  describe '#setup' do
    before :all do
      TokenAction.setup do |config|
        config.success_url = '/hello/success'
        config.failure_url = '/hello/failure'
      end
    end

    it 'should set the default URLs' do
      expect(TokenAction.success_url).to eq('/hello/success')
      expect(TokenAction.failure_url).to eq('/hello/failure')
    end
  end

  describe '#success_url=' do
    context 'with String argument' do
      before :all do
        TokenAction.success_url = '/hello/success'
      end

      it 'should set the default success URL' do
        expect(TokenAction.success_url).to eq('/hello/success')
      end
    end

    context 'with Proc argument' do
      before :all do
        TokenAction.success_url = lambda { '/hello/success' }
      end

      it 'should set the default success URL' do
        expect(TokenAction.success_url).to eq('/hello/success')
      end
    end
  end

  describe '#failure_url=' do
    context 'with String argument' do
      before :all do
        TokenAction.failure_url = '/hello/failure'
      end

      it 'should set the default failure URL' do
        expect(TokenAction.failure_url).to eq('/hello/failure')
      end
    end

    context 'with Proc argument' do
      before :all do
        TokenAction.failure_url = lambda { '/hello/failure' }
      end

      it 'should set the default failure URL' do
        expect(TokenAction.failure_url).to eq('/hello/failure')
      end
    end
  end

  describe '#friendly_token' do
    it 'should return a random alphanumeric string' do
      expect(TokenAction.friendly_token).to match(/\A[A-Za-z0-9]{20}\z/)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
token_action-0.0.2 spec/token_action_spec.rb