Skip to content

Commit

Permalink
Disable yaml autoloader spec for zeitwerk as we can't test it this way
Browse files Browse the repository at this point in the history
We can't modify the frozen autoload paths with zeitwerk.

For now, just disable this test with zeitwerk loader.
  • Loading branch information
jrafanie committed Aug 21, 2023
1 parent 85a2eb1 commit 5dfd15e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions config/initializers/yaml_autoloader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
#
# Note, this is used to autoload constants serialized as yaml from one process and loaded in another such as through
# args in the MiqQueue. An alternative would be to eager load all of our autoload_paths in all processes.
#
# This is still needed in some areas for zeitwerk, such as YAML files for tests in the manageiq-providers-vmware
# that reference a constant: RbVmomi::VIM::TaskEvent
Psych::Visitors::ToRuby.prepend Module.new {
def resolve_class(klass_name)
(class_loader.class != Psych::ClassLoader::Restricted && klass_name && klass_name.safe_constantize) || super
Expand Down
1 change: 1 addition & 0 deletions spec/initializers/yaml_autoloader_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
let(:missing_model) { model_directory.join("zzz_model.rb") }

before do
skip "This is currently not testable with zeitwerk!" if Rails.application.config.autoloader == :zeitwerk
File.write(missing_model, "class ZzzModel\nend\n")
ActiveSupport::Dependencies.autoload_paths << model_directory
end
Expand Down

0 comments on commit 5dfd15e

Please sign in to comment.