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
end
describe "#builds_with_coverage" do
let!(:rspec) { create(:ci_build, name: 'rspec', coverage: 97.1, pipeline: pipeline) }
let!(:jest) { create(:ci_build, name: 'jest', coverage: 94.1, pipeline: pipeline) }
let!(:karma) { create(:ci_build, name: 'karma', coverage: nil, pipeline: pipeline) }
it 'returns builds with coverage only' do
rspec = create(:ci_build, name: 'rspec', coverage: 97.1, 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 match_array([rspec, jest])
expect(builds).to include(rspec, jest)
expect(builds).not_to include(karma)
end
end
end
......@@ -4114,8 +4114,8 @@ RSpec.describe MergeRequest, factory_default: :keep do
end
describe '#head_pipeline_builds_with_coverage' do
it do
is_expected
it 'delegates to head_pipeline' do
expect(subject)
.to delegate_method(:builds_with_coverage)
.to(:head_pipeline)
.with_prefix
......
......@@ -287,19 +287,14 @@ RSpec.describe MergeRequestPollWidgetEntity do
end
describe '#builds_with_coverage' do
let(:result) { subject[:builds_with_coverage] }
let(:builds) do
[
it 'serializes the builds with coverage' do
allow(resource).to receive(:head_pipeline_builds_with_coverage).and_return([
double(name: 'rspec', coverage: 91.5),
double(name: 'jest', coverage: 94.1)
]
end
])
before do
allow(resource).to receive(:head_pipeline_builds_with_coverage).and_return(builds)
end
result = subject[:builds_with_coverage]
it 'serializes the builds with coverage' do
expect(result).to eq([
{ name: 'rspec', coverage: 91.5 },
{ 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