Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/shell/command-processor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def open(path, mode = nil, perm = 0666, &b)
# call-seq:
# unlink(path)
#
# See IO.unlink when +path+ is a file.
# See File.unlink when +path+ is a file.
#
# See Dir.unlink when +path+ is a directory.
#
Expand All @@ -140,7 +140,7 @@ def unlink(path)
if File.directory?(path)
Dir.unlink(path)
else
IO.unlink(path)
File.unlink(path)
end
Void.new(@shell)
end
Expand Down
24 changes: 24 additions & 0 deletions test/shell/test_command_processor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,30 @@ def test_test
File.unlink(path)
end

def test_unlink_file
name = "foo"
path = File.join(@tmpdir, name)
open(path, "w") {}

@shell.cd(@tmpdir)
assert_kind_of(Shell::Void, @shell.unlink(name))
assert_not_send([File, :exist?, path])
ensure
File.unlink(path) if File.exist?(path)
end

def test_unlink_directory
name = "foo"
path = File.join(@tmpdir, name)
Dir.mkdir(path)

@shell.cd(@tmpdir)
assert_kind_of(Shell::Void, @shell.unlink(name))
assert_not_send([File, :exist?, path])
ensure
Dir.rmdir(path) if File.exist?(path)
end

def test_option_type
name = 'foo.cmd'
path = File.join(@tmpdir, name)
Expand Down
⌂ Proxy