I'm working on upgrading rails, and part of that process involves switching from the classic autoloader to zeitwerk. I've been running bin/rails zeitwerk:check and handling all the cases that come up, and I've now come to a spec file. Up until now it has been the odd case of adding an inflection or renaming the constant:
Rails.autoloaders.each do |autoloader|
autoloader.inflector.inflect(
'aes' => 'AES',
)
end
The following is the convention I've always known for rspec tests, and I can't find anything that contradicts that this is still the convention:
# spec/models/user_spec.rb
require 'rails_helper'
RSpec.describe User do
# test stuff
end
However, user_spec.rb does not define UserSpec, and zeitwerk isn't having it.
From what I can tell, I have 3 options:
- go against the standard rspec convention, and rename all the constants in all the tests such as from User to UserSpec
- define a 'dummy' module in every test that defines the constant
- add an inflection in application.rb for every single test.
All of these seem like terrible ideas. What is everyone else doing here? Is there a 4th option I haven't seen?