File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,25 @@ class Railtie < ::Rails::Railtie
9
9
# As of Rails 5.1.0 you can register directories to work with `rake notes`
10
10
require 'rails/source_annotation_extractor'
11
11
::Rails ::SourceAnnotationExtractor ::Annotation . register_directories ( "spec" )
12
+
13
+ # As of Rails 8.0.0 you can register directories to work with `rails stats`
14
+ if ::Rails ::VERSION ::STRING >= "8.0.0"
15
+ require 'rails/code_statistics'
16
+ types = begin
17
+ dirs = Dir [ './spec/**/*_spec.rb' ]
18
+ . map { |f | f . sub ( /^\. \/ (spec\/ \w +)\/ .*/ , '\\1' ) }
19
+ . uniq
20
+ . select { |f | File . directory? ( f ) }
21
+ Hash [ dirs . map { |d | [ d . split ( '/' ) . last , d ] } ]
22
+ end
23
+ types . each do |type , dir |
24
+ name = type . singularize . capitalize
25
+
26
+ ::Rails ::CodeStatistics . register_directory "#{ name } specs" , dir
27
+ ::Rails ::CodeStatistics ::TEST_TYPES << "#{ name } specs"
28
+ end
29
+ end
30
+
12
31
generators = config . app_generators
13
32
generators . integration_tool :rspec
14
33
generators . test_framework :rspec
Original file line number Diff line number Diff line change 5
5
6
6
task default : :spec
7
7
8
- task stats : "spec:statsetup"
8
+ if ::Rails ::VERSION ::STRING < "8.0.0"
9
+ task stats : "spec:statsetup"
10
+ end
9
11
10
12
desc "Run all specs in spec directory (excluding plugin specs)"
11
13
RSpec ::Core ::RakeTask . new ( spec : "spec:prepare" )
You can’t perform that action at this time.
0 commit comments