From caeb6b58b662d24d9523c9e676b3e5e9adcd58d4 Mon Sep 17 00:00:00 2001 From: Kyrylo Silin Date: Fri, 6 Jul 2012 21:23:31 +0300 Subject: [PATCH] Refactor tests for command groups We should not rely on default commands, because they can be removed or shuffled around in the future. Use our custom command in the tests. Also, add a test that ensures that a group does not disappear after the call without parameters. Reported-by: John Mair Signed-off-by: Kyrylo Silin --- test/test_command.rb | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/test/test_command.rb b/test/test_command.rb index 746d4ee2..bde244de 100644 --- a/test/test_command.rb +++ b/test/test_command.rb @@ -696,17 +696,25 @@ describe "Pry::Command" do describe 'group' do before do - @set.import Pry::DefaultCommands::Cd - end - - it 'should not change once it is initialized' do - @set.commands["cd"].group("-==CD COMMAND==-") - @set.commands["cd"].group.should == "Context" + @set.import( + Pry::CommandSet.new do + create_command("magic") { group("Not for a public use") } + end + ) end it 'should be correct for default commands' do - @set.commands["cd"].group.should == "Context" @set.commands["help"].group.should == "Help" end + + it 'should not change once it is initialized' do + @set.commands["magic"].group("-==CD COMMAND==-") + @set.commands["magic"].group.should == "Not for a public use" + end + + it 'should not disappear after the call without parameters' do + @set.commands["magic"].group + @set.commands["magic"].group.should == "Not for a public use" + end end end