From 4249b7acffc045839f376af7e3b178c2850ebbfd Mon Sep 17 00:00:00 2001 From: Mauro George Date: Thu, 12 Feb 2015 18:52:23 -0200 Subject: [PATCH] Improve coverage of Formatter#awesome_object Cover the case when the option plain is false, this way show the colorized object. Cover the multiline option as false, this way show the content in a single line. --- spec/objects_spec.rb | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/spec/objects_spec.rb b/spec/objects_spec.rb index ee7d241..cdbfa40 100644 --- a/spec/objects_spec.rb +++ b/spec/objects_spec.rb @@ -77,6 +77,50 @@ EOS attr_reader :abra = 1, attr_writer :ca = 2 > +EOS + expect(out.gsub(/0x([a-f\d]+)/, "0x01234567")).to eq(str) + expect(hello.ai(:plain => true, :raw => false)).to eq(hello.inspect) + end + + it "without the plain options print the colorized values" do + class Hello + attr_reader :abra + attr_writer :ca + + def initialize + @abra, @ca = 1, 2 + @dabra = 3 + end + end + + hello = Hello.new + out = hello.ai(:raw => true) + str = <<-EOS.strip +# +EOS + expect(out.gsub(/0x([a-f\d]+)/, "0x01234567")).to eq(str) + expect(hello.ai(:plain => true, :raw => false)).to eq(hello.inspect) + end + + it "with multine as false show inline values" do + class Hello + attr_reader :abra + attr_writer :ca + + def initialize + @abra, @ca = 1, 2 + @dabra = 3 + end + end + + hello = Hello.new + out = hello.ai(:multiline => false, :plain => true, :raw => true) + str = <<-EOS.strip +# EOS expect(out.gsub(/0x([a-f\d]+)/, "0x01234567")).to eq(str) expect(hello.ai(:plain => true, :raw => false)).to eq(hello.inspect)