Skip to content

Commit

Permalink
Refactor to remove begin/end block
Browse files Browse the repository at this point in the history
  • Loading branch information
JonRowe committed Sep 1, 2024
1 parent d9dceef commit e2bc292
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions lib/rspec-rails.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e2bc292

Please sign in to comment.