- Defined in:
Checks that spec file paths are consistent and well-formed.
By default, this checks that spec file paths are consistent with the test subject and and enforces that it reflects the described class/module and its optionally called out method.
With the configuration option `IgnoreMethods` the called out method will be ignored when determining the enforced path.
With the configuration option `CustomTransform` modules or classes can be specified that should not as usual be transformed from CamelCase to snake_case (e.g. 'RuboCop' => 'rubocop' ).
With the configuration option `SpecSuffixOnly` test files will only be checked to ensure they end in '_spec.rb'. This option disables checking for consistency in the test subject or test methods.
Constant Summary collapse
- MSG =
'Spec path should end with `%<suffix>s`.'
Constants inherited from
Constants included from
Instance Method Summary collapse
Methods included from
Methods inherited from
Instance Method Details
#on_top_level_describe(node, args) ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79
# File 'lib/rubocop/cop/rspec/file_path.rb', line 67 def on_top_level_describe(node, args) return unless const_described?(node) && single_top_level_describe? return if routing_spec?(args) glob = glob_for(args) return if filename_ends_with?(glob) add_offense( node, message: format(, suffix: glob) ) end