Sha256: b70b73a39f4505530d93907127452b94ad8a7c655fc98035c2400a02785d1f25

Contents?: true

Size: 1.84 KB

Versions: 35

Compression:

Stored size: 1.84 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.should =~ /Usage: ls/
    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

35 entries across 35 versions & 1 rubygems

Version Path
pry-0.9.8.2 test/test_default_commands.rb
pry-0.9.8.2-i386-mswin32 test/test_default_commands.rb
pry-0.9.8.2-i386-mingw32 test/test_default_commands.rb
pry-0.9.8.2-java test/test_default_commands.rb
pry-0.9.8.1 test/test_default_commands.rb
pry-0.9.8.1-i386-mswin32 test/test_default_commands.rb
pry-0.9.8.1-i386-mingw32 test/test_default_commands.rb
pry-0.9.8.1-java test/test_default_commands.rb
pry-0.9.8 test/test_default_commands.rb
pry-0.9.8-i386-mswin32 test/test_default_commands.rb
pry-0.9.8-i386-mingw32 test/test_default_commands.rb
pry-0.9.8-java test/test_default_commands.rb
pry-0.9.8pre8 test/test_default_commands.rb
pry-0.9.8pre8-i386-mswin32 test/test_default_commands.rb
pry-0.9.8pre8-i386-mingw32 test/test_default_commands.rb
pry-0.9.8pre8-java test/test_default_commands.rb
pry-0.9.8pre7 test/test_default_commands.rb
pry-0.9.8pre7-i386-mswin32 test/test_default_commands.rb
pry-0.9.8pre7-i386-mingw32 test/test_default_commands.rb
pry-0.9.8pre7-java test/test_default_commands.rb