From e2bc2923e843a5a1ead21e7e96953c6bcac4ab82 Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Sun, 1 Sep 2024 10:17:01 +0100 Subject: [PATCH] Refactor to remove begin/end block --- lib/rspec-rails.rb | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/lib/rspec-rails.rb b/lib/rspec-rails.rb index e7048caa5..4d6ce04cf 100644 --- a/lib/rspec-rails.rb +++ b/lib/rspec-rails.rb @@ -13,14 +13,13 @@ class Railtie < ::Rails::Railtie # As of Rails 8.0.0 you can register directories to work with `rails stats` if ::Rails::VERSION::STRING >= "8.0.0" require 'rails/code_statistics' - types = begin - dirs = Dir['./spec/**/*_spec.rb'] - .map { |f| f.sub(/^\.\/(spec\/\w+)\/.*/, '\\1') } - .uniq - .select { |f| File.directory?(f) } - Hash[dirs.map { |d| [d.split('/').last, d] }] - end - types.each do |type, dir| + + dirs = Dir['./spec/**/*_spec.rb'] + .map { |f| f.sub(/^\.\/(spec\/\w+)\/.*/, '\\1') } + .uniq + .select { |f| File.directory?(f) } + + Hash[dirs.map { |d| [d.split('/').last, d] }].each do |type, dir| name = type.singularize.capitalize ::Rails::CodeStatistics.register_directory "#{name} specs", dir