Skip to content

Commit

Permalink
Ignore the directory that keeps factory files under the lib
Browse files Browse the repository at this point in the history
Some tests put factory files under the `lib`. But since Rails 7.1,
Rails loads `lib` directory by default in a new application.
https://guides.rubyonrails.org/7_1_release_notes.html#introducing-config-autoload-lib-and-config-autoload-lib-once-for-enhanced-autoloading

But factory files don't follow the naming rule of Zeitwerk. So
Zeitwerk raises `Zeitwerk::NameError`.
To avoid the error, this changed to ignore the directory that puts
factory files.
  • Loading branch information
y-yagi committed Oct 27, 2023
1 parent 2d14ce3 commit c5228bb
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion features/support/rails_template
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,12 @@ if Rails.gem_version < Gem::Version.new('6')
end

gsub_file "Gemfile", /^ gem 'spring'$/, ' gem "spring", "!= 2.1.1"'
gsub_file "config/routes.rb", /^ get/, ' # get'
gsub_file "config/routes.rb", /^ get/, ' # get'

if Rails.gem_version >= Gem::Version.new('7.1')
append_to_file File.join("config", "application.rb"), <<~RUBY
class TestApp::Application
config.autoload_lib(ignore: %w(some_railtie))
end
RUBY
end

0 comments on commit c5228bb

Please sign in to comment.