Closed ryan-mcneil closed 3 weeks ago
@ryan-mcneil Thank you for your report. I could not reproduce it with just the code you provided. Can you give us the code to reproduce it?
If you can’t provide a full example, perhaps you can run rubocop with -d flag and provide the error and rubocop backtrace?
Hey, apologies for the delay.
So, I dug in a bit to see how I could provide enough context code to get it to work properly. It wasn't my code, so I had to figure out what they were trying to do. Turns out, they were using that line incorrectly. They were using change(ProductDirectory::Codeowner, :count).by(0)
AS an expectation, vs being used in conjunction with an expectation
expect { some_action }.to change(ProductDirectory::Codeowner, :count).by(0)
.
Fixing that, the errors actually went a way. So this may not be an edge case you need to fix. But perhaps an idea for a future cop could be checking for orphaned, useless matchers 🙃 😆
Sorry for the false alarm!
Thanks for the feedback! We’ve just merged a new cop that helps with similar situations, but bot exactly what you describe.
Hi,
While running Rubocop (1.64.1) w/ rubocop-rspec (3.0.1), I'm getting the following error:
Unfortunately this repo is currently private, but the following lines, respectively, caused the 5 errors:
change(ProductDirectory::Codeowner, :count).by(0)
X 2change(ProductDirectory::Product, :count).by(0)
change(ProductDirectory::Team, :count).by(0)
X 2Hopefully that's all you need to investigate - Thank you!!