Skip to content

Commit

Permalink
Update gem_spec tests
Browse files Browse the repository at this point in the history
Signed-off-by: Alexandre Terrasa <alexandre.terrasa@shopify.com>
  • Loading branch information
Morriar committed Mar 4, 2022
1 parent 05ec3dc commit 7aa0bbe
Showing 1 changed file with 69 additions and 3 deletions.
72 changes: 69 additions & 3 deletions spec/tapioca/cli/gem_spec.rb
Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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

0 comments on commit 7aa0bbe

Please sign in to comment.