Sha256: 9bb19c962a3fa5d028be1fd06d80daae0e25ebec613d631bc304ff2fca25aa04
Contents?: true
Size: 1.13 KB
Versions: 1
Compression:
Stored size: 1.13 KB
Contents
# frozen_string_literal: true require 'rails_helper' RSpec.describe Article, '#idy_encode' do context 'with no given salt' do let!(:model) { Article.new id: 1 } it 'obfuscates the id with default class salt' do expect(model.class.idy_encode(model.id)).to eq 'My' end end context 'with empty salt' do let!(:model) { Article.new id: 1 } let!(:salt) { '' } it 'obfuscates the id with empty salt' do expect(model.class.idy_encode(model.id, salt: salt)).to eq 'jR' end end context 'with salt' do let!(:model) { Article.new id: 1 } context 'when is string' do let!(:salt) { 'salt' } it 'obfuscates the id with given salt' do expect(model.class.idy_encode(model.id, salt: salt)).to eq 'XG' end end context 'when is number' do let!(:salt) { 1 } it 'obfuscates the id with given salt as string' do expect(model.class.idy_encode(model.id, salt: salt)).to eq 'kL' end end end context 'with nil id' do let!(:model) { Article.new } it 'returns nil' do expect(model.class.idy_encode(model.id)).to be_nil end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
idy-1.0.0 | spec/lib/idy/extension/idy_encode_spec.rb |