diff options
Diffstat (limited to 'spec/support')
-rw-r--r-- | spec/support/shared_examples/ci/runner_with_status_scope_shared_examples.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/spec/support/shared_examples/ci/runner_with_status_scope_shared_examples.rb b/spec/support/shared_examples/ci/runner_with_status_scope_shared_examples.rb new file mode 100644 index 00000000000..510721d66b2 --- /dev/null +++ b/spec/support/shared_examples/ci/runner_with_status_scope_shared_examples.rb @@ -0,0 +1,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 |