diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-20 18:38:24 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-20 18:38:24 +0000 |
commit | 983a0bba5d2a042c4a3bbb22432ec192c7501d82 (patch) | |
tree | b153cd387c14ba23bd5a07514c7c01fddf6a78a0 /spec/lib/banzai | |
parent | a2bddee2cdb38673df0e004d5b32d9f77797de64 (diff) | |
download | gitlab-ce-983a0bba5d2a042c4a3bbb22432ec192c7501d82.tar.gz |
Add latest changes from gitlab-org/gitlab@12-10-stable-ee
Diffstat (limited to 'spec/lib/banzai')
-rw-r--r-- | spec/lib/banzai/pipeline_spec.rb | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/spec/lib/banzai/pipeline_spec.rb b/spec/lib/banzai/pipeline_spec.rb new file mode 100644 index 00000000000..eeff7287ff5 --- /dev/null +++ b/spec/lib/banzai/pipeline_spec.rb @@ -0,0 +1,64 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe Banzai::Pipeline do + describe '.[]' do + subject { described_class[name] } + + shared_examples 'error' do |exception, message| + it do + expect { subject }.to raise_error(exception, message) + end + end + + context 'for nil' do + let(:name) { nil } + + it { is_expected.to eq(Banzai::Pipeline::FullPipeline) } + end + + context 'for symbols' do + context 'when known' do + let(:name) { :full } + + it { is_expected.to eq(Banzai::Pipeline::FullPipeline) } + end + + context 'when unknown' do + let(:name) { :unknown } + + it_behaves_like 'error', NameError, + 'uninitialized constant Banzai::Pipeline::UnknownPipeline' + end + end + + context 'for classes' do + let(:name) { klass } + + context 'subclassing Banzai::Pipeline::BasePipeline' do + let(:klass) { Class.new(Banzai::Pipeline::BasePipeline) } + + it { is_expected.to eq(klass) } + end + + context 'subclassing other types' do + let(:klass) { Class.new(Banzai::RenderContext) } + + before do + stub_const('Foo', klass) + end + + it_behaves_like 'error', ArgumentError, + 'unsupported pipeline name Foo (Class)' + end + end + + context 'for other types' do + let(:name) { 'label' } + + it_behaves_like 'error', ArgumentError, + 'unsupported pipeline name "label" (String)' + end + end +end |