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

rename Pry::CommandSet#commands as Pry::CommandSet#to_hash.

'Pry.commands.commands' gone in favor of 'Pry.commands.to_hash' or as
using a CommandSet as an enumerable (Pry.commands.each etc) instead.
This commit is contained in:
Robert Gleeson 2014-02-04 05:12:28 +01:00
parent c283e644b5
commit 77a9c00067
7 changed files with 81 additions and 73 deletions

View file

@ -167,7 +167,7 @@ describe Pry::CommandSet do
it 'should set the descriptions of commands' do
@set.command('foo', 'some stuff') {}
@set.commands['foo'].description.should == 'some stuff'
@set['foo'].description.should == 'some stuff'
end
describe "aliases" do
@ -176,8 +176,8 @@ describe Pry::CommandSet do
@set.command('foo', 'stuff') { run = true }
@set.alias_command 'bar', 'foo'
@set.commands['bar'].match.should == 'bar'
@set.commands['bar'].description.should == 'Alias for `foo`'
@set['bar'].match.should == 'bar'
@set['bar'].description.should == 'Alias for `foo`'
@set.run_command @ctx, 'bar'
run.should == true
@ -188,12 +188,12 @@ describe Pry::CommandSet do
@set.command('foo', 'stuff', :shellwords => true, :interpolate => false) { run = true }
@set.alias_command 'bar', 'foo'
@set.commands['bar'].options[:shellwords].should == @set.commands['foo'].options[:shellwords]
@set.commands['bar'].options[:interpolate].should == @set.commands['foo'].options[:interpolate]
@set['bar'].options[:shellwords].should == @set['foo'].options[:shellwords]
@set['bar'].options[:interpolate].should == @set['foo'].options[:interpolate]
# however some options should not be inherited
@set.commands['bar'].options[:listing].should.not == @set.commands['foo'].options[:listing]
@set.commands['bar'].options[:listing].should == "bar"
@set['bar'].options[:listing].should.not == @set['foo'].options[:listing]
@set['bar'].options[:listing].should == "bar"
end
it 'should be able to specify alias\'s description when aliasing' do
@ -201,8 +201,8 @@ describe Pry::CommandSet do
@set.command('foo', 'stuff') { run = true }
@set.alias_command 'bar', 'foo', :desc => "tobina"
@set.commands['bar'].match.should == 'bar'
@set.commands['bar'].description.should == "tobina"
@set['bar'].match.should == 'bar'
@set['bar'].description.should == "tobina"
@set.run_command @ctx, 'bar'
run.should == true
@ -213,8 +213,8 @@ describe Pry::CommandSet do
@set.command(/^foo1/, 'stuff', :listing => 'foo') { run = true }
@set.alias_command 'bar', 'foo1'
@set.commands['bar'].match.should == 'bar'
@set.commands['bar'].description.should == 'Alias for `foo1`'
@set['bar'].match.should == 'bar'
@set['bar'].description.should == 'Alias for `foo1`'
@set.run_command @ctx, 'bar'
run.should == true
@ -225,7 +225,7 @@ describe Pry::CommandSet do
@set.command(/^foo1/, 'stuff', :listing => 'foo') { run = true }
@set.alias_command /^b.r/, 'foo1', :listing => "bar"
@set.commands[/^b.r/].options[:listing].should == "bar"
@set.to_hash[/^b.r/].options[:listing].should == "bar"
end
it "should set description to default if description parameter is nil" do
@ -233,7 +233,7 @@ describe Pry::CommandSet do
@set.command(/^foo1/, 'stuff', :listing => 'foo') { run = true }
@set.alias_command "bar", 'foo1'
@set.commands["bar"].description.should == "Alias for `foo1`"
@set["bar"].description.should == "Alias for `foo1`"
end
end
@ -241,7 +241,7 @@ describe Pry::CommandSet do
@set.command('foo', 'bar') {}
@set.desc 'foo', 'baz'
@set.commands['foo'].description.should == 'baz'
@set['foo'].description.should == 'baz'
end
it 'should get the descriptions of commands' do
@ -327,12 +327,12 @@ describe Pry::CommandSet do
it 'should provide a :listing for a command that defaults to its name' do
@set.command 'foo', "" do;end
@set.commands['foo'].options[:listing].should == 'foo'
@set['foo'].options[:listing].should == 'foo'
end
it 'should provide a :listing for a command that differs from its name' do
@set.command 'foo', "", :listing => 'bar' do;end
@set.commands['foo'].options[:listing].should == 'bar'
@set['foo'].options[:listing].should == 'bar'
end
it "should provide a 'help' command" do
@ -377,9 +377,9 @@ describe Pry::CommandSet do
listing = "bing"
@set.command('foo') { }
@set.rename_command('bar', 'foo', :description => desc, :listing => listing, :keep_retval => true)
@set.commands['bar'].description.should == desc
@set.commands['bar'].options[:listing].should == listing
@set.commands['bar'].options[:keep_retval].should == true
@set['bar'].description.should == desc
@set['bar'].options[:listing].should == listing
@set['bar'].options[:keep_retval].should == true
end
end