Commit af841c9
Changed files (2)
lib
scale
spec
lib/scale/rectangle.rb
@@ -1,6 +1,7 @@
module Scale
class Rectangle
include Node
+ attr_accessor :height, :width, :fill, :x, :y, :rx, :ry
def initialize(width: nil, height: nil, fill: nil)
@width = width
@@ -13,7 +14,7 @@ module Scale
end
def attributes
- { width: @width, height: @height, fill: @fill }
+ { width: width, height: height, fill: fill, x: x, y: y, rx: rx, ry: ry }
end
end
end
spec/rectangle_spec.rb
@@ -0,0 +1,35 @@
+describe Scale::Rectangle do
+ it { expect(subject.xml_tag).to eql(:rect) }
+
+ describe "#attributes" do
+ it 'includes the x position of the top left corner' do
+ subject.x = 10
+ expect(subject.attributes).to include(x: 10)
+ end
+
+ it 'includes the y position of the top left corner' do
+ subject.y = 10
+ expect(subject.attributes).to include(y: 10)
+ end
+
+ it 'includes the width' do
+ subject.width = "100%"
+ expect(subject.attributes).to include(width: "100%")
+ end
+
+ it 'includes the height' do
+ subject.height = "100%"
+ expect(subject.attributes).to include(height: "100%")
+ end
+
+ it 'includes the x radius of the corners' do
+ subject.rx = 10
+ expect(subject.attributes).to include(rx: 10)
+ end
+
+ it 'includes the y radius of the corners' do
+ subject.ry = 10
+ expect(subject.attributes).to include(ry: 10)
+ end
+ end
+end