Skip to content

Commit

Permalink
Reorganize some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fxn committed Oct 31, 2022
1 parent b42edf9 commit 31c8938
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions test/lib/zeitwerk/test_eager_load_namespace.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,29 +110,29 @@ def loader.actual_eager_load_dir(*)
end
end

test "skips directories which are excluded from eager loading (Namespace)" do
test "skips directories which are excluded from eager loading (namespace, ancestor)" do
files = [["rd1/m/a.rb", "M::A = 1"], ["rd2/m/b.rb", "M::B = 1"]]
with_setup(files, dirs: %w(rd1 rd2)) do
loader.do_not_eager_load("rd1/m")
loader.eager_load_namespace(M)
loader.eager_load_namespace(Object)

assert !required?(files[0])
assert required?(files[1])
end
end

test "skips directories which are excluded from eager loading (Namespace, ancestor)" do
test "skips directories which are excluded from eager loading (namespace, self)" do
files = [["rd1/m/a.rb", "M::A = 1"], ["rd2/m/b.rb", "M::B = 1"]]
with_setup(files, dirs: %w(rd1 rd2)) do
loader.do_not_eager_load("rd1/m")
loader.eager_load_namespace(Object)
loader.eager_load_namespace(M)

assert !required?(files[0])
assert required?(files[1])
end
end

test "skips directories which are excluded from eager loading (2nd level namespace)" do
test "skips directories which are excluded from eager loading (namespace, descendant)" do
files = [["rd1/m/n/a.rb", "M::N::A = 1"], ["rd2/m/n/b.rb", "M::N::B = 1"]]
with_setup(files, dirs: %w(rd1 rd2)) do
loader.do_not_eager_load("rd1/m")
Expand Down Expand Up @@ -314,7 +314,7 @@ module CN; end
end
end

test "skips root directories which are excluded from eager loading (root custom namespace)" do
test "skips root directories which are excluded from eager loading (self)" do
files = [["rd1/a.rb", "#{CN}::A = 1"], ["rd2/b.rb", "#{CN}::B = 1"]]
with_setup(files, dirs: %w(rd1 rd2), namespace: CN) do
loader.do_not_eager_load("rd1")
Expand All @@ -325,29 +325,29 @@ module CN; end
end
end

test "skips directories which are excluded from eager loading (Namespace)" do
test "skips directories which are excluded from eager loading (namespace, ancestor)" do
files = [["rd1/m/a.rb", "#{CN}::M::A = 1"], ["rd2/m/b.rb", "#{CN}::M::B = 1"]]
with_setup(files, dirs: %w(rd1 rd2), namespace: CN) do
loader.do_not_eager_load("rd1/m")
loader.eager_load_namespace(CN::M)
loader.eager_load_namespace(Object)

assert !required?(files[0])
assert required?(files[1])
end
end

test "skips directories which are excluded from eager loading (Namespace, ancestor)" do
test "skips directories which are excluded from eager loading (namespace, self)" do
files = [["rd1/m/a.rb", "#{CN}::M::A = 1"], ["rd2/m/b.rb", "#{CN}::M::B = 1"]]
with_setup(files, dirs: %w(rd1 rd2), namespace: CN) do
loader.do_not_eager_load("rd1/m")
loader.eager_load_namespace(Object)
loader.eager_load_namespace(CN::M)

assert !required?(files[0])
assert required?(files[1])
end
end

test "skips directories which are excluded from eager loading (2nd level namespace)" do
test "skips directories which are excluded from eager loading (namespace, descendant)" do
files = [["rd1/m/n/a.rb", "#{CN}::M::N::A = 1"], ["rd2/m/n/b.rb", "#{CN}::M::N::B = 1"]]
with_setup(files, dirs: %w(rd1 rd2), namespace: CN) do
loader.do_not_eager_load("rd1/m")
Expand Down

0 comments on commit 31c8938

Please sign in to comment.