-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
require "json" | ||
require "test_helper" | ||
|
||
class BunInstallerTest < ActiveSupport::TestCase | ||
include RailsAppHelpers | ||
|
||
test "installer for bun" do | ||
with_new_rails_app do | ||
_out, _err = run_command("bin/rails", "javascript:install:bun") | ||
|
||
assert_match "js: bun run build --watch", File.read("Procfile.dev") | ||
|
||
assert_equal File.read("#{__dir__}/../../lib/install/bun/bun.config.js"), File.read("bun.config.js") | ||
|
||
JSON.parse(File.read("package.json")).tap do |package| | ||
assert_equal("bun bun.config.js", package["scripts"]["build"]) | ||
end | ||
|
||
if sprockets? | ||
assert_match "//= link_tree ../builds", File.read("app/assets/config/manifest.js") | ||
end | ||
end | ||
end | ||
|
||
test "installer with pre-existing Procfile" do | ||
with_new_rails_app do | ||
File.write("Procfile.dev", "pre: existing\n") | ||
_out, _err = run_command("bin/rails", "javascript:install:bun") | ||
|
||
assert_equal <<~YAML, File.read("Procfile.dev") | ||
pre: existing | ||
js: bun run build --watch | ||
YAML | ||
end | ||
end | ||
end |