Sha256: 4f4752d2f73d75967f357101f0abce07eecebdfd25b2f2bc91fbe511f8fae34f

Contents?: true

Size: 1.08 KB

Versions: 8

Compression:

Stored size: 1.08 KB

Contents

require 'spec_helper'

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

  describe "#rows" do
    it "calculates the rows based on the bounds" do
      expect(subject.rows).to eq(4)
    end
  end

  describe "#columns" do
    it "calculates the rows based on the bounds" do
      expect(subject.columns).to eq(2)
    end
  end

  describe "#draw" do
    before do
      allow(pdf).to receive(:fill_color)
      allow(pdf).to receive(:fill_rectangle)
      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 "calls fill rectangle 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_rectangle).exactly(3*4 / 2).times
      subject.draw
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
dot_grid-0.0.12 spec/lib/dot_grid/pattern/checkerboard_spec.rb
dot_grid-0.0.11 spec/lib/dot_grid/pattern/checkerboard_spec.rb
dot_grid-0.0.10 spec/lib/dot_grid/pattern/checkerboard_spec.rb
dot_grid-0.0.9 spec/lib/dot_grid/pattern/checkerboard_spec.rb
dot_grid-0.0.8 spec/lib/dot_grid/pattern/checkerboard_spec.rb
dot_grid-0.0.7 spec/lib/dot_grid/pattern/checkerboard_spec.rb
dot_grid-0.0.6 spec/lib/dot_grid/pattern/checkerboard_spec.rb
dot_grid-0.0.5 spec/lib/dot_grid/pattern/checkerboard_spec.rb