Skip to content

Commit

Permalink
Update dsl_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 7aa0bbe commit 229791c
Showing 1 changed file with 86 additions and 25 deletions.
111 changes: 86 additions & 25 deletions spec/tapioca/cli/dsl_spec.rb
Expand Up @@ -94,8 +94,8 @@ class Post
Done
Typechecking RBI files... Done
No error found
Checking generated RBI files... Done
No error found
All operations performed in working directory.
Please review changes and commit them.
Expand Down Expand Up @@ -207,8 +207,8 @@ class Comment
Done
Typechecking RBI files... Done
No error found
Checking generated RBI files... Done
No error found
All operations performed in working directory.
Please review changes and commit them.
Expand Down Expand Up @@ -290,8 +290,8 @@ class Role
Done
Typechecking RBI files... Done
No error found
Checking generated RBI files... Done
No error found
All operations performed in working directory.
Please review changes and commit them.
Expand Down Expand Up @@ -357,8 +357,8 @@ class Comment
Done
Typechecking RBI files... Done
No error found
Checking generated RBI files... Done
No error found
All operations performed in working directory.
Please review changes and commit them.
Expand Down Expand Up @@ -409,8 +409,8 @@ class Comment
Done
Typechecking RBI files... Done
No error found
Checking generated RBI files... Done
No error found
All operations performed in working directory.
Please review changes and commit them.
Expand Down Expand Up @@ -444,8 +444,8 @@ class Post
Done
Typechecking RBI files... Done
No error found
Checking generated RBI files... Done
No error found
All operations performed in working directory.
Please review changes and commit them.
Expand Down Expand Up @@ -517,8 +517,8 @@ class Post
Done
Typechecking RBI files... Done
No error found
Checking generated RBI files... Done
No error found
All operations performed in working directory.
Please review changes and commit them.
Expand Down Expand Up @@ -632,8 +632,8 @@ class User; end
Done
Typechecking RBI files... Done
No error found
Checking generated RBI files... Done
No error found
All operations performed in working directory.
Please review changes and commit them.
Expand Down Expand Up @@ -714,8 +714,8 @@ def self.gather_constants
Done
Typechecking RBI files... Done
No error found
Checking generated RBI files... Done
No error found
All operations performed in working directory.
Please review changes and commit them.
Expand Down Expand Up @@ -806,8 +806,8 @@ def self.gather_constants
Done
Typechecking RBI files... Done
No error found
Checking generated RBI files... Done
No error found
All operations performed in working directory.
Please review changes and commit them.
Expand Down Expand Up @@ -913,8 +913,8 @@ def self.gather_constants
Done
Typechecking RBI files... Done
No error found
Checking generated RBI files... Done
No error found
All operations performed in working directory.
Please review changes and commit them.
Expand Down Expand Up @@ -1028,8 +1028,8 @@ class Image
Done
Typechecking RBI files... Done
No error found
Checking generated RBI files... Done
No error found
All operations performed in working directory.
Please review changes and commit them.
Expand Down Expand Up @@ -1263,7 +1263,7 @@ class Post
result = @project.tapioca("dsl Post")

assert_includes(result.out, <<~OUT)
Typechecking RBI files... Done
Checking generated RBI files... Done
Changed strictness of sorbet/rbi/gems/bar@1.0.0.rbi to `typed: false` (conflicting with DSL files)
OUT
Expand All @@ -1279,6 +1279,67 @@ class Post
@project.remove("sorbet/rbi/dsl")
end
end

describe "sanity" do
before(:all) do
@project.require_real_gem("smart_properties", "1.15.0")
@project.bundle_install
@project.tapioca("init")

@project.write("lib/post.rb", <<~RB)
require "smart_properties"
class Post
include SmartProperties
property :title, accepts: String
end
RB
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/dsl/bar.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("dsl Post")

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 dsl Post
Compilers:
Tapioca::Dsl::Compilers::SmartProperties
Errors:
sorbet/rbi/dsl/bar.rbi:5: unexpected token tRCURLY (2001)
sorbet/rbi/dsl/bar.rbi:6: unexpected token "end" (2001)
##########################
ERR

refute_success_status(result)
end
end
end
end
end

0 comments on commit 229791c

Please sign in to comment.