Sha256: 98d5aa6d08b5b21973a74bb79f9ec796d6d2a56871265b849c44828d1fd8533c

Contents?: true

Size: 909 Bytes

Versions: 1

Compression:

Stored size: 909 Bytes

Contents

# frozen_string_literal: true

require 'rails_helper'

RSpec.describe Article, '#idy_decode' do
  context 'with no given salt' do
    it 'undos the obfuscation of id with default class salt' do
      expect(described_class.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(described_class.idy_decode('jR', salt: salt)).to eq 1
    end
  end

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

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

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

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
idy-1.1.0 spec/lib/idy/extension/idy_decode_spec.rb