Welcome to mirror list, hosted at ThFree Co, Russian Federation.

runner_with_status_scope_shared_examples.rb « ci « shared_examples « support « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 510721d66b258bff9d08df9a31a8ddf335455012 (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
# frozen_string_literal: true

RSpec.shared_examples 'runner with status scope' do
  describe '.with_status' do
    subject(:scope) { described_class.with_status(status) }

    described_class::AVAILABLE_STATUSES.each do |status|
      context "with #{status} status" do
        let(:status) { status }

        it "calls corresponding :#{status} scope" do
          expect(described_class).to receive(status.to_sym).and_call_original

          scope
        end
      end
    end

    context 'with invalid status' do
      let(:status) { :invalid_status }

      it 'returns all records' do
        expect(described_class).to receive(:all).at_least(:once).and_call_original

        expect { scope }.not_to raise_error
      end
    end
  end
end