Sha256: b48c1ae56e2c4131b78b03bbe1ad33fce9d69c43cca71626e058b27fdb07236b

Contents?: true

Size: 1.62 KB

Versions: 1

Compression:

Stored size: 1.62 KB

Contents

require 'spec_helper'

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
      TokenAction.success_url.should == '/hello/success'
      TokenAction.failure_url.should == '/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
        TokenAction.success_url.should == '/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
        TokenAction.success_url.should == '/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
        TokenAction.failure_url.should == '/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
        TokenAction.failure_url.should == '/hello/failure'
      end
    end
  end

  describe '#friendly_token' do
    it 'should return a random alphanumeric string' do
      TokenAction.friendly_token.should 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.1 spec/token_action_spec.rb