rubocop-rspec icon indicating copy to clipboard operation
rubocop-rspec copied to clipboard

Focus cop raises incorrectly on variables named `fit`.

Open alexgerstein opened this issue 7 years ago • 3 comments

Example:

let(:fit) { Tax.federal_income_tax }
let(:fit_attributes) { tax_id: fit.id }

raises

C: RSpec/Focus: Focused spec found.
       { tax_id: fit.id }
                 ^^^

alexgerstein avatar Apr 10 '17 21:04 alexgerstein

Interesting. Assuming calling fit inside of an example doesn't focus the test then we should definitely stop searching for focusing method calls once we know we are inside of an example. Thanks for the bug report

backus avatar Apr 10 '17 21:04 backus

I suggest adding a (block part to the node pattern.

I've checked that fit without a block does not focus, so it does not make much sense to flag it.

You've been taking a stab at this, WDYT @dgollahon ?

pirj avatar Aug 20 '19 11:08 pirj

I'd need to go over my old code to check if that'd work or not but my memory is that it's a bit trickier than that. I'll hopefully have some time to look over this in the next couple of weeks.

dgollahon avatar Aug 21 '19 21:08 dgollahon