Skip to content

Commit aceac7a

Browse files
test: cover declined igniter.install dependency prompt (#394)
1 parent e9d0084 commit aceac7a

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

test/mix/tasks/igniter.install_test.exs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,17 @@
44

55
defmodule Mix.Tasks.Igniter.InstallTest do
66
use ExUnit.Case
7+
use Mimic
78

89
import ExUnit.CaptureIO
910

11+
setup_all do
12+
Mimic.copy(Igniter.Mix.Task)
13+
:ok
14+
end
15+
16+
setup :verify_on_exit!
17+
1018
test "it delegates --help to mix help" do
1119
expected =
1220
capture_io(fn ->
@@ -45,6 +53,24 @@ defmodule Mix.Tasks.Igniter.InstallTest do
4553
refute String.contains?(output, "jason\nCompiling")
4654
end
4755

56+
test "does not report success when installation is declined" do
57+
mix_exs_before = File.read!("test_project/mix.exs")
58+
59+
stub(Igniter.Mix.Task, :tty?, fn -> true end)
60+
61+
output =
62+
capture_io("n\n", fn ->
63+
File.cd!("test_project", fn ->
64+
Igniter.Util.Install.install([{:jason, "~> 1.0"}], [])
65+
end)
66+
end)
67+
68+
mix_exs_after = File.read!("test_project/mix.exs")
69+
70+
assert mix_exs_after == mix_exs_before
71+
refute String.contains?(output, "Successfully installed")
72+
end
73+
4874
test "displays additional information with `--verbose` option" do
4975
output = cmd!("mix", ["igniter.install", "jason", "--verbose"], cd: "test_project")
5076
assert String.contains?(output, "jason\nCompiling")

0 commit comments

Comments
 (0)