spec/prawn/svg/elements/gradient_spec.rb in prawn-svg-0.29.1 vs spec/prawn/svg/elements/gradient_spec.rb in prawn-svg-0.30.0
- old
+ new
@@ -27,11 +27,12 @@
it "returns correct gradient arguments for an element" do
arguments = element.gradient_arguments(double(bounding_box: [100, 100, 200, 0]))
expect(arguments).to eq(
from: [100.0, 100.0],
to: [120.0, 0.0],
- stops: [[0, "ff0000"], [0.25, "ff0000"], [0.5, "ffffff"], [0.75, "0000ff"], [1, "0000ff"]]
+ stops: [[0, "ff0000"], [0.25, "ff0000"], [0.5, "ffffff"], [0.75, "0000ff"], [1, "0000ff"]],
+ apply_transformations: true,
)
end
it "returns nil if the element doesn't have a bounding box" do
arguments = element.gradient_arguments(double(bounding_box: nil))
@@ -52,10 +53,33 @@
it "returns correct gradient arguments for an element" do
arguments = element.gradient_arguments(double)
expect(arguments).to eq(
from: [100.0, 100.0],
to: [200.0, 0.0],
- stops: [[0, "ff0000"], [1, "0000ff"]]
+ stops: [[0, "ff0000"], [1, "0000ff"]],
+ apply_transformations: true,
+ )
+ end
+ end
+
+ context "when gradientTransform is specified" do
+ let(:svg) do
+ <<-SVG
+ <linearGradient id="flag" gradientTransform="translateX(10) scale(2)" x1="0" y1="0" x2="10" y2="10">
+ <stop offset="0" stop-color="red"/>
+ <stop offset="1" stop-color="blue"/>
+ </linearGradient>
+ SVG
+ end
+
+ it "passes in the transform via the apply_transformations option" do
+ arguments = element.gradient_arguments(double(bounding_box: [0, 0, 10, 10]))
+
+ expect(arguments).to eq(
+ from: [0, 0],
+ to: [10, 10],
+ stops: [[0, "ff0000"], [1, "0000ff"]],
+ apply_transformations: [2, 0, 0, 2, 10, 0],
)
end
end
end