lib/tapioca/helpers/test/dsl_compiler.rb in tapioca-0.13.3 vs lib/tapioca/helpers/test/dsl_compiler.rb in tapioca-0.14.3

- old
+ new

@@ -2,10 +2,11 @@ # frozen_string_literal: true require "tapioca/helpers/test/content" require "tapioca/helpers/test/isolation" require "tapioca/helpers/test/template" +require "tapioca/helpers/sorbet_helper" module Tapioca module Helpers module Test module DslCompiler @@ -51,10 +52,12 @@ end class CompilerContext extend T::Sig + include SorbetHelper + sig { returns(T.class_of(Tapioca::Dsl::Compiler)) } attr_reader :compiler_class sig { returns(T::Array[T.class_of(Tapioca::Dsl::Compiler)]) } attr_reader :other_compiler_classes @@ -93,10 +96,29 @@ constant = Object.const_get(constant_name) compiler = compiler_class.new(pipeline, file.root, constant) compiler.decorate - Tapioca::DEFAULT_RBI_FORMATTER.print_file(file) + rbi = Tapioca::DEFAULT_RBI_FORMATTER.print_file(file) + result = sorbet( + "--no-config", + "--stop-after", + "parser", + "-e", + "\"#{rbi}\"", + ) + + unless result.status + raise(SyntaxError, <<~MSG) + Expected generated RBI file for `#{constant_name}` to not have any parsing errors. + + Got these parsing errors: + + #{result.err} + MSG + end + + rbi end sig { returns(T::Array[String]) } def errors pipeline.errors