Sha256: e2b785295aa2be04f22e8f2ae58c6f691d817f2bfde9807d524d728cc26ba89d

Contents?: true

Size: 728 Bytes

Versions: 2

Compression:

Stored size: 728 Bytes

Contents

require 'spec_helper'

describe Grid do
  context "when given width and height" do
    let(:width)  { 10 }
    let(:height) { 10 }
    subject { Grid.new([width,height]) }
    it 'should reflect given width and height' do 
      expect(subject.width).to eql(width)
      expect(subject.height).to eql(height)
    end
  end

  describe ".elements" do 
    subject { Grid.new([2,2]) }

    it 'should iterate over the grid' do
      expect(subject.to_a).to eql([[0, 0], [0, 1], [1, 0], [1, 1]])
    end
  end

  describe "#first" do
    subject { Grid.new([1,1]) }
    its(:first) { should eql([0,0]) }
  end

  describe "#sample" do
    subject { Grid.new([2,2]) }
    its(:sample) { should be_an Array } # eql([1,1])}
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
straightedge-0.1.2 spec/straightedge/figures/grid_spec.rb
straightedge-0.1.1 spec/straightedge/figures/grid_spec.rb