summaryrefslogtreecommitdiff
path: root/spec/support/shared_examples/lib/gitlab/repo_type_shared_examples.rb
blob: 69ae9339f1014ca72e5c6116abc2ef9d81f14adc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# frozen_string_literal: true

RSpec.shared_examples 'a repo type' do
  describe '#identifier_for_container' do
    subject { described_class.identifier_for_container(expected_container) }

    it { is_expected.to eq(expected_identifier) }
  end

  describe '#fetch_id' do
    it 'finds an id match in the identifier' do
      expect(described_class.fetch_id(expected_identifier)).to eq(expected_id)
    end

    it 'does not break on other identifiers' do
      expect(described_class.fetch_id('wiki-noid')).to eq(nil)
    end
  end

  describe '#fetch_container!' do
    it 'returns the container' do
      expect(described_class.fetch_container!(expected_identifier)).to eq expected_container
    end

    it 'raises an exception if the identifier is invalid' do
      expect { described_class.fetch_container!('project-noid') }.to raise_error ArgumentError
    end
  end

  describe '#path_suffix' do
    subject { described_class.path_suffix }

    it { is_expected.to eq(expected_suffix) }
  end

  describe '#repository_for' do
    it 'finds the repository for the repo type' do
      expect(described_class.repository_for(expected_container)).to eq(expected_repository)
    end
  end
end