Skip to content

Empty with_them definitions without where are misleading #8

Open
@splattael

Description

@splattael

Proposed solution

The following code does not run any examples because with_them is defined a different example group and it does not any where definitions.

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

Refs https://gitlab.com/gitlab-org/gitlab/-/issues/430870

Proposed solution

Because RSpec::Parameterized support definition of where/with_them in any order it's not straightforward to disallow the mentioned behavior (with_them without any where definitions).

I see the following options:

  1. Emit a warning whenever with_them is defined before any where definition.
  2. Disallow definition of with_them before where definition. This is potentially a BREAKING CHANGE.

Related but out of scope

  • Disallow or warn about multiple where definitions. Currently, the latter wins without any warning.
  • Disallow or warn about multiple with_them definitions. I am unsure about the use-case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions