rubocop / rubocop-capybara

Code style checking for Capybara files.
https://docs.rubocop.org/rubocop-capybara
MIT License
40 stars 8 forks source link

Cop idea: Redundant `within find('foo')` #75

Closed ydah closed 8 months ago

ydah commented 11 months ago

within find('foo.bar') and within 'foo.bar' have the same behavior. https://www.rubydoc.info/gems/capybara/Capybara%2FSession:within

We consider it redundant to pass the result of find as the argument of within, since we are executing find internally. https://github.com/teamcapybara/capybara/blob/0b43cb90ae633ce9b2008e07b997c76833fa570e/lib/capybara/session.rb#L362-L363

# bad
within find('foo.bar') do
end

# good
within 'foo.bar' do
end