Skip to content

Commit cfb46fe

Browse files
committed
Compute file path with ActiveSupport Inflector if defined
1 parent 2f8ec8a commit cfb46fe

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lib/rubocop/cop/rspec/file_path.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,13 @@ def expected_path(constant)
130130
end
131131

132132
def camel_to_snake_case(string)
133+
if defined?(ActiveSupport::Inflector)
134+
if File.exist?('./config/initializers/inflections.rb')
135+
require './config/initializers/inflections'
136+
end
137+
return ActiveSupport::Inflector.underscore(string)
138+
end
139+
133140
string
134141
.gsub(/([^A-Z])([A-Z]+)/, '\1_\2')
135142
.gsub(/([A-Z])([A-Z][^A-Z\d]+)/, '\1_\2')

0 commit comments

Comments
 (0)