diff options
| author | Tom Black <[email protected]> | 2018-12-12 00:10:14 -0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2018-12-12 00:10:14 -0800 |
| commit | 241093f3ea07255af6d36fa9e07c2a1ecb7c712f (patch) | |
| tree | c9987a2eb4d98820ba5a8845909e4c9430d31307 /test/line_spec.rb | |
| parent | 0f52b2115a5f910ae4d3350f7400bb11622ea899 (diff) | |
| download | ruby2d-241093f3ea07255af6d36fa9e07c2a1ecb7c712f.tar.gz ruby2d-241093f3ea07255af6d36fa9e07c2a1ecb7c712f.zip | |
Make `contains?` inclusive (#137)
If point is over the visual area, it's true. Also add default rectangle implementation to `renderable.rb`.
Diffstat (limited to 'test/line_spec.rb')
| -rw-r--r-- | test/line_spec.rb | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/test/line_spec.rb b/test/line_spec.rb index ac6d005..2129073 100644 --- a/test/line_spec.rb +++ b/test/line_spec.rb @@ -3,15 +3,16 @@ require 'ruby2d' RSpec.describe Ruby2D::Line do describe "#contains?" do + line = Line.new(x1: 0, y1: 0, x2: 100, y2: 100) + it "returns true if point is inside the line" do - line = Line.new(x1: 0, y1: 0, x2: 100, y2: 100) - expect(line.contains?(25, 25)).to be true + expect(line.contains?( 0, 1)).to be true + expect(line.contains?(100, 100)).to be true end it "returns false if point is outside the line" do - line = Line.new(x1: 0, y1: 0, x2: 100, y2: 100) - expect(line.contains?(0, 10)).to be false - expect(line.contains?(10, 0)).to be false + expect(line.contains?( 0, 2)).to be false + expect(line.contains?(101, 0)).to be false end end |
