summaryrefslogtreecommitdiffhomepage
path: root/test/rectangle_spec.rb
diff options
context:
space:
mode:
authorlstrzebinczyk <[email protected]>2017-05-21 21:26:12 +0200
committerTom Black <[email protected]>2017-05-31 23:36:04 -0400
commit65187cd5126227778146ec33c2857a391fbab620 (patch)
tree328c21a2bdf9365d5c018326c229760986cf412f /test/rectangle_spec.rb
parent09ed2811ad3ccb9af50028447fabbcee5b5c5ae2 (diff)
downloadruby2d-65187cd5126227778146ec33c2857a391fbab620.tar.gz
ruby2d-65187cd5126227778146ec33c2857a391fbab620.zip
Implement #contains? for all renderables
Diffstat (limited to 'test/rectangle_spec.rb')
-rw-r--r--test/rectangle_spec.rb18
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