Sha256: a704795a9163082f23f30e5ed98a96645e6cbda8b067d882170e092dc971b4a9

Contents?: true

Size: 1.27 KB

Versions: 12

Compression:

Stored size: 1.27 KB

Contents

require 'spec_helper'

RSpec.describe Prawn::SVG::Elements::Polygon do
  let(:document) { Prawn::SVG::Document.new(svg, [800, 600], {width: 800, height: 600}) }

  subject do
    Prawn::SVG::Elements::Polygon.new(document, document.root, [], Prawn::SVG::State.new)
  end

  context "with a valid points attribute" do
    let(:svg) { '<polygon points="10 10 20,20 30,30" />' }

    it "renders the polygon" do
      subject.process
      expect(subject.base_calls).to eq [
        ["fill", [], [
          ["move_to", [[10.0, 590.0]], []],
          ["line_to", [[20.0, 580.0]], []],
          ["line_to", [[30.0, 570.0]], []],
          ["close_path", [], []]]
        ]
      ]
    end
  end

  context "with a polygon that has an odd number of arguments" do
    let(:svg) { '<polygon points="10 10 20,20 30" />' }

    it "ignores the last one" do
      subject.process
      expect(subject.base_calls).to eq [
        ["fill", [], [
          ["move_to", [[10.0, 590.0]], []],
          ["line_to", [[20.0, 580.0]], []],
          ["close_path", [], []]]
        ]
      ]
    end
  end

  context "with a polygon that has no arguments" do
    let(:svg) { '<polygon points="" />' }

    it "renders nothing" do
      subject.process
      expect(subject.base_calls).to eq []
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
prawn-svg-0.31.0 spec/prawn/svg/elements/polygon_spec.rb
prawn-svg-0.30.0 spec/prawn/svg/elements/polygon_spec.rb
prawn-svg-0.29.1 spec/prawn/svg/elements/polygon_spec.rb
prawn-svg-0.29.0 spec/prawn/svg/elements/polygon_spec.rb
prawn-svg-0.28.0 spec/prawn/svg/elements/polygon_spec.rb
prawn-svg-0.27.1 spec/prawn/svg/elements/polygon_spec.rb
prawn-svg-0.27.0 spec/prawn/svg/elements/polygon_spec.rb
prawn-svg-0.26.0 spec/prawn/svg/elements/polygon_spec.rb
prawn-svg-0.25.2 spec/prawn/svg/elements/polygon_spec.rb
prawn-svg-0.25.1 spec/prawn/svg/elements/polygon_spec.rb
prawn-svg-0.25.0 spec/prawn/svg/elements/polygon_spec.rb
prawn-svg-0.24.0 spec/prawn/svg/elements/polygon_spec.rb