Skip to content

Commit

Permalink
rails_helper template: Restore old order of support files
Browse files Browse the repository at this point in the history
Before rspec#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#<=>`.
  • Loading branch information
franzliedke authored Aug 27, 2024
1 parent d0e322b commit a73ef24
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit a73ef24

Please sign in to comment.