diff options
author | Kyrylo Silin <kyrylosilin@gmail.com> | 2013-03-10 09:41:42 +0200 |
---|---|---|
committer | Kyrylo Silin <kyrylosilin@gmail.com> | 2013-03-12 20:53:28 +0200 |
commit | fed97f0738cf88f1e8176296a630235dae567be1 (patch) | |
tree | 2be377a23c90ffc80780c07ff2d853c031968357 | |
parent | 629bb75cc6f79765fd1cdcff91c5d7f635a47162 (diff) | |
download | pry-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.rb | 4 | ||||
-rw-r--r-- | spec/commands/hist_spec.rb | 6 |
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 |