Sha256: 6b5af6385ce177f29d109a06a6daaca812c943d16a9471f8006263f4db2cf157

Contents?: true

Size: 1.91 KB

Versions: 24

Compression:

Stored size: 1.91 KB

Contents

require 'helper'

describe "Pry::DefaultCommands::Documentation" do
  describe "show-doc" do
    it 'should output a method\'s documentation' do
      redirect_pry_io(InputTester.new("show-doc sample_method", "exit-all"), str_output=StringIO.new) do
        pry
      end

      str_output.string.should =~ /sample doc/
    end

    it 'should output a method\'s documentation with line numbers' do
      redirect_pry_io(InputTester.new("show-doc sample_method -l", "exit-all"), str_output=StringIO.new) do
        pry
      end

      str_output.string.should =~ /\d: sample doc/
    end

    it 'should output a method\'s documentation with line numbers (base one)' do
      redirect_pry_io(InputTester.new("show-doc sample_method -b", "exit-all"), str_output=StringIO.new) do
        pry
      end

      str_output.string.should =~ /1: sample doc/
    end

    it 'should output a method\'s documentation if inside method without needing to use method name' do
      o = Object.new

      # sample comment
      def o.sample
        redirect_pry_io(InputTester.new("show-doc", "exit-all"), $out=StringIO.new) do
          binding.pry
       end
      end
      o.sample
      $out.string.should =~ /sample comment/
      $out = nil
    end

    it "should be able to find super methods" do

      c = Class.new{
        # classy initialize!
        def initialize(*args); end
      }

      d = Class.new(c){
        # grungy initialize??
        def initialize(*args, &block); end
      }

      o = d.new

      # instancey initialize!
      def o.initialize; end

      mock_pry(binding, "show-doc o.initialize").should =~ /instancey initialize/
      mock_pry(binding, "show-doc --super o.initialize").should =~ /grungy initialize/
      mock_pry(binding, "show-doc o.initialize -ss").should =~ /classy initialize/
      mock_pry(binding, "show-doc --super o.initialize -ss").should == mock_pry("show-doc Object#initialize")
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
pry-0.9.8.4 test/test_default_commands/test_documentation.rb
pry-0.9.8.4-i386-mswin32 test/test_default_commands/test_documentation.rb
pry-0.9.8.4-i386-mingw32 test/test_default_commands/test_documentation.rb
pry-0.9.8.4-java test/test_default_commands/test_documentation.rb
pry-0.9.8.3 test/test_default_commands/test_documentation.rb
pry-0.9.8.3-i386-mswin32 test/test_default_commands/test_documentation.rb
pry-0.9.8.3-i386-mingw32 test/test_default_commands/test_documentation.rb
pry-0.9.8.3-java test/test_default_commands/test_documentation.rb
pry-0.9.8.2 test/test_default_commands/test_documentation.rb
pry-0.9.8.2-i386-mswin32 test/test_default_commands/test_documentation.rb
pry-0.9.8.2-i386-mingw32 test/test_default_commands/test_documentation.rb
pry-0.9.8.2-java test/test_default_commands/test_documentation.rb
pry-0.9.8.1 test/test_default_commands/test_documentation.rb
pry-0.9.8.1-i386-mswin32 test/test_default_commands/test_documentation.rb
pry-0.9.8.1-i386-mingw32 test/test_default_commands/test_documentation.rb
pry-0.9.8.1-java test/test_default_commands/test_documentation.rb
pry-0.9.8 test/test_default_commands/test_documentation.rb
pry-0.9.8-i386-mswin32 test/test_default_commands/test_documentation.rb
pry-0.9.8-i386-mingw32 test/test_default_commands/test_documentation.rb
pry-0.9.8-java test/test_default_commands/test_documentation.rb