Sha256: f87eb165dd6707ce16dfc0042950966575db82fd0361c63b5c7811f619094ddc

Contents?: true

Size: 998 Bytes

Versions: 2

Compression:

Stored size: 998 Bytes

Contents

require 'spec_helper'
require 'pry'
require 'geometer'

describe Geometer do
  it "should have a VERSION constant" do
    expect(subject.const_get('VERSION')).to_not be_empty
  end
end

describe Line do
  include PointHelpers
  let(:point_a) { coord(0,3) }
  let(:point_b) { coord(4,0) }

  describe "measuring the hypotenuse" do
    it 'should find a 3-4-5 triangle' do
      expect(Line.new(point_a,point_b).length).to eq(5)
    end

    it 'should find a 1-1-root(2) triangle' do
      expect(Line.new(coord(1,0),coord(0,1)).length).to eq(Math.sqrt(2))
    end
  end
end

describe Rectangle do
  include PointHelpers
  include DimensionHelpers

  subject(:rectangle) { Rectangle.new(origin,dimensions) }
  let(:origin) { coord(1,1) }
  let(:dimensions) { dim(2,2) }

  it 'should identify points within itself' do
    expect(rectangle.contains?(coord(1,1))).to eq(true)
    expect(rectangle.contains?(coord(1,0))).to eq(false)
    expect(rectangle.contains?(coord(1,-1))).to eq(false)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
geometer-0.1.1 spec/geometer_spec.rb
geometer-0.1.0 spec/geometer_spec.rb