Sha256: ed4f7f8a08d24ad1a103150bfcf896b55366a69099ea49359a3fa218b9878546

Contents?: true

Size: 1.24 KB

Versions: 3

Compression:

Stored size: 1.24 KB

Contents

require 'spec_helper'

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

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

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

    it 'renders the polyline' 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]], {}, []]
        ]]
      ]
    end
  end

  context 'with a polyline that has an odd number of arguments' do
    let(:svg) { '<polyline 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]], {}, []]
        ]]
      ]
    end
  end

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

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
prawn-svg-0.36.0 spec/prawn/svg/elements/polyline_spec.rb
prawn-svg-0.35.1 spec/prawn/svg/elements/polyline_spec.rb
prawn-svg-0.35.0 spec/prawn/svg/elements/polyline_spec.rb