Hi,
After looking at some of the source file that throws the spec pathing offense, I think it might be getting thrown by accident for describe blocks for nested classes/modules.
Here's the example code that's causing the error:
require 'spec_helper'
tags = { . . . meta_data . . .}
RSpec.describe Module::PluralizedModelController, tags do
end
Rubocop reports Spec path should end with 'module/pluralized_model_controller*_spec.rb' but the file follows that format. pluralized_model_controller_spec.rb is within a folder named module.
There isn't anything else in the file and the error is repeatable with the example I've given above. Could there be a Regexp issue with https://github.com/nevir/rubocop-rspec/blob/master/lib/rubocop/cop/rspec/file_path.rb?
Thanks!
+1
I had the same problem, but I had misspelled the directory name. When I corrected the spelling the offense was gone.
I had this issue with companies_spec.rb
The cop was happy if I named the file companys_spec.rb
but instead I disabled this cop with # rubocop:disable RSpec/FilePath
@kWhittington @adarsh: I'm having trouble reproducing this problem. Could you confirm if it's still happening in the latest release?
@seanlerner: that sounds like it might be a separate issue. Could you give some more details about your spec file's contents?
I just tried it again in the app it was happening in. I'm not getting the error in our controller specs anymore. We've updated rubocop and rubocop-rspec since I first reported this:
rubocop (0.39.0)
parser (>= 2.3.0.7, < 3.0)
powerpack (~> 0.1)
rainbow (>= 1.99.1, < 3.0)
ruby-progressbar (~> 1.7)
unicode-display_width (~> 1.0, >= 1.0.1)
rubocop-rspec (1.4.1)
rubocop (= 0.39.0)
Thanks for asking.
Sorry for not closing the loop here - I realized the spec file was
mis-named and that was the root problem. I'm okay closing this issue, at
least from my end.
@adarshp http://www.twitter.com/adarshp
313.454.1515 (mobile)
See when I am free: http://bit.ly/adarshcal
On Sun, May 8, 2016 at 2:24 PM, Kyle Whittington [email protected]
wrote:
I just tried it again in the app it was happening in. I'm not getting the
error in our controller specs anymore. We've updated rubocop and
rubocop-rspec since I first reported this:rubocop (0.39.0)
parser (>= 2.3.0.7, < 3.0)
powerpack (~> 0.1)
rainbow (>= 1.99.1, < 3.0)
ruby-progressbar (~> 1.7)
unicode-display_width (~> 1.0, >= 1.0.1)
rubocop-rspec (1.4.1)
rubocop (= 0.39.0)Thanks for asking.
—
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
https://github.com/nevir/rubocop-rspec/issues/37#issuecomment-217747053
@andyw8 - I'm not able to reproduce the issue any longer. (I've moved away from 'Company' as a model name). thx for following up.
+1 directory name misspelling
@vladlena please provide some information about how to reproduce your problem.
Looks like everyone reporting issues here wound up figuring out their problem. Closing this. Let me know if anyone still has problems
@backus Hey. I have similar issue with acronym controller name.
My controller is named: POIsController and POI is added to rails' inflections, but rubocop shouts:
spec/controllers/pois_controller_spec.rb:4:1: C: RSpec/FilePath: Spec path should end with po_is_controller*_spec.rb.
@nowakov rubocop-rspec does not read from the Rails reflections, but you can define a CustomTransform:
RSpec/FilePath:
CustomTransform:
POIsController: pois_controller
https://github.com/backus/rubocop-rspec/blob/master/lib/rubocop/cop/rspec/file_path.rb
@andyw8 Fair enough. Thanks! 🎉
Most helpful comment
+1 directory name misspelling