Test AdvanceTeamsInIntermediateStage Interactor
This commit is contained in:
parent
213867a827
commit
6dff05b5e6
|
|
@ -1,18 +1,52 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
RSpec.describe AdvanceTeamsInIntermediateStage do
|
RSpec.describe AdvanceTeamsInIntermediateStage do
|
||||||
|
shared_examples_for 'succeeding context' do
|
||||||
|
it 'succeeds' do
|
||||||
|
expect(context).to be_a_success
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
shared_examples_for 'failing context' do
|
||||||
|
it 'fails' do
|
||||||
|
expect(context).to be_a_failure
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context 'intermediate_stage is nil' do
|
context 'intermediate_stage is nil' do
|
||||||
let(:context) do
|
let(:context) do
|
||||||
AdvanceTeamsInIntermediateStage.call(intermediate_stage: nil)
|
AdvanceTeamsInIntermediateStage.call(intermediate_stage: nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'succeeds' do
|
it_behaves_like 'succeeding context'
|
||||||
expect(context).to be_a_success
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'doesn\'t call PopulateMatchBelow' do
|
it 'doesn\'t call PopulateMatchBelow' do
|
||||||
expect(PopulateMatchBelowAndSave).not_to receive(:call)
|
expect(PopulateMatchBelowAndSave).not_to receive(:call)
|
||||||
context
|
context
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'intermediate_stage is an realistic stage' do
|
||||||
|
let(:context) do
|
||||||
|
AdvanceTeamsInIntermediateStage.call(intermediate_stage: create(:playoff_stage, match_type: :single_team_match))
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'PopulateMatchBelow succeeds' do
|
||||||
|
before do
|
||||||
|
expect(class_double('PopulateMatchBelowAndSave').as_stubbed_const(transfer_nested_constants: true))
|
||||||
|
.to receive(:call).exactly(4).times.and_return(double(:context, success?: true))
|
||||||
|
end
|
||||||
|
|
||||||
|
it_behaves_like 'succeeding context'
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'PopulateMatchBelow fails' do
|
||||||
|
before do
|
||||||
|
expect(class_double('PopulateMatchBelowAndSave').as_stubbed_const(transfer_nested_constants: true))
|
||||||
|
.to receive(:call).and_return(double(:context, success?: false))
|
||||||
|
end
|
||||||
|
|
||||||
|
it_behaves_like 'failing context'
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue