Sha256: 722cef5b14b71587e44b9b378b2309ef4ac2f0cd39c252628e3b53e373e9729a

Contents?: true

Size: 1.1 KB

Versions: 126

Compression:

Stored size: 1.1 KB

Contents

require 'helper'

describe Pry do
  describe "output failsafe" do
    after do
      Pry.config.print = Pry::DEFAULT_PRINT
    end

    it "should catch serialization exceptions" do
      Pry.config.print = lambda { |*a| raise "catch-22" }

      lambda {
        mock_pry("1")
      }.should.not.raise
    end

    it "should display serialization exceptions" do
      Pry.config.print = lambda { |*a| raise "catch-22" }

      mock_pry("1").should =~ /\(pry\) output error: #<RuntimeError: catch-22>/
    end

    it "should catch errors serializing exceptions" do
      Pry.config.print = lambda do |*a|
        raise Exception.new("catch-22").tap{ |e| class << e; def inspect; raise e; end; end }
      end

      mock_pry("1").should =~ /\(pry\) output error: failed to show result/
    end
  end

  describe "DEFAULT_PRINT" do
    it "should output the right thing" do
      mock_pry("{:a => 1}").should =~ /\{:a=>1\}/
    end

    it "should not be phased by un-inspectable things" do
      mock_pry("class NastyClass; undef pretty_inspect; end", "NastyClass.new").should =~ /#<NastyClass:0x.*?>/
    end
  end
end

Version data entries

126 entries across 126 versions & 1 rubygems

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