2014-03-14 05:31:24 +01:00
|
|
|
require_relative '../helper'
|
2012-02-22 23:56:25 -08:00
|
|
|
|
2012-09-15 14:50:15 -07:00
|
|
|
describe "help" do
|
2012-02-22 23:56:25 -08:00
|
|
|
before do
|
|
|
|
@oldset = Pry.config.commands
|
|
|
|
@set = Pry.config.commands = Pry::CommandSet.new do
|
2012-08-11 17:22:29 -07:00
|
|
|
import Pry::Commands
|
2012-02-22 23:56:25 -08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
after do
|
|
|
|
Pry.config.commands = @oldset
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should display help for a specific command' do
|
2015-03-10 22:49:29 +02:00
|
|
|
expect(pry_eval('help ls')).to match(/Usage: ls/)
|
2012-02-22 23:56:25 -08:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'should display help for a regex command with a "listing"' do
|
2015-01-23 10:30:41 +01:00
|
|
|
@set.command(/bar(.*)/, "Test listing", :listing => "foo") do; end
|
2015-03-10 22:49:29 +02:00
|
|
|
expect(pry_eval('help foo')).to match(/Test listing/)
|
2012-02-22 23:56:25 -08:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'should display help for a command with a spaces in its name' do
|
2012-08-05 02:47:16 +00:00
|
|
|
@set.command "cmd with spaces", "desc of a cmd with spaces" do; end
|
2015-03-10 22:49:29 +02:00
|
|
|
expect(pry_eval('help "cmd with spaces"')).to match(/desc of a cmd with spaces/)
|
2012-02-22 23:56:25 -08:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'should display help for all commands with a description' do
|
2015-01-23 10:30:41 +01:00
|
|
|
@set.command(/bar(.*)/, "Test listing", :listing => "foo") do; end
|
2012-02-22 23:56:25 -08:00
|
|
|
@set.command "b", "description for b", :listing => "foo" do; end
|
|
|
|
@set.command "c" do;end
|
|
|
|
@set.command "d", "" do;end
|
|
|
|
|
2012-08-05 02:47:16 +00:00
|
|
|
output = pry_eval('help')
|
2015-03-10 22:49:29 +02:00
|
|
|
expect(output).to match(/Test listing/)
|
|
|
|
expect(output).to match(/Description for b/)
|
|
|
|
expect(output).to match(/No description/)
|
2012-02-22 23:56:25 -08:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should sort the output of the 'help' command" do
|
2012-03-01 17:09:07 -08:00
|
|
|
@set.command 'faa', "Fooerizes" do; end
|
|
|
|
@set.command 'gaa', "Gooerizes" do; end
|
|
|
|
@set.command 'maa', "Mooerizes" do; end
|
|
|
|
@set.command 'baa', "Booerizes" do; end
|
2012-02-22 23:56:25 -08:00
|
|
|
|
2012-08-05 02:47:16 +00:00
|
|
|
doc = pry_eval('help')
|
2012-02-22 23:56:25 -08:00
|
|
|
|
2012-03-01 17:09:07 -08:00
|
|
|
order = [doc.index("baa"),
|
|
|
|
doc.index("faa"),
|
|
|
|
doc.index("gaa"),
|
|
|
|
doc.index("maa")]
|
2012-02-22 23:56:25 -08:00
|
|
|
|
2015-03-10 22:49:29 +02:00
|
|
|
expect(order).to eq(order.sort)
|
2012-02-22 23:56:25 -08:00
|
|
|
end
|
|
|
|
end
|