From 7aa0bbe15a05507b0628e8cd675df233df0bed91 Mon Sep 17 00:00:00 2001 From: Alexandre Terrasa Date: Fri, 4 Mar 2022 11:21:19 -0500 Subject: [PATCH] Update gem_spec tests Signed-off-by: Alexandre Terrasa --- spec/tapioca/cli/gem_spec.rb | 72 ++++++++++++++++++++++++++++++++++-- 1 file changed, 69 insertions(+), 3 deletions(-) diff --git a/spec/tapioca/cli/gem_spec.rb b/spec/tapioca/cli/gem_spec.rb index b9e2ca2ba..1dc500dba 100644 --- a/spec/tapioca/cli/gem_spec.rb +++ b/spec/tapioca/cli/gem_spec.rb @@ -1346,7 +1346,7 @@ def quux(x); end result = @project.tapioca("gem --all") assert_includes(result.out, <<~OUT) - Typechecking RBI files... Done + Checking generated RBI files... Done Changed strictness of sorbet/rbi/gems/bar@0.3.0.rbi to `typed: false` (conflicting with DSL files) @@ -1372,7 +1372,7 @@ def quux(x); end result = @project.tapioca("gem foo bar") assert_includes(result.out, <<~OUT) - Typechecking RBI files... Done + Checking generated RBI files... Done Changed strictness of sorbet/rbi/gems/bar@0.3.0.rbi to `typed: false` (conflicting with DSL files) OUT @@ -1398,7 +1398,7 @@ def foo; end result = @project.tapioca("gem --dsl-dir sorbet/rbi/shims") assert_includes(result.out, <<~OUT) - Typechecking RBI files... Done + Checking generated RBI files... Done Changed strictness of sorbet/rbi/gems/foo@0.0.1.rbi to `typed: false` (conflicting with DSL files) OUT @@ -1415,6 +1415,72 @@ def foo; end @project.remove("sorbet/rbi/shims/foo.rbi") end end + + describe "sanity" do + before(:all) do + foo = mock_gem("foo", "0.0.1") do + write("lib/foo.rb", FOO_RB) + end + + bar = mock_gem("bar", "1.0.0") do + write("lib/bar.rb", BAR_RB) + end + + @project.require_mock_gem(foo) + @project.require_mock_gem(bar) + @project.bundle_install + @project.tapioca("init") + end + + after do + project.remove("sorbet/rbi/gems") + project.remove("sorbet/rbi/dsl") + end + + it "must display an error message when a generated gem RBI file contains a parse error" do + @project.write("sorbet/rbi/gems/bar@1.0.0.rbi", <<~RBI) + # typed: true + + module Bar + # This method is missing a `)` + sig { params(block: T.proc.params(x: T.any(String, Integer).void).void } + def bar(&block); end + end + RBI + + result = @project.tapioca("gem foo") + + assert_includes(result.err, <<~ERR) + ##### INTERNAL ERROR ##### + + There are parse errors in the generated RBI files. + + This seems related to a bug in Tapioca. + Please open an issue at https://github.com/Shopify/tapioca/issues/new with the following information: + + Tapioca v#{Tapioca::VERSION} + + Command: + bin/tapioca gem foo + + Gems: + ERR + + assert_includes(result.err, <<~ERR) + foo (0.0.1) + ERR + + assert_includes(result.err, <<~ERR) + Errors: + sorbet/rbi/gems/bar@1.0.0.rbi:5: unexpected token tRCURLY (2001) + sorbet/rbi/gems/bar@1.0.0.rbi:6: unexpected token "end" (2001) + + ########################## + ERR + + refute_success_status(result) + end + end end end end