Skip to content

Commit

Permalink
Add test for DSL loader
Browse files Browse the repository at this point in the history
  • Loading branch information
andyw8 committed Nov 28, 2024
1 parent ebb0cc2 commit 41a90b5
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
2 changes: 2 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
require "spec_with_project"
require "rails_spec_helper"

require "debug/prelude"

backtrace_filter = Minitest::ExtensibleBacktraceFilter.default_filter
backtrace_filter.add_filter(%r{gems/sorbet-runtime})
backtrace_filter.add_filter(%r{gems/railties})
Expand Down
44 changes: 44 additions & 0 deletions spec/tapioca/loaders/dsl_spec.rb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 41a90b5

Please sign in to comment.