Skip to content

Cop idea: prevent closure variables #1648

@thijsnado

Description

@thijsnado

A common mistake I see is using closure variables instead of let statements. An example of this:

describe User do
  user = FactoryBot.create(:user)

  it "exists" do
    expect(user).not_to be_nil
  end
end

The issue with above example is now a user exists in the DB for the rest of the tests since it is not part of example transaction.

I'd be willing to work on a PR for this if you think this would be a good addition to this gem.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions