diff --git a/lib/fluent/config/section.rb b/lib/fluent/config/section.rb index cb6603d891..ccbde51f2d 100644 --- a/lib/fluent/config/section.rb +++ b/lib/fluent/config/section.rb @@ -50,6 +50,11 @@ def inspect "" end + # Used by PP and Pry + def pretty_print(q) + q.text(inspect) + end + def nil? false end diff --git a/test/config/test_section.rb b/test/config/test_section.rb index 8d2d0f366d..e303aa1e98 100644 --- a/test/config/test_section.rb +++ b/test/config/test_section.rb @@ -1,5 +1,6 @@ require_relative '../helper' require 'fluent/config/section' +require 'pp' module Fluent::Config class TestSection < ::Test::Unit::TestCase @@ -176,6 +177,14 @@ class TestSection < ::Test::Unit::TestCase s1 = Fluent::Config::Section.new(h1) assert_equal(expected, s1.respond_to?(method)) end + + test '#pretty_print' do + q = PP.new + h1 = {name: "s1", klass: "A"} + s1 = Fluent::Config::Section.new(h1) + s1.pretty_print(q) + assert_equal s1.inspect, q.output + end end end end