diff options
| author | lstrzebinczyk <[email protected]> | 2017-05-21 21:26:12 +0200 |
|---|---|---|
| committer | Tom Black <[email protected]> | 2017-05-31 23:36:04 -0400 |
| commit | 65187cd5126227778146ec33c2857a391fbab620 (patch) | |
| tree | 328c21a2bdf9365d5c018326c229760986cf412f /test/image_spec.rb | |
| parent | 09ed2811ad3ccb9af50028447fabbcee5b5c5ae2 (diff) | |
| download | ruby2d-65187cd5126227778146ec33c2857a391fbab620.tar.gz ruby2d-65187cd5126227778146ec33c2857a391fbab620.zip | |
Implement #contains? for all renderables
Diffstat (limited to 'test/image_spec.rb')
| -rw-r--r-- | test/image_spec.rb | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/test/image_spec.rb b/test/image_spec.rb index 3eb5d86..33dee35 100644 --- a/test/image_spec.rb +++ b/test/image_spec.rb @@ -1,11 +1,25 @@ require 'ruby2d' RSpec.describe Ruby2D::Image do - describe '#new' do it "raises exception if image file doesn't exist" do expect { Image.new(0, 0, 'bad_image.png') }.to raise_error(Ruby2D::Error) end end + # Image has 100 width and 100 height + describe '#contains?' do + it "returns true if point is inside image" do + image = Image.new(0, 0, "test/media/image.bmp") + expect(image.contains?(50, 50)).to be true + end + + it "returns true if point is not inside image" do + image = Image.new(0, 0, "test/media/image.bmp") + expect(image.contains?(-50, 50)).to be false + expect(image.contains?(50, -50)).to be false + expect(image.contains?(50, 150)).to be false + expect(image.contains?(150, 50)).to be false + end + end end |
