diff options
Diffstat (limited to 'test/rectangle_spec.rb')
| -rw-r--r-- | test/rectangle_spec.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/test/rectangle_spec.rb b/test/rectangle_spec.rb new file mode 100644 index 0000000..493f3d1 --- /dev/null +++ b/test/rectangle_spec.rb @@ -0,0 +1,18 @@ +require 'ruby2d' + +RSpec.describe Ruby2D::Rectangle do + describe '#contains?' do + it "returns true if point is inside rectangle" do + rectangle = Rectangle.new(0, 0, 50, 50) + expect(rectangle.contains?(25, 25)).to be true + end + + it "returns true if point is not inside rectangle" do + rectangle = Rectangle.new(0, 0, 50, 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 |
