Class: RuboCop::Cop::RSpec::SpecFilePathFormat
- Includes:
- FileHelp, Namespace, TopLevelGroup
- Defined in:
- lib/rubocop/cop/rspec/spec_file_path_format.rb
Overview
Checks that spec file paths are consistent and well-formed.
Constant Summary collapse
- MSG =
'Spec path should end with `%<suffix>s`.'
Constants included from TopLevelGroup
TopLevelGroup::DEPRECATED_MODULE_METHOD_WARNING
Instance Method Summary collapse
- #example_group_arguments(node) ⇒ Object
- #metadata_key_value(node) ⇒ Object
- #on_top_level_example_group(node) ⇒ Object
Methods included from FileHelp
Methods included from TopLevelGroup
#on_new_investigation, #top_level_groups
Methods inherited from Base
inherited, #on_new_investigation
Methods included from RSpec::Language
#example?, #example_group?, #example_group_with_body?, #explicit_rspec?, #hook?, #include?, #let?, #rspec?, #shared_group?, #spec_group?, #subject?
Instance Method Details
#example_group_arguments(node) ⇒ Object
43 44 45 |
# File 'lib/rubocop/cop/rspec/spec_file_path_format.rb', line 43 def_node_matcher :example_group_arguments, <<~PATTERN (block $(send #rspec? #ExampleGroups.all $_ $...) ...) PATTERN |
#metadata_key_value(node) ⇒ Object
48 |
# File 'lib/rubocop/cop/rspec/spec_file_path_format.rb', line 48 def_node_search :metadata_key_value, '(pair (sym $_key) (sym $_value))' |
#on_top_level_example_group(node) ⇒ Object
50 51 52 53 54 55 56 57 58 |
# File 'lib/rubocop/cop/rspec/spec_file_path_format.rb', line 50 def on_top_level_example_group(node) return unless top_level_groups.one? example_group_arguments(node) do |send_node, class_name, arguments| next if !class_name.const_type? || (arguments) ensure_correct_file_path(send_node, class_name, arguments) end end |