Sha256: 1f1cb4ccffb2ffb6bb5e91ef11e798fbabf577619b97121906d13f389bbddf3c

Contents?: true

Size: 1.65 KB

Versions: 59

Compression:

Stored size: 1.65 KB

Contents

require 'helper'

describe "'help' command" do
  before do
    @oldset = Pry.config.commands
    @set = Pry.config.commands = Pry::CommandSet.new do
      import Pry::DefaultCommands::Help
      import Pry::DefaultCommands::Ls
    end
  end

  after do
    Pry.config.commands = @oldset
  end

  it 'should display help for a specific command' do
    mock_pry('help ls').should =~ /Usage: ls/
  end

  it 'should display help for a regex command with a "listing"' do
    @set.command /bar(.*)/, "Test listing", :listing => "foo" do; end
    mock_pry('help foo').should =~ /Test listing/
  end

  it 'should display help for a command with a spaces in its name' do
    @set.command "command with spaces", "description of a command with spaces" do; end
    mock_pry('help "command with spaces"').should =~ /description of a command with spaces/
  end

  it 'should display help for all commands with a description' do
    @set.command /bar(.*)/, "Test listing", :listing => "foo" do; end
    @set.command "b", "description for b", :listing => "foo" do; end
    @set.command "c" do;end
    @set.command "d", "" do;end

    output = mock_pry('help')
    output.should =~ /Test listing/
    output.should =~ /description for b/
    output.should =~ /No description/
  end

  it "should sort the output of the 'help' command" do
    @set.command 'faa', "Fooerizes" do; end
    @set.command 'gaa', "Gooerizes" do; end
    @set.command 'maa', "Mooerizes" do; end
    @set.command 'baa', "Booerizes" do; end

    doc = mock_pry('help')

    order = [doc.index("baa"),
             doc.index("faa"),
             doc.index("gaa"),
             doc.index("maa")]

    order.should == order.sort
  end
end

Version data entries

59 entries across 59 versions & 1 rubygems

Version Path
pry-0.9.10 test/test_default_commands/test_help.rb
pry-0.9.10-i386-mswin32 test/test_default_commands/test_help.rb
pry-0.9.10-i386-mingw32 test/test_default_commands/test_help.rb
pry-0.9.10-java test/test_default_commands/test_help.rb
pry-0.9.10pre1 test/test_default_commands/test_help.rb
pry-0.9.10pre1-i386-mswin32 test/test_default_commands/test_help.rb
pry-0.9.10pre1-i386-mingw32 test/test_default_commands/test_help.rb
pry-0.9.10pre1-java test/test_default_commands/test_help.rb
pry-0.10.pre.1-i386-mingw32 test/test_default_commands/test_help.rb
pry-0.10.pre.1-java test/test_default_commands/test_help.rb
pry-0.10.pre.1-i386-mswin32 test/test_default_commands/test_help.rb
pry-0.9.9.6 test/test_default_commands/test_help.rb
pry-0.9.9.6-i386-mswin32 test/test_default_commands/test_help.rb
pry-0.9.9.6-i386-mingw32 test/test_default_commands/test_help.rb
pry-0.9.9.6-java test/test_default_commands/test_help.rb
pry-0.9.9.6pre2 test/test_default_commands/test_help.rb
pry-0.9.9.6pre2-i386-mswin32 test/test_default_commands/test_help.rb
pry-0.9.9.6pre2-i386-mingw32 test/test_default_commands/test_help.rb
pry-0.9.9.6pre2-java test/test_default_commands/test_help.rb
pry-0.9.9.6pre1 test/test_default_commands/test_help.rb