From a73ef24cc80fa1c197691500445f5109cdf7751b Mon Sep 17 00:00:00 2001 From: Franz Liedke <249125+franzliedke@users.noreply.github.com> Date: Tue, 27 Aug 2024 20:59:03 +0200 Subject: [PATCH] rails_helper template: Restore old order of support files Before #2678, the suggested code snippet for loading support files loaded files in directories (e.g. `spec/support/a/b.rb`) *after* files with the same basename as those directories (e.g. `spec/support/a.rb`). This tends to be the preferrable load order, given how Ruby modules and classes are usually structured. The root cause is a difference between the alphabetic ordering of string sorting compared to `Pathname#<=>`. --- lib/generators/rspec/install/templates/spec/rails_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/generators/rspec/install/templates/spec/rails_helper.rb b/lib/generators/rspec/install/templates/spec/rails_helper.rb index 15ef42609..36ca9834d 100644 --- a/lib/generators/rspec/install/templates/spec/rails_helper.rb +++ b/lib/generators/rspec/install/templates/spec/rails_helper.rb @@ -25,7 +25,7 @@ # directory. Alternatively, in the individual `*_spec.rb` files, manually # require only the support files necessary. # -# Rails.root.glob('spec/support/**/*.rb').sort.each { |f| require f } +# Rails.root.glob('spec/support/**/*.rb').sort_by(&:to_s).each { |f| require f } <% if RSpec::Rails::FeatureCheck.has_active_record_migration? -%> # Checks for pending migrations and applies them before tests are run.