Sha256: 4fd5639f14096949655a0817855e8d66c309bcc5abb4b1c15f04688f9fa08d9f

Contents?: true

Size: 1.57 KB

Versions: 79

Compression:

Stored size: 1.57 KB

Contents

require 'helper'

describe "help" do
  before do
    @oldset = Pry.config.commands
    @set = Pry.config.commands = Pry::CommandSet.new do
      import Pry::Commands
    end
  end

  after do
    Pry.config.commands = @oldset
  end

  it 'should display help for a specific command' do
    pry_eval('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
    pry_eval('help foo').should =~ /Test listing/
  end

  it 'should display help for a command with a spaces in its name' do
    @set.command "cmd with spaces", "desc of a cmd with spaces" do; end
    pry_eval('help "cmd with spaces"').should =~ /desc of a cmd 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 = pry_eval('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 = pry_eval('help')

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

    order.should == order.sort
  end
end

Version data entries

79 entries across 79 versions & 5 rubygems

Version Path
pry-0.9.12.2 spec/commands/help_spec.rb
pry-0.9.12.2-i386-mswin32 spec/commands/help_spec.rb
pry-0.9.12.2-i386-mingw32 spec/commands/help_spec.rb
pry-0.9.12.2-java spec/commands/help_spec.rb
pry-0.9.12.2pre1 spec/commands/help_spec.rb
pry-0.9.12.2pre1-i386-mswin32 spec/commands/help_spec.rb
pry-0.9.12.2pre1-i386-mingw32 spec/commands/help_spec.rb
pry-0.9.12.2pre1-java spec/commands/help_spec.rb
sidekiq-statsd-0.1.1 vendor/ruby/1.9.1/gems/pry-0.9.12.1/spec/commands/help_spec.rb
sidekiq-statsd-0.1.0 vendor/ruby/1.9.1/gems/pry-0.9.12.1/spec/commands/help_spec.rb
pry-0.9.12.1 spec/commands/help_spec.rb
pry-0.9.12.1-i386-mswin32 spec/commands/help_spec.rb
pry-0.9.12.1-i386-mingw32 spec/commands/help_spec.rb
pry-0.9.12.1-java spec/commands/help_spec.rb
pry-0.9.12.1pre1 spec/commands/help_spec.rb
pry-0.9.12.1pre1-i386-mswin32 spec/commands/help_spec.rb
pry-0.9.12.1pre1-i386-mingw32 spec/commands/help_spec.rb
pry-0.9.12.1pre1-java spec/commands/help_spec.rb
torquebox-console-0.2.5 vendor/bundle/jruby/1.9/gems/pry-0.9.12-java/spec/commands/help_spec.rb
pry-1.0.0.pre1-i386-mswin32 spec/commands/help_spec.rb