lib/rubocop/cop/rspec/file_path.rb in rubocop-rspec-1.3.1 vs lib/rubocop/cop/rspec/file_path.rb in rubocop-rspec-1.4.0

- old
+ new

@@ -1,6 +1,7 @@ # encoding: utf-8 +# frozen_string_literal: true module RuboCop module Cop module RSpec # Checks the path of the spec file and enforces that it reflects the @@ -15,16 +16,16 @@ # my_class_method_spec.rb # describe MyClass, '#method' # my_class_spec.rb # describe MyClass class FilePath < Cop include RuboCop::RSpec::TopLevelDescribe - MESSAGE = 'Spec path should end with `%s`' + MESSAGE = 'Spec path should end with `%s`'.freeze METHOD_STRING_MATCHER = /^[\#\.].+/ def on_top_level_describe(node, args) return unless single_top_level_describe? - object = const_name(args.first) + object = args.first.const_name return unless object path_matcher = matcher(object, args[1]) return if source_filename =~ regexp_from_glob(path_matcher) @@ -52,10 +53,10 @@ processed_source.buffer.name end def camel_to_underscore(string) string.dup.tap do |result| - result.gsub!(/([^A-Z])([A-Z]+)/, '\\1_\\2') + result.gsub!(/([^A-Z])([A-Z]+)/, '\\1_\\2') result.gsub!(/([A-Z])([A-Z][^A-Z]+)/, '\\1_\\2') result.downcase! end end