diff --git a/test/lib/zeitwerk/test_eager_load_dir.rb b/test/lib/zeitwerk/test_eager_load_dir.rb index 7dfc3767..986fd065 100644 --- a/test/lib/zeitwerk/test_eager_load_dir.rb +++ b/test/lib/zeitwerk/test_eager_load_dir.rb @@ -279,7 +279,7 @@ class TestEagerLoadDir < LoaderTest end test "shortcircuits if eager loaded" do - with_setup([]) do + with_setup do loader.eager_load # Dirty way to prove we shortcircuit. @@ -298,14 +298,14 @@ def loader.actual_eager_load_dir(*) end test "raises Zeitwerk::Error if the argument is not a directory" do - with_setup([]) do + with_setup do e = assert_raises(Zeitwerk::Error) { loader.eager_load_dir(__FILE__) } assert_equal "#{__FILE__} is not a directory", e.message end end test "raises if the argument is not managed by the loader" do - with_setup([]) do + with_setup do e = assert_raises(Zeitwerk::Error) { loader.eager_load_dir(__dir__) } assert_equal "I do not manage #{__dir__}", e.message end diff --git a/test/lib/zeitwerk/test_eager_load_namespace.rb b/test/lib/zeitwerk/test_eager_load_namespace.rb index 7a5b90fe..25456135 100644 --- a/test/lib/zeitwerk/test_eager_load_namespace.rb +++ b/test/lib/zeitwerk/test_eager_load_namespace.rb @@ -11,7 +11,7 @@ class TestEagerLoadNamespaceWithObjectRootNamespace < LoaderTest end test "shortcircuits if eager loaded" do - with_setup([]) do + with_setup do loader.eager_load # Dirty way to prove we shortcircuit. @@ -166,7 +166,7 @@ def loader.actual_eager_load_dir(*) end test "raises if the argument is not a class or module object" do - with_setup([]) do + with_setup do e = assert_raises(Zeitwerk::Error) do loader.eager_load_namespace(self.class.name) end @@ -175,7 +175,7 @@ def loader.actual_eager_load_dir(*) end test "raises if the argument is not a class or module object, even if eager loaded" do - with_setup([]) do + with_setup do loader.eager_load e = assert_raises(Zeitwerk::Error) do loader.eager_load_namespace(self.class.name) diff --git a/test/lib/zeitwerk/test_load_file.rb b/test/lib/zeitwerk/test_load_file.rb index 240628a4..ca95328f 100644 --- a/test/lib/zeitwerk/test_load_file.rb +++ b/test/lib/zeitwerk/test_load_file.rb @@ -62,7 +62,7 @@ class TestLoadFile < LoaderTest class TestLoadFileErrors < LoaderTest test "raises if the argument does not exist" do - with_setup([]) do + with_setup do e = assert_raises { loader.load_file("foo.rb") } assert_equal "#{File.expand_path('foo.rb')} does not exist", e.message end diff --git a/test/lib/zeitwerk/test_logging.rb b/test/lib/zeitwerk/test_logging.rb index d28c02bf..7c86d7fb 100644 --- a/test/lib/zeitwerk/test_logging.rb +++ b/test/lib/zeitwerk/test_logging.rb @@ -181,7 +181,7 @@ def logger.debug(message) end test "logs when eager loading starts" do - with_setup([]) do + with_setup do assert_logged(/eager load start/) do loader.eager_load end @@ -189,7 +189,7 @@ def logger.debug(message) end test "logs when eager loading ends" do - with_setup([]) do + with_setup do assert_logged(/eager load end/) do loader.eager_load end diff --git a/test/support/loader_test.rb b/test/support/loader_test.rb index 1fc8961e..79ac9d36 100644 --- a/test/support/loader_test.rb +++ b/test/support/loader_test.rb @@ -79,7 +79,7 @@ def with_load_path(dirs = loader.dirs) dirs.each { |dir| $LOAD_PATH.delete(dir) } end - def with_setup(files, dirs: ".", namespace: Object, load_path: nil, rm: true) + def with_setup(files = [], dirs: ".", namespace: Object, load_path: nil, rm: true) with_files(files, rm: rm) do Array(dirs).each { |dir| loader.push_dir(dir, namespace: namespace) } loader.setup