forked from ruby2d/ruby2d
-
Notifications
You must be signed in to change notification settings - Fork 0
/
circle_spec.rb
53 lines (46 loc) · 1.32 KB
/
circle_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
require 'ruby2d'
RSpec.describe Ruby2D::Circle do
describe "#new" do
it "creates a white circle by default" do
circle = Circle.new
expect(circle.color).to be_a(Ruby2D::Color)
expect(circle.color.r).to eq(1)
expect(circle.color.g).to eq(1)
expect(circle.color.b).to eq(1)
expect(circle.color.a).to eq(1)
end
it "creates a circle with options" do
circle = Circle.new(
x: 10, y: 20, z: 30,
radius: 40, sectors: 50,
color: 'gray', opacity: 0.5
)
expect(circle.x).to eq(10)
expect(circle.y).to eq(20)
expect(circle.z).to eq(30)
expect(circle.radius).to eq(40)
expect(circle.sectors).to eq(50)
expect(circle.color.r).to eq(2/3.0)
expect(circle.color.opacity).to eq(0.5)
end
end
describe "attributes" do
it "can be set and read" do
circle = Circle.new
circle.x = 10
circle.y = 20
circle.z = 30
circle.radius = 40
circle.sectors = 50
circle.color = 'gray'
circle.color.opacity = 0.5
expect(circle.x).to eq(10)
expect(circle.y).to eq(20)
expect(circle.z).to eq(30)
expect(circle.radius).to eq(40)
expect(circle.sectors).to eq(50)
expect(circle.color.r).to eq(2/3.0)
expect(circle.color.opacity).to eq(0.5)
end
end
end