Sha256: b0e90772ab7c464bb3e77cf61ec818fadbc00b78257256bf16701567dc51377e

Contents?: true

Size: 858 Bytes

Versions: 3

Compression:

Stored size: 858 Bytes

Contents

# frozen_string_literal: true

require 'rails_helper'

RSpec.describe '#idy_decode' do
  context 'with no given salt' do
    it 'undos the obfuscation of id with default class salt' do
      expect(Article.idy_decode('My')).to eq 1
    end
  end

  context 'with empty salt' do
    let!(:salt) { '' }

    it 'undos the obfuscation of id with given salt' do
      expect(Article.idy_decode('jR', salt: salt)).to eq 1
    end
  end

  context 'with salt' do
    context 'as string' do
      let!(:salt) { 'salt' }

      it 'undos the obfuscation of id with given salt' do
        expect(Article.idy_decode('XG', salt: salt)).to eq 1
      end
    end

    context 'as number' do
      let!(:salt) { 1 }

      it 'undos the obfuscation of id with given salt as string' do
        expect(Article.idy_decode('kL', salt: 1)).to eq 1
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
idy-0.1.3 spec/lib/idy/extension/idy_decode_spec.rb
idy-0.1.2 spec/lib/idy/extension/idy_decode_spec.rb
idy-0.1.1 spec/lib/idy/extension/idy_decode_spec.rb