1
0
Fork 0
mirror of https://github.com/pry/pry.git synced 2022-11-09 12:35:05 -05:00

improved some command code and added more tests

This commit is contained in:
John Mair 2011-11-16 03:09:16 +13:00
parent a3723baaab
commit 747d80df47
2 changed files with 13 additions and 3 deletions

View file

@ -160,7 +160,7 @@ class Pry
instance_exec(*args, &block) instance_exec(*args, &block)
instance_exec(*args, &prev_block) instance_exec(*args, &prev_block)
end end
commands[cmd.name].block = wrapper_block cmd.block = wrapper_block
end end
# Execute a block of code after a command is invoked. The block also # Execute a block of code after a command is invoked. The block also
@ -180,7 +180,7 @@ class Pry
instance_exec(*args, &prev_block) instance_exec(*args, &prev_block)
instance_exec(*args, &block) instance_exec(*args, &block)
end end
commands[cmd.name].block = wrapper_block cmd.block = wrapper_block
end end
def each &block def each &block

View file

@ -142,13 +142,23 @@ describe Pry::CommandSet do
run.should == true run.should == true
end end
it 'should be able to change the descriptions of methods' do it 'should be able to change the descriptions of commands' do
@set.command('foo', 'bar') {} @set.command('foo', 'bar') {}
@set.desc 'foo', 'baz' @set.desc 'foo', 'baz'
@set.commands['foo'].description.should == 'baz' @set.commands['foo'].description.should == 'baz'
end end
it 'should get the descriptions of commands' do
@set.command('foo', 'bar') {}
@set.desc('foo').should == 'bar'
end
it 'should get the descriptions of commands, by listing' do
@set.command(/^foo1/, 'bar', :listing => 'foo') {}
@set.desc('foo').should == 'bar'
end
it 'should return Pry::CommandContext::VOID_VALUE for commands by default' do it 'should return Pry::CommandContext::VOID_VALUE for commands by default' do
@set.command('foo') { 3 } @set.command('foo') { 3 }
@set.run_command(@ctx, 'foo').should == Pry::CommandContext::VOID_VALUE @set.run_command(@ctx, 'foo').should == Pry::CommandContext::VOID_VALUE