debian-mirror-gitlab/spec/lib/gitlab/utils/safe_inline_hash_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

36 lines
899 B
Ruby
Raw Permalink Normal View History

2019-12-21 20:55:43 +05:30
# frozen_string_literal: true
require 'fast_spec_helper'
2020-07-28 23:09:34 +05:30
RSpec.describe Gitlab::Utils::SafeInlineHash do
2019-12-21 20:55:43 +05:30
describe '.merge_keys!' do
let(:source) { { 'foo' => { 'bar' => 'baz' } } }
let(:validator) { instance_double(Gitlab::Utils::DeepSize, valid?: valid) }
subject { described_class.merge_keys!(source, prefix: 'safe', connector: '::') }
before do
allow(Gitlab::Utils::DeepSize)
.to receive(:new)
.with(source)
.and_return(validator)
end
context 'when hash is too big' do
let(:valid) { false }
it 'raises an exception' do
expect { subject }.to raise_error ArgumentError, 'The Hash is too big'
end
end
context 'when hash has an acceptaable size' do
let(:valid) { true }
it 'returns a result of InlineHash' do
is_expected.to eq('safe::foo::bar' => 'baz')
end
end
end
end