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

Add custom cop to disallow "let!" #40

Open
klappradla opened this issue Sep 23, 2020 · 0 comments
Open

Add custom cop to disallow "let!" #40

klappradla opened this issue Sep 23, 2020 · 0 comments
Assignees

Comments

@klappradla
Copy link
Member

Add a custom cop to check for the usage of let! in RSpec test setups. Background: we prefer to use the lazy-evaluated let and call it in an explicit before hook.

RSpec's let! does the same under the hood, but it's visually less obvious and tends to be overused by people.

Example:

# Bad
let!(:thing) { create(:thing) }

it 'does things' do
  expect(thing.do).to eq(1)
end

# Good
let(:thing) { create(:thing) }

before { thing }

it 'does things' do
  expect(thing.do).to eq(1)
end

For adding a custom cop, see:

@klappradla klappradla self-assigned this Sep 23, 2020
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