Skip to content

Empty with_them definitions without where are misleading #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
splattael opened this issue Nov 7, 2023 · 1 comment
Open

Empty with_them definitions without where are misleading #8

splattael opened this issue Nov 7, 2023 · 1 comment

Comments

@splattael
Copy link

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.
@splattael
Copy link
Author

#9 to emit warnings when where was redefined or with_them was used before where was defined.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant