Skip to content

Commit 296c077

Browse files
committed
Add test for DSL loader
1 parent ffc509c commit 296c077

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

spec/spec_helper.rb

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
require "rails_spec_helper"
1818
require "mocha/minitest"
1919

20+
require "debug/prelude"
21+
2022
backtrace_filter = Minitest::ExtensibleBacktraceFilter.default_filter
2123
backtrace_filter.add_filter(%r{gems/sorbet-runtime})
2224
backtrace_filter.add_filter(%r{gems/railties})

spec/tapioca/loaders/dsl_spec.rb

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# typed: true
2+
# frozen_string_literal: true
3+
4+
require "spec_helper"
5+
6+
module Tapioca
7+
module Loaders
8+
class DslSpec < SpecWithProject
9+
describe "#load_application" do
10+
it "loads the application if `lsp_addon` is false" do
11+
outputs = capture_io do
12+
Loaders::Dsl.load_application(
13+
tapioca_path: @project.absolute_path,
14+
app_root: @project.absolute_path,
15+
lsp_addon: false,
16+
)
17+
end
18+
19+
output = outputs.first # TODO: why are there two outputs?
20+
21+
assert_match(/Loading DSL extension classes.../, output)
22+
assert_match(/Loading Rails application/, output)
23+
assert_match(/Loading DSL compiler classes.../, output)
24+
end
25+
26+
it "does not load the application if `lsp_addon` is true" do
27+
outputs = capture_io do
28+
Loaders::Dsl.load_application(
29+
tapioca_path: @project.absolute_path,
30+
app_root: @project.absolute_path,
31+
lsp_addon: true,
32+
)
33+
end
34+
35+
output = outputs.first # TODO: why are there two outputs?
36+
37+
assert_match(/Loading DSL extension classes.../, output)
38+
refute_match(/Loading Rails application/, output)
39+
assert_match(/Loading DSL compiler classes.../, output)
40+
end
41+
end
42+
end
43+
end
44+
end

0 commit comments

Comments
 (0)