Skip to content

Commit

Permalink
Add a test that demonstrates using Zeitwerk to discover constants tha…
Browse files Browse the repository at this point in the history
…t are only ever defined as namespaces
  • Loading branch information
egiurleo committed Jan 10, 2023
1 parent 6d9d631 commit b1beb6c
Showing 1 changed file with 0 additions and 58 deletions.
58 changes: 0 additions & 58 deletions spec/tapioca/cli/gem_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1467,64 +1467,6 @@ class User; end
assert_success_status(result)
end

describe "ObjectSpace WeakMap generation" do
before do
@project = mock_project(sorbet_dependency: false)
end

after do
@project.destroy
end

it "is a generic type with Sorbet < 0.5.10587" do
foo = mock_gem("foo", "0.0.1") do
write("lib/foo.rb", <<~RB)
Foo = ObjectSpace::WeakMap.new
RB
end

@project.gemfile(@project.tapioca_gemfile)
@project.require_mock_gem(foo)
@project.require_real_gem("sorbet-static", "0.5.10585")
@project.bundle_install
@project.tapioca("gem")

assert_project_file_equal("sorbet/rbi/gems/foo@0.0.1.rbi", <<~RBI)
# typed: true
# DO NOT EDIT MANUALLY
# This is an autogenerated file for types exported from the `foo` gem.
# Please instead update this file by running `bin/tapioca gem foo`.
Foo = T.let(T.unsafe(nil), ObjectSpace::WeakMap[T.untyped])
RBI
end

it "is a non-generic type with Sorbet >= 0.5.10587" do
foo = mock_gem("foo", "0.0.1") do
write("lib/foo.rb", <<~RB)
Foo = ObjectSpace::WeakMap.new
RB
end

@project.gemfile(@project.tapioca_gemfile)
@project.require_mock_gem(foo)
@project.require_real_gem("sorbet-static", "0.5.10588")
@project.bundle_install
@project.tapioca("gem")

assert_project_file_equal("sorbet/rbi/gems/foo@0.0.1.rbi", <<~RBI)
# typed: true
# DO NOT EDIT MANUALLY
# This is an autogenerated file for types exported from the `foo` gem.
# Please instead update this file by running `bin/tapioca gem foo`.
Foo = T.let(T.unsafe(nil), ObjectSpace::WeakMap)
RBI
end
end

it "generates correct RBIs for a Rails engine" do
@project.require_real_gem("rails", "7.0.4")
@project.require_real_gem("turbo-rails", "1.3.2")
Expand Down

0 comments on commit b1beb6c

Please sign in to comment.