Sha256: 0a6ccd39e65794708feb6db7c1229da839574510c4bf4736550ee707749e3dbf

Contents?: true

Size: 1.44 KB

Versions: 5

Compression:

Stored size: 1.44 KB

Contents

require 'spec_helper'

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

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

  context "with attributes specified" do
    let(:svg) { '<line x1="5" y1="10" x2="15" y2="20" stroke="black" />' }

    it "renders the line" do
      subject.process
      expect(subject.base_calls).to eq [
        ["stroke_color", ["000000"], {}, []],
        ["stroke", [], {}, [
          ["move_to", [[5.0, 590.0]], {}, []],
          ["line_to", [[15.0, 580.0]], {}, []]]
        ]
      ]
    end
  end

  context "with no attributes nor stroke specified" do
    let(:svg) { '<line />' }

    it "outlines a path from 0,0 to 0,0" do
      subject.process
      expect(subject.base_calls).to eq [
        ["end_path", [], {}, [
          ["move_to", [[0, 600]], {}, []],
          ["line_to", [[0, 600]], {}, []]]
        ]
      ]
    end
  end

  context "with a fill specified" do
    let(:svg) { '<line x1="0" y1="0" x2="15" y2="20" style="stroke: red; fill: blue;" />' }

    it "ignores the fill" do
      subject.process

      expect(subject.base_calls).to eq [
        ["fill_color", ["0000ff"], {}, []],
        ["stroke_color", ["ff0000"], {}, []],
        ["stroke", [], {}, [
          ["move_to", [[0, 600]], {}, []],
          ["line_to", [[15.0, 580.0]], {}, []]]
        ]
      ]
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
prawn-svg-0.34.2 spec/prawn/svg/elements/line_spec.rb
prawn-svg-0.34.1 spec/prawn/svg/elements/line_spec.rb
prawn-svg-0.34.0 spec/prawn/svg/elements/line_spec.rb
prawn-svg-0.33.0 spec/prawn/svg/elements/line_spec.rb
prawn-svg-0.32.0 spec/prawn/svg/elements/line_spec.rb