diff --git a/spec/ext/active_record_spec.rb b/spec/ext/active_record_spec.rb index 5b4a6ec..6b67ac3 100644 --- a/spec/ext/active_record_spec.rb +++ b/spec/ext/active_record_spec.rb @@ -53,6 +53,38 @@ RSpec.describe "AwesomePrint/ActiveRecord", skip: ->{ !ExtVerifier.has_rails? }. :name => "Laura", :rank => 2 } +] + EOS + if RUBY_VERSION < '1.9' + str.sub!('??', 'Sat Oct 10 12:30:00 UTC 1992') + str.sub!('?!', 'Mon May 26 14:15:00 UTC 2003') + else + str.sub!('??', '1992-10-10 12:30:00 UTC') + str.sub!('?!', '2003-05-26 14:15:00 UTC') + end + expect(out.gsub(/0x([a-f\d]+)/, "0x01234567")).to eq(str) + end + + it "display multiple records on a relation" do + @diana.save + @laura.save + out = @ap.send(:awesome, User.all) + str = <<-EOS.strip +[ + [0] # { + :admin => false, + :created_at => ??, + :id => 1, + :name => "Diana", + :rank => 1 + }, + [1] # { + :admin => true, + :created_at => ?!, + :id => 2, + :name => "Laura", + :rank => 2 + } ] EOS if RUBY_VERSION < '1.9' diff --git a/spec/ext/nokogiri_spec.rb b/spec/ext/nokogiri_spec.rb index 19623e0..466059b 100644 --- a/spec/ext/nokogiri_spec.rb +++ b/spec/ext/nokogiri_spec.rb @@ -42,4 +42,9 @@ RSpec.describe "AwesomePrint/Nokogiri" do \e[0m<\e[1;36m/html\e[0m> EOS end + + it "handle empty NodeSet" do + xml = Nokogiri::XML::NodeSet.new(Nokogiri::XML('')) + expect(xml.ai).to eq('[]') + end end 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)