Class: RuboCop::Cop::RSpecParity::FileHasSpec
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::RSpecParity::FileHasSpec
- Includes:
- DepartmentConfig
- Defined in:
- lib/rubocop/cop/rspec_parity/file_has_spec.rb
Overview
Checks that each Ruby file in the app directory has a corresponding spec file.
Constant Summary collapse
- MSG =
"Missing spec file. Expected %<spec_path>s to exist"
Constants included from DepartmentConfig
DepartmentConfig::SHARED_CONFIG_DEFAULTS
Instance Method Summary collapse
Instance Method Details
#on_new_investigation ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/rubocop/cop/rspec_parity/file_has_spec.rb', line 18 def on_new_investigation return unless should_check_file? spec_paths = expected_spec_paths return if spec_paths.empty? return if spec_paths.any? { |path| File.exist?(path) } add_offense( processed_source.ast || processed_source.tokens.first, message: format(MSG, spec_path: relative_spec_path(spec_paths.first)) ) end |