Sha256: 7ef2c99c3ef62ad9328f0d52b461fd9e77bd2396172da0e59f6ad51ef1aa343e

Contents?: true

Size: 1.48 KB

Versions: 1

Compression:

Stored size: 1.48 KB

Contents

require 'spec_helper'

describe "DotGrid::Pattern::DotDash" do
  describe "#draw" do
    let(:pdf) { double('pdf').as_null_object }
    let(:params) { { pdf: pdf, bounds: double('bounds', { upper_left: [0, 0], height: 20.mm, width: 10.mm } ), spacing: 5 } }
    let(:subject) { DotGrid::Pattern::DotDash.new(params) }

    before do
      allow(pdf).to receive(:bounding_box).and_yield
    end

    it "sets the fill color" do
      expect(pdf).to receive(:fill_color)
      subject.draw
    end

    it "sets the line width" do
      expect(pdf).to receive(:line_width)
      subject.draw
    end

    it "sets the stroke color" do
      expect(pdf).to receive(:stroke_color)
      subject.draw
    end

    it "calls fill circle the correct number of times" do
      allow(subject).to receive(:rows).and_return(2)
      allow(subject).to receive(:columns).and_return(3)
      expect(pdf).to receive(:fill_circle).exactly(3*4).times
      subject.draw
    end

    it "calls horizontal line the correct number of times" do
      allow(subject).to receive(:rows).and_return(2)
      allow(subject).to receive(:columns).and_return(3)
      expect(pdf).to receive(:stroke_horizontal_line).exactly(3*4).times
      subject.draw
    end

    it "calls vertical line the correct number of times" do
      allow(subject).to receive(:rows).and_return(2)
      allow(subject).to receive(:columns).and_return(3)
      expect(pdf).to receive(:stroke_vertical_line).exactly(3*4).times
      subject.draw
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dot_grid-0.0.12 spec/lib/dot_grid/pattern/dot_dash_spec.rb