mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
Refactor 'command_lookup'
Thanks to Bacon we can use `before` method to simplify our life. And, blimey, I accidentally left some unwanted code after myself! Signed-off-by: Kyrylo Silin <kyrylosilin@gmail.com>
This commit is contained in:
parent
73820fa08a
commit
5cb356f731
1 changed files with 9 additions and 11 deletions
|
@ -39,32 +39,30 @@ describe Pry::CodeObject do
|
|||
end
|
||||
|
||||
describe 'commands lookup' do
|
||||
before do
|
||||
@p = Pry.new
|
||||
end
|
||||
|
||||
it 'works' do
|
||||
p = Pry.new
|
||||
p.commands.command "jeremy-jones" do
|
||||
@p.commands.command "jeremy-jones" do
|
||||
"lobster"
|
||||
end
|
||||
m = Pry::CodeObject.lookup("jeremy-jones", binding, p)
|
||||
m = Pry::CodeObject.lookup("jeremy-jones", binding, @p)
|
||||
(m <= Pry::Command).should == true
|
||||
m.source.should =~ /lobster/
|
||||
end
|
||||
|
||||
it 'looks up commands by :listing name as well' do
|
||||
p = Pry.new
|
||||
p.commands.command /jeremy-.*/, "", :listing => "jeremy-baby" do
|
||||
@p.commands.command /jeremy-.*/, "", :listing => "jeremy-baby" do
|
||||
"lobster"
|
||||
end
|
||||
m = Pry::CodeObject.lookup("jeremy-baby", binding, p)
|
||||
m = Pry::CodeObject.lookup("jeremy-baby", binding, @p)
|
||||
(m <= Pry::Command).should == true
|
||||
m.source.should =~ /lobster/
|
||||
end
|
||||
|
||||
it 'finds nothing when passing nil as the first argument' do
|
||||
p = Pry.new
|
||||
p.commands.command /kierkegaard-.*/, '', :listing => 'kierkegaard-baby' do
|
||||
"lobster"
|
||||
end
|
||||
Pry::CodeObject.lookup(nil, binding, p).should == nil
|
||||
Pry::CodeObject.lookup(nil, binding, @p).should == nil
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue