Skip to content

Cop Idea: Prefer using the all matcher instead of iterating over an array #278

@backus

Description

@backus

The all matcher is pretty cool. We can't infer a lot of use cases statically of course but I bet we could probably detect enough cases for it to be useful. For example, I've seen some specs like this

it 'validates users' do
  [user1, user2, user3].each { |user| expect(user).to be_valid }
end

this could be written as

it 'validates users' do
  expect([user1, user2, user3].to all(be_valid)
end

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions