Commit 37fa83f
Changed files (1)
spec
spec/node_spec.rb
@@ -3,6 +3,10 @@ describe Scale::Node do
include Scale::Node
attribute :x, Integer
attribute :y, Integer
+
+ def xml_tag
+ :fake
+ end
end
subject { FakeNode.new }
@@ -20,4 +24,23 @@ describe Scale::Node do
expect(subject).to include(child)
end
end
+
+ describe "#to_xml" do
+ it 'generates the full xml tree' do
+ grandchild = Scale::Rectangle.new(width: "100%", height: "100%", fill: "blue")
+ child = Scale::Rectangle.new(width: "100%", height: "100%", fill: "red")
+ child.add(grandchild)
+ subject.add(child)
+
+ expected = <<-XML
+<?xml version="1.0"?>
+<fake>
+ <rect width="100%" height="100%" fill="red">
+ <rect width="100%" height="100%" fill="blue"/>
+ </rect>
+</fake>
+ XML
+ expect(subject.to_xml).to eql(expected)
+ end
+ end
end