Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FileName cop to check rspec file ends in _rspec #412

Closed
IanVaughan opened this issue May 16, 2017 · 1 comment
Closed

FileName cop to check rspec file ends in _rspec #412

IanVaughan opened this issue May 16, 2017 · 1 comment

Comments

@IanVaughan
Copy link

IanVaughan commented May 16, 2017

We just hit this, and thought maybe it should be added to the core...

Similar to file_name.rb in Rubocop core, the idea here would be to check files under the /spec directory to ensure they end in _rspec.

Users would need to exclude common non-spec directories like fixtures etc, and maybe this could provide a suggested default for common ones?

I'm happy to do this myself, but just wanted to check if a) I had missed this if already present, or b) was going in the wrong direction and should think of something else!

# @example
    #   # bad
    #   whatever.rb 
    #
    #   # bad
    #   whatever_foo.rb 
    #
    #   # good
    #   whatever_spec.rb 

See also file_path.rb

@andyw8
Copy link
Collaborator

andyw8 commented Jun 2, 2017

I think you meant to write "check rspec file ends in _spec"?

The RSpec/FilePath cop already handles this, for example if you create a file spec/foo.rb containing a describe block, it will report:

spec/foo.rb:1:1: C: Spec path should end with foo*_spec.rb.`
describe Foo do
^^^^^^^^^^^^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants