From a29226bb42584501e3fff4037c38005cc0bff9a4 Mon Sep 17 00:00:00 2001 From: Jason Laster Date: Sun, 8 Dec 2013 21:48:52 -0500 Subject: [PATCH] Update ShellCommand so that autocompletes to --- lib/pry/commands/shell_command.rb | 3 ++- spec/commands/shell_command_spec.rb | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/pry/commands/shell_command.rb b/lib/pry/commands/shell_command.rb index 4f87de92..69559405 100644 --- a/lib/pry/commands/shell_command.rb +++ b/lib/pry/commands/shell_command.rb @@ -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 diff --git a/spec/commands/shell_command_spec.rb b/spec/commands/shell_command_spec.rb index 567f9c6b..a0ee03ba 100644 --- a/spec/commands/shell_command_spec.rb +++ b/spec/commands/shell_command_spec.rb @@ -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