Commit 4ac22588 authored by Erick Bajao's avatar Erick Bajao

Clean up specs according to testing guidelines

parent a5d6a17a
...@@ -3442,14 +3442,15 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do ...@@ -3442,14 +3442,15 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
end end
describe "#builds_with_coverage" do describe "#builds_with_coverage" do
let!(:rspec) { create(:ci_build, name: 'rspec', coverage: 97.1, pipeline: pipeline) } it 'returns builds with coverage only' do
let!(:jest) { create(:ci_build, name: 'jest', coverage: 94.1, pipeline: pipeline) } rspec = create(:ci_build, name: 'rspec', coverage: 97.1, pipeline: pipeline)
let!(:karma) { create(:ci_build, name: 'karma', coverage: nil, pipeline: pipeline) } jest = create(:ci_build, name: 'jest', coverage: 94.1, pipeline: pipeline)
karma = create(:ci_build, name: 'karma', coverage: nil, pipeline: pipeline)
subject(:builds) { pipeline.builds_with_coverage } builds = pipeline.builds_with_coverage
it 'returns builds with coverage only' do expect(builds).to include(rspec, jest)
expect(builds).to match_array([rspec, jest]) expect(builds).not_to include(karma)
end end
end end
end end
...@@ -4114,8 +4114,8 @@ RSpec.describe MergeRequest, factory_default: :keep do ...@@ -4114,8 +4114,8 @@ RSpec.describe MergeRequest, factory_default: :keep do
end end
describe '#head_pipeline_builds_with_coverage' do describe '#head_pipeline_builds_with_coverage' do
it do it 'delegates to head_pipeline' do
is_expected expect(subject)
.to delegate_method(:builds_with_coverage) .to delegate_method(:builds_with_coverage)
.to(:head_pipeline) .to(:head_pipeline)
.with_prefix .with_prefix
......
...@@ -287,19 +287,14 @@ RSpec.describe MergeRequestPollWidgetEntity do ...@@ -287,19 +287,14 @@ RSpec.describe MergeRequestPollWidgetEntity do
end end
describe '#builds_with_coverage' do describe '#builds_with_coverage' do
let(:result) { subject[:builds_with_coverage] } it 'serializes the builds with coverage' do
let(:builds) do allow(resource).to receive(:head_pipeline_builds_with_coverage).and_return([
[
double(name: 'rspec', coverage: 91.5), double(name: 'rspec', coverage: 91.5),
double(name: 'jest', coverage: 94.1) double(name: 'jest', coverage: 94.1)
] ])
end
before do result = subject[:builds_with_coverage]
allow(resource).to receive(:head_pipeline_builds_with_coverage).and_return(builds)
end
it 'serializes the builds with coverage' do
expect(result).to eq([ expect(result).to eq([
{ name: 'rspec', coverage: 91.5 }, { name: 'rspec', coverage: 91.5 },
{ name: 'jest', coverage: 94.1 } { name: 'jest', coverage: 94.1 }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment