RSpec Parameterized: Prevent empty with_them definitions (without where)

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

Problem

The following RSpec code runs 0 examples:

describe 'empty' do
  where(:x) { [1] }

  describe 'another scope' do # !!! NOTE THIS EXTRA CONTEXT!!
    with_them do
      it 'works' do

      end
    end
  end
end

# 0 examples, 0 failures

This is misleading and potentially dangerous because examples are simply skipped without any warnings!

For example: https://gitlab.com/gitlab-org/gitlab/-/blob/07ee9810d52b81c13d0f95eefb04df5d375e208c/spec/lib/gitlab/instrumentation_helper_spec.rb#L260-302: describe 'duration calculations' do is never run 💥

Proposed solution

Let rspec-parameterized-core detect such cases and fail.

Using static code analysis in GitLab.org / Developer Experience / Engineering Productivity / master-broken-incidents might not work as there are instances of where definitions inside a shared_context.

Refs

Found while inspecting spec/lib/gitlab/instrumentation_helper_spec.rb specs for gitlab-org/quality/engineering-productivity/master-broken-incidents#4077 (closed).

Edited by 🤖 GitLab Bot 🤖