Skip to content

Commit 7c1f8e1

Browse files
committed
Add test for IEx ls helper
1 parent efcd164 commit 7c1f8e1

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

lib/iex/test/iex/helpers_test.exs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1200,6 +1200,19 @@ defmodule IEx.HelpersTest do
12001200
test "lists the given directory" do
12011201
assert capture_io(fn -> ls("~") end) == capture_io(fn -> ls(System.user_home()) end)
12021202
end
1203+
1204+
test "returns an existing file" do
1205+
File.cd!(iex_path(), fn ->
1206+
assert capture_io(fn -> ls("mix.exs") end) == Path.join(iex_path(), "mix.exs") <> "\n"
1207+
end)
1208+
end
1209+
1210+
test "prints an error if directory doesn't exist" do
1211+
File.cd!(iex_path(), fn ->
1212+
assert capture_io(fn -> ls("unknown_dir") end) ==
1213+
"No such file or directory unknown_dir\n"
1214+
end)
1215+
end
12031216
end
12041217

12051218
describe "exports" do

0 commit comments

Comments
 (0)