summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyrylo Silin <kyrylosilin@gmail.com>2013-03-10 09:41:42 +0200
committerKyrylo Silin <kyrylosilin@gmail.com>2013-03-12 20:53:28 +0200
commitfed97f0738cf88f1e8176296a630235dae567be1 (patch)
tree2be377a23c90ffc80780c07ff2d853c031968357
parent629bb75cc6f79765fd1cdcff91c5d7f635a47162 (diff)
downloadpry-fed97f0738cf88f1e8176296a630235dae567be1.tar.gz
Hist: fix `--exclude-pry` switch
Fix issue #874 (hist -e breaks with TypeError: can't convert Pry::Code::LOC to String) And add a test for that switch.
-rw-r--r--lib/pry/commands/hist.rb4
-rw-r--r--spec/commands/hist_spec.rb6
2 files changed, 9 insertions, 1 deletions
diff --git a/lib/pry/commands/hist.rb b/lib/pry/commands/hist.rb
index eee89b18..cf96ba63 100644
--- a/lib/pry/commands/hist.rb
+++ b/lib/pry/commands/hist.rb
@@ -55,7 +55,9 @@ class Pry
end
if opts.present?(:'exclude-pry')
- @history = @history.select { |l, ln| !command_set.valid_command?(l) }
+ @history = @history.select do |loc|
+ !command_set.valid_command?(loc.line)
+ end
end
if opts.present?(:save)
diff --git a/spec/commands/hist_spec.rb b/spec/commands/hist_spec.rb
index 9d0e231a..d0545609 100644
--- a/spec/commands/hist_spec.rb
+++ b/spec/commands/hist_spec.rb
@@ -169,4 +169,10 @@ describe "hist" do
@t.eval("a").should == 2
@t.eval("hist").lines.to_a.size.should == 5
end
+
+ it "excludes Pry commands from the history with `-e` switch" do
+ @hist.push('a = 20')
+ @hist.push('ls')
+ pry_eval('hist -e').should == "1: a = 20\n"
+ end
end