Skip to content

Commit e0c1676

Browse files
Merge pull request #209 from jonathanhefner/json-command-test
Test `json` command using Minitest
2 parents 6fadba1 + d57923c commit e0c1676

File tree

2 files changed

+27
-5
lines changed

2 files changed

+27
-5
lines changed

.github/workflows/ci.yml

-5
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,3 @@ jobs:
4141
- name: Run tests
4242
run: |
4343
bundle exec rake
44-
45-
- name: Ensure json command prints an importmap
46-
run: |
47-
cp lib/install/bin/importmap test/dummy/bin/importmap
48-
test/dummy/bin/importmap json | jq -e .imports

test/commands_test.rb

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
require "test_helper"
2+
require "json"
3+
4+
class CommandsTest < ActiveSupport::TestCase
5+
include ActiveSupport::Testing::Isolation
6+
7+
setup do
8+
@tmpdir = Dir.mktmpdir
9+
FileUtils.cp_r("#{__dir__}/dummy", @tmpdir)
10+
Dir.chdir("#{@tmpdir}/dummy")
11+
FileUtils.cp("#{__dir__}/../lib/install/bin/importmap", "bin")
12+
end
13+
14+
teardown do
15+
FileUtils.remove_entry(@tmpdir) if @tmpdir
16+
end
17+
18+
test "json command prints JSON with imports" do
19+
out, err = run_importmap_command("json")
20+
assert_includes JSON.parse(out), "imports"
21+
end
22+
23+
private
24+
def run_importmap_command(command, *args)
25+
capture_subprocess_io { system("bin/importmap", command, *args, exception: true) }
26+
end
27+
end

0 commit comments

Comments
 (0)