Update ShellCommand so that autocompletes to

This commit is contained in:
Jason Laster 2013-12-08 21:48:52 -05:00 committed by Jason Laster
parent 35a4b44b40
commit a29226bb42
2 changed files with 9 additions and 1 deletions

View File

@ -16,7 +16,7 @@ class Pry
BANNER
def process(cmd)
if cmd =~ /^cd\s+(.+)/i
if cmd =~ /^cd\s*(.*)/i
process_cd parse_destination($1)
else
pass_block(cmd)
@ -36,6 +36,7 @@ class Pry
private
def parse_destination(dest)
return "~" if dest.empty?
return dest unless dest == "-"
state.old_pwd || raise(CommandError, "No prior directory available")
end

View File

@ -31,6 +31,13 @@ describe "Command::ShellCommand" do
end
end
describe "given an empty string" do
it "sends ~ to File.expand_path" do
Dir.expects(:chdir).with(File.expand_path("~"))
@t.eval ".cd "
end
end
describe "given a dash" do
describe "given no prior directory" do
it "raises the correct error" do