Improve command handling

This commit is contained in:
2019-10-06 18:30:36 +03:00
parent 927ca47b04
commit 3669e31c66
3 changed files with 20 additions and 3 deletions

View File

@ -40,4 +40,17 @@ describe CLI::CommandRouter do
router.handle "plus 1 3 6"
x.should eq 10
end
it "should match commands from begin of string" do
router = CLI::CommandRouter.new
x = 5
router.add "plus" do |p|
x += 10
end
router.add "mult and plus" do |p|
x = x * 2 + 10
end
router.handle "mult and plus"
x.should eq 20
end
end