diff options
| author | Tom Black <[email protected]> | 2018-09-26 17:21:34 -0700 |
|---|---|---|
| committer | Tom Black <[email protected]> | 2018-09-26 17:21:34 -0700 |
| commit | e2fb9c34d6f56ec833e0451b26a02c304afaf71b (patch) | |
| tree | 35029a30d2d0074ad783926fcd83e6dfe1401a37 /test/triangle_spec.rb | |
| parent | 6351fe4b374000ba78e3a7795f0f05e63cbdbc29 (diff) | |
| download | ruby2d-e2fb9c34d6f56ec833e0451b26a02c304afaf71b.tar.gz ruby2d-e2fb9c34d6f56ec833e0451b26a02c304afaf71b.zip | |
Documentation and style updates
Diffstat (limited to 'test/triangle_spec.rb')
| -rw-r--r-- | test/triangle_spec.rb | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/test/triangle_spec.rb b/test/triangle_spec.rb index 045f9f3..1f9dc5d 100644 --- a/test/triangle_spec.rb +++ b/test/triangle_spec.rb @@ -1,18 +1,19 @@ require 'ruby2d' RSpec.describe Ruby2D::Triangle do - describe '#new' do - it "creates a triangle with white color by default" do + + describe "#new" do + it "creates a white triangle by default" do triangle = Triangle.new - expect(triangle.color).to be_a(Ruby2D::Color) + expect(triangle.color).to be_a(Ruby2D::Color) expect(triangle.color.r).to eq(1) expect(triangle.color.g).to eq(1) expect(triangle.color.b).to eq(1) expect(triangle.color.a).to eq(1) end - it 'creates a new triangle with one color via string' do - triangle = Triangle.new(color: "black") + it "creates a new triangle with one color via string" do + triangle = Triangle.new(color: 'black') expect(triangle.color).to be_a(Ruby2D::Color) end @@ -22,7 +23,7 @@ RSpec.describe Ruby2D::Triangle do end it "creates a new triangle with 3 colors via array of 3 strings" do - triangle = Triangle.new(color: ["red", "green", "blue"]) + triangle = Triangle.new(color: ['red', 'green', 'blue']) expect(triangle.color).to be_a(Ruby2D::Color::Set) end @@ -39,20 +40,19 @@ RSpec.describe Ruby2D::Triangle do it "throws an error when array of 2 strings is passed" do expect do - Triangle.new(color: ["red", "green"]) + Triangle.new(color: ['red', 'green']) end.to raise_error("Triangles require 3 colors, one for each vertex. 2 were given.") end it "throws an error when array of 4 strings is passed" do expect do - Triangle.new(color: ["red", "green", "blue", "fuchsia"]) + Triangle.new(color: ['red', 'green', 'blue', 'fuchsia']) end.to raise_error("Triangles require 3 colors, one for each vertex. 4 were given.") end end - - describe '#contains?' do - it "returns true if point is inside triangle" do + describe "#contains?" do + it "returns true if point is inside the triangle" do triangle = Triangle.new( x1: 0, y1: 0, x2: 0, y2: 100, @@ -61,7 +61,7 @@ RSpec.describe Ruby2D::Triangle do expect(triangle.contains?(25, 25)).to be true end - it "returns true if point is inside text" do + it "returns false if point is outside the triangle" do triangle = Triangle.new( x1: 0, y1: 0, x2: 0, y2: 100, @@ -72,4 +72,5 @@ RSpec.describe Ruby2D::Triangle do expect(triangle.contains?(100, 100)).to be false end end + end |
