test/geometry/line.rb in geometry-5 vs test/geometry/line.rb in geometry-6

- old
+ new

@@ -1,8 +1,33 @@ require 'minitest/autorun' require 'geometry/line' describe Geometry::Line do + Line = Geometry::Line + Point = Geometry::Point + + describe "when initializing" do + it "must accept two named points" do + line = Line.new(from:Point[0,0], to:Point[10,10]) + line.must_be_kind_of(Line) + line.must_be_instance_of(Geometry::TwoPointLine) + line.first.must_equal Point[0,0] + line.last.must_equal Point[10,10] + end + + it "must accept named start and end points" do + line = Line.new(start:Point[0,0], end:Point[10,10]) + line.must_be_kind_of(Line) + line.must_be_instance_of(Geometry::TwoPointLine) + line.first.must_equal Point[0,0] + line.last.must_equal Point[10,10] + end + + it "must raise an exception when no arguments are given" do + -> { Line.new }.must_raise ArgumentError + end + end + it "create a Line object from 2 Points" do line = Geometry::Line[Geometry::Point[0,0], Geometry::Point[10,10]] assert_kind_of(Geometry::Line, line) assert_kind_of(Geometry::TwoPointLine, line) end