Skip to content
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

Cop idea: Don't use remove_const in specs #1748

Closed
swelther opened this issue Dec 1, 2023 · 1 comment · Fixed by #1749
Closed

Cop idea: Don't use remove_const in specs #1748

swelther opened this issue Dec 1, 2023 · 1 comment · Fixed by #1749

Comments

@swelther
Copy link
Contributor

swelther commented Dec 1, 2023

We had some specs in our project that used Object.send(:remove_const, :SomeConstant) instead of using e.g. stub_const. This lead to annoying and hard to debug issues in our CI pipelines. To get rid of these usages and rise awareness about this we created a cop that we would like to contribute, if you are interested.

# bad
it 'does something' do
  Object.send(:remove_const, :SomeConstant)
end

# bad
before do
  Object.send(:remove_const, :SomeConstant)
end
@pirj
Copy link
Member

pirj commented Dec 1, 2023

Makes sense. A PR is welcome.

LukasAud added a commit to puppetlabs/rspec-puppet that referenced this issue Jan 9, 2024
Following the recent introduction of a new cop in Rubocop,
Rspec/RemoveConst, our CI has started failing. It seems like this rule
is being enforced as a good practice to avoid buggy debug information
but no real alternative is being offered.

This commit disables the cop to allow the CI to continue working. Here
are the discussions that led to the creation of the rule:
rubocop/rubocop-rspec#1748
rubocop/rubocop-rspec#1749
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

Successfully merging a pull request may close this issue.

2 participants