Skip to content

Commit 71d6911

Browse files
committed
Tests for bun
Ensures: 1. The bun config file is copied 2. The bun command is used as a build script 3. The Procfile.dev is copied / modified
1 parent 0adcb7b commit 71d6911

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

test/installer/bun_test.rb

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
require "json"
2+
require "test_helper"
3+
4+
class BunInstallerTest < ActiveSupport::TestCase
5+
include RailsAppHelpers
6+
7+
test "installer for bun" do
8+
with_new_rails_app do
9+
_out, _err = run_command("bin/rails", "javascript:install:bun")
10+
11+
assert_match "js: bun run build --watch", File.read("Procfile.dev")
12+
13+
assert_equal File.read("#{__dir__}/../../lib/install/bun/bun.config.js"), File.read("bun.config.js")
14+
15+
JSON.parse(File.read("package.json")).tap do |package|
16+
assert_equal("bun bun.config.js", package["scripts"]["build"])
17+
end
18+
19+
if sprockets?
20+
assert_match "//= link_tree ../builds", File.read("app/assets/config/manifest.js")
21+
end
22+
end
23+
end
24+
25+
test "installer with pre-existing Procfile" do
26+
with_new_rails_app do
27+
File.write("Procfile.dev", "pre: existing\n")
28+
_out, _err = run_command("bin/rails", "javascript:install:bun")
29+
30+
assert_equal <<~YAML, File.read("Procfile.dev")
31+
pre: existing
32+
js: bun run build --watch
33+
YAML
34+
end
35+
end
36+
end

0 commit comments

Comments
 (0)