summaryrefslogtreecommitdiffhomepage
path: root/test/text_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/text_spec.rb
parent09ed2811ad3ccb9af50028447fabbcee5b5c5ae2 (diff)
downloadruby2d-65187cd5126227778146ec33c2857a391fbab620.tar.gz
ruby2d-65187cd5126227778146ec33c2857a391fbab620.zip
Implement #contains? for all renderables
Diffstat (limited to 'test/text_spec.rb')
-rw-r--r--test/text_spec.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/text_spec.rb b/test/text_spec.rb
index ad12cbf..15038d2 100644
--- a/test/text_spec.rb
+++ b/test/text_spec.rb
@@ -41,4 +41,19 @@ RSpec.describe Ruby2D::Text do
expect(t.height).to eq(48)
end
end
+
+ describe '#contains?' do
+ it "returns true if point is inside text" do
+ text = Text.new(0, 0, "Hello world!", 40, "test/media/bitstream_vera/vera.ttf")
+ expect(text.contains?(text.width / 2, text.height / 2)).to be true
+ end
+
+ it "returns true if point is not inside text" do
+ text = Text.new(0, 0, "Hello world!", 40, "test/media/bitstream_vera/vera.ttf")
+ expect(text.contains?( - text.width / 2, text.height / 2)).to be false
+ expect(text.contains?( text.width / 2, - text.height / 2)).to be false
+ expect(text.contains?(3 * text.width / 2, text.height / 2)).to be false
+ expect(text.contains?( text.width / 2, 3 * text.height / 2)).to be false
+ end
+ end
end