summaryrefslogtreecommitdiffhomepage
path: root/test/rectangle_spec.rb
blob: bbf1616e50cff3358e90b5c63fac199f024e8e98 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
require 'ruby2d'

RSpec.describe Ruby2D::Rectangle do

  describe "#contains?" do
    it "returns true if point is inside the rectangle" do
      rectangle = Rectangle.new(x: 0, y: 0, width: 50, height: 50)
      expect(rectangle.contains?(25, 25)).to be true
    end

    it "returns true if point is outside the rectangle" do
      rectangle = Rectangle.new(x: 0, y: 0, width: 50, height: 50)
      expect(rectangle.contains?(-25,  25)).to be false
      expect(rectangle.contains?( 25, -25)).to be false
      expect(rectangle.contains?( 25,  50)).to be false
      expect(rectangle.contains?( 50,  25)).to be false
    end
  end

end