Sha256: ccad09f97cc5a3cc61fe0a541002ac2fa6ad8fff593fcc0d07aaafd8a9460fe5

Contents?: true

Size: 1.9 KB

Versions: 92

Compression:

Stored size: 1.9 KB

Contents

require 'helper'

describe "Pry::Commands" do
  describe "help" do
    it 'should display help for a specific command' do
      str_output = StringIO.new
      redirect_pry_io(InputTester.new("help ls", "exit-all"), str_output) do
        pry
      end
      str_output.string.each_line.count.should == 1
      str_output.string.should =~ /ls --help/
    end

    it 'should display help for a regex command with a "listing"' do
      set = Pry::CommandSet.new do
        command /bar(.*)/, "Test listing", :listing => "foo" do
        end
      end

      str_output = StringIO.new
      redirect_pry_io(InputTester.new("help foo"), str_output) do
        Pry.new(:commands => set).rep
      end
      str_output.string.each_line.count.should == 1
      str_output.string.should =~ /Test listing/
    end

    it 'should display help for a command with a spaces in its name' do
      set = Pry::CommandSet.new do
        command "command with spaces", "description of a command with spaces" do
        end
      end

      str_output = StringIO.new
      redirect_pry_io(InputTester.new("help \"command with spaces\""), str_output) do
        Pry.new(:commands => set).rep
      end
      str_output.string.each_line.count.should == 1
      str_output.string.should =~ /description of a command with spaces/
    end

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

      str_output = StringIO.new
      redirect_pry_io(InputTester.new("help"), str_output) do
        Pry.new(:commands => set).rep
      end
      str_output.string.should =~ /Test listing/
      str_output.string.should =~ /description for b/
      str_output.string.should =~ /No description/
    end
  end
end

Version data entries

92 entries across 92 versions & 1 rubygems

Version Path
pry-0.9.8pre2 test/test_default_commands.rb
pry-0.9.8pre2-i386-mswin32 test/test_default_commands.rb
pry-0.9.8pre2-i386-mingw32 test/test_default_commands.rb
pry-0.9.8pre2-java test/test_default_commands.rb
pry-0.9.8.0pre1-i386-mswin32 test/test_default_commands.rb
pry-0.9.8.0pre1-i386-mingw32 test/test_default_commands.rb
pry-0.9.7.4 test/test_default_commands.rb
pry-0.9.7.4-i386-mswin32 test/test_default_commands.rb
pry-0.9.7.4-i386-mingw32 test/test_default_commands.rb
pry-0.9.7.4-java test/test_default_commands.rb
pry-0.9.7.3 test/test_default_commands.rb
pry-0.9.7.3-i386-mswin32 test/test_default_commands.rb
pry-0.9.7.3-i386-mingw32 test/test_default_commands.rb
pry-0.9.7.3-java test/test_default_commands.rb
pry-0.9.7.2 test/test_default_commands.rb
pry-0.9.7.2-i386-mswin32 test/test_default_commands.rb
pry-0.9.7.2-i386-mingw32 test/test_default_commands.rb
pry-0.9.7.2-java test/test_default_commands.rb
pry-0.9.7.1 test/test_default_commands.rb
pry-0.9.7.1-i386-mswin32 test/test_default_commands.rb