Sha256: 965c398314f579b65a2b571193107324adb242beed96ad57adeab72a52f6fce4

Contents?: true

Size: 852 Bytes

Versions: 1

Compression:

Stored size: 852 Bytes

Contents

require 'spec_helper'
require 'pry'

describe Array do
  describe ".to_point" do
    subject do 
      [1,2]
    end

    context 'should decode straightforwardly as a geometric coordinate' do
      it 'should have an x-coordinate' do
	expect(subject.x).to eql(1)
      end

      it 'should have a y-coordinate' do
	expect(subject.y).to eql(2)
      end
    end
  end

  describe ".to_points" do
    subject do
      [[1,2],[3,2]]
    end

    context 'should decode as a set of points' do
      it 'should have a center' do
	expect(subject.center).to eql([2,2])
      end

      let(:expected_adjacent) do
	[[2, 2], [2, 3], [2, 1], [1, 1], [3, 1], [1, 3], [3, 3], [4, 2], [0, 2], [0, 1], [0, 3], [4, 1], [4, 3]]
      end
      it 'should have adjacent coordinates' do
	expect(subject.adjacent).to eql(expected_adjacent)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
straightedge-0.1.1 spec/straightedge/extend/array_spec.rb