lib/rubocop/cop/rspec/file_path.rb in rubocop-rspec-2.12.1 vs lib/rubocop/cop/rspec/file_path.rb in rubocop-rspec-2.13.0

- old
+ new

@@ -56,10 +56,11 @@ # # good # my_class_spec.rb # describe MyClass, '#method' # class FilePath < Base include TopLevelGroup + include Namespace MSG = 'Spec path should end with `%<suffix>s`.' # @!method example_group(node) def_node_matcher :example_group, <<~PATTERN @@ -99,21 +100,21 @@ args.any?(&method(:routing_metadata?)) end def pattern_for(example_group, method_name) if spec_suffix_only? || !example_group.const_type? - return pattern_for_spec_suffix_only? + return pattern_for_spec_suffix_only end [ expected_path(example_group), name_pattern(method_name), '[^/]*_spec\.rb' ].join end - def pattern_for_spec_suffix_only? + def pattern_for_spec_suffix_only '.*_spec\.rb' end def name_pattern(method_name) return unless method_name&.str_type? @@ -121,11 +122,13 @@ ".*#{method_name.str_content.gsub(/\s/, '_').gsub(/\W/, '')}" end def expected_path(constant) + constants = namespace(constant) + constant.const_name.split('::') + File.join( - constant.const_name.split('::').map do |name| + constants.map do |name| custom_transform.fetch(name) { camel_to_snake_case(name) } end ) end