2011-09-21 10:15:53 -04:00
|
|
|
require 'helper'
|
2011-08-23 03:54:58 -04:00
|
|
|
|
|
|
|
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" }
|
|
|
|
|
2011-09-14 18:48:20 -04:00
|
|
|
mock_pry("1").should =~ /\(pry\) output error: #<RuntimeError: catch-22>/
|
2011-08-23 03:54:58 -04:00
|
|
|
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
|
|
|
|
|
2011-09-14 18:48:20 -04:00
|
|
|
mock_pry("1").should =~ /\(pry\) output error: failed to show result/
|
2011-08-23 03:54:58 -04:00
|
|
|
end
|
|
|
|
end
|
2011-08-24 04:07:52 -04:00
|
|
|
|
|
|
|
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
|
2011-09-21 10:51:14 -04:00
|
|
|
mock_pry("class NastyClass; undef pretty_inspect; end", "NastyClass.new").should =~ /#<NastyClass:0x.*?>/
|
2011-08-24 04:07:52 -04:00
|
|
|
end
|
|
|
|
end
|
2011-08-23 03:54:58 -04:00
|
|
|
end
|