diff options
Diffstat (limited to 'spec/mspec/lib/mspec/utils/format.rb')
-rw-r--r-- | spec/mspec/lib/mspec/utils/format.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/spec/mspec/lib/mspec/utils/format.rb b/spec/mspec/lib/mspec/utils/format.rb new file mode 100644 index 0000000000..bb75e131de --- /dev/null +++ b/spec/mspec/lib/mspec/utils/format.rb @@ -0,0 +1,20 @@ +# If the implementation on which the specs are run cannot +# load pp from the standard library, add a pp.rb file that +# defines the #pretty_inspect method on Object or Kernel. +begin + require 'pp' +rescue LoadError + module Kernel + def pretty_inspect + inspect + end + end +end + +module MSpec + def self.format(obj) + obj.pretty_inspect.chomp + rescue => e + "#<#{obj.class}>(#pretty_inspect raised #{e.inspect})" + end +end |