From 296c077de1acc139c99c558a47d1928c5a435c36 Mon Sep 17 00:00:00 2001 From: Andy Waite <13400+andyw8@users.noreply.github.com> Date: Thu, 28 Nov 2024 14:55:54 -0500 Subject: [PATCH] Add test for DSL loader --- spec/spec_helper.rb | 2 ++ spec/tapioca/loaders/dsl_spec.rb | 44 ++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 spec/tapioca/loaders/dsl_spec.rb diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 890be81f5..2ce383eea 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -17,6 +17,8 @@ require "rails_spec_helper" require "mocha/minitest" +require "debug/prelude" + backtrace_filter = Minitest::ExtensibleBacktraceFilter.default_filter backtrace_filter.add_filter(%r{gems/sorbet-runtime}) backtrace_filter.add_filter(%r{gems/railties}) diff --git a/spec/tapioca/loaders/dsl_spec.rb b/spec/tapioca/loaders/dsl_spec.rb new file mode 100644 index 000000000..a8e0d1ba9 --- /dev/null +++ b/spec/tapioca/loaders/dsl_spec.rb @@ -0,0 +1,44 @@ +# typed: true +# frozen_string_literal: true + +require "spec_helper" + +module Tapioca + module Loaders + class DslSpec < SpecWithProject + describe "#load_application" do + it "loads the application if `lsp_addon` is false" do + outputs = capture_io do + Loaders::Dsl.load_application( + tapioca_path: @project.absolute_path, + app_root: @project.absolute_path, + lsp_addon: false, + ) + end + + output = outputs.first # TODO: why are there two outputs? + + assert_match(/Loading DSL extension classes.../, output) + assert_match(/Loading Rails application/, output) + assert_match(/Loading DSL compiler classes.../, output) + end + + it "does not load the application if `lsp_addon` is true" do + outputs = capture_io do + Loaders::Dsl.load_application( + tapioca_path: @project.absolute_path, + app_root: @project.absolute_path, + lsp_addon: true, + ) + end + + output = outputs.first # TODO: why are there two outputs? + + assert_match(/Loading DSL extension classes.../, output) + refute_match(/Loading Rails application/, output) + assert_match(/Loading DSL compiler classes.../, output) + end + end + end + end +end