mirror of
https://github.com/awesome-print/awesome_print
synced 2023-03-27 23:22:34 -04:00
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.
This commit is contained in:
parent
f67bb17e11
commit
4249b7acff
1 changed files with 44 additions and 0 deletions
|
@ -77,6 +77,50 @@ EOS
|
||||||
attr_reader :abra = 1,
|
attr_reader :abra = 1,
|
||||||
attr_writer :ca = 2
|
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
|
||||||
|
#<Hello:0x01234567
|
||||||
|
\e[0;36m@dabra\e[0m\e[0;37m = \e[0m\e[1;34m3\e[0m,
|
||||||
|
\e[1;36mattr_reader\e[0m \e[0;35m:abra\e[0m\e[0;37m = \e[0m\e[1;34m1\e[0m,
|
||||||
|
\e[1;36mattr_writer\e[0m \e[0;35m:ca\e[0m\e[0;37m = \e[0m\e[1;34m2\e[0m
|
||||||
|
>
|
||||||
|
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
|
||||||
|
#<Hello:0x01234567 @dabra = 3, attr_reader :abra = 1, attr_writer :ca = 2>
|
||||||
EOS
|
EOS
|
||||||
expect(out.gsub(/0x([a-f\d]+)/, "0x01234567")).to eq(str)
|
expect(out.gsub(/0x([a-f\d]+)/, "0x01234567")).to eq(str)
|
||||||
expect(hello.ai(:plain => true, :raw => false)).to eq(hello.inspect)
|
expect(hello.ai(:plain => true, :raw => false)).to eq(hello.inspect)
|
||||||
|
|
Loading…
Reference in a new issue