gosu_enhanced 0.3.4 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +11 -8
- data/README.md +4 -4
- data/Rakefile +3 -3
- data/gosu_enhanced.gemspec +15 -15
- data/lib/gosu_enhanced/enhanced.rb +21 -19
- data/lib/gosu_enhanced/point.rb +38 -20
- data/lib/gosu_enhanced/region.rb +31 -14
- data/lib/gosu_enhanced/size.rb +66 -23
- data/lib/gosu_enhanced/version.rb +3 -2
- data/spec/point_spec.rb +77 -77
- data/spec/region_delegation_spec.rb +78 -78
- data/spec/region_spec.rb +40 -38
- data/spec/size_spec.rb +75 -75
- metadata +10 -10
data/spec/point_spec.rb
CHANGED
@@ -3,120 +3,120 @@ require 'spec_helper'
|
|
3
3
|
describe GosuEnhanced::Point do
|
4
4
|
describe '#initialize' do
|
5
5
|
it 'should work with two positive values' do
|
6
|
-
point = GosuEnhanced::Point.new(
|
7
|
-
expect(
|
8
|
-
expect(
|
6
|
+
point = GosuEnhanced::Point.new(10, 20)
|
7
|
+
expect(point.x).to eq 10
|
8
|
+
expect(point.y).to eq 20
|
9
9
|
end
|
10
10
|
|
11
11
|
it 'should work with negative values' do
|
12
|
-
point = GosuEnhanced::Point.new(
|
13
|
-
expect(
|
14
|
-
expect(
|
12
|
+
point = GosuEnhanced::Point.new(-10, 20)
|
13
|
+
expect(point.x).to eq(-10)
|
14
|
+
expect(point.y).to eq 20
|
15
15
|
|
16
|
-
point = GosuEnhanced::Point.new(
|
17
|
-
expect(
|
18
|
-
expect(
|
16
|
+
point = GosuEnhanced::Point.new(10, -20)
|
17
|
+
expect(point.x).to eq 10
|
18
|
+
expect(point.y).to eq(-20)
|
19
19
|
|
20
|
-
point = GosuEnhanced::Point.new(
|
21
|
-
expect(
|
22
|
-
expect(
|
20
|
+
point = GosuEnhanced::Point.new(-10, -20)
|
21
|
+
expect(point.x).to eq(-10)
|
22
|
+
expect(point.y).to eq(-20)
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
26
|
describe '#offset' do
|
27
27
|
it 'should work with another Point' do
|
28
|
-
point = GosuEnhanced::Point.new(
|
29
|
-
opoint = point.offset(
|
30
|
-
expect(
|
31
|
-
expect(
|
28
|
+
point = GosuEnhanced::Point.new(10, 20)
|
29
|
+
opoint = point.offset(GosuEnhanced::Point.new(30, 40))
|
30
|
+
expect(opoint.x).to eq 40
|
31
|
+
expect(opoint.y).to eq 60
|
32
32
|
end
|
33
33
|
|
34
34
|
it 'should work with a Size' do
|
35
|
-
point = GosuEnhanced::Point.new(
|
36
|
-
opoint = point.offset(
|
37
|
-
expect(
|
38
|
-
expect(
|
35
|
+
point = GosuEnhanced::Point.new(10, 20)
|
36
|
+
opoint = point.offset(GosuEnhanced::Size.new(50, 60))
|
37
|
+
expect(opoint.x).to eq 60
|
38
|
+
expect(opoint.y).to eq 80
|
39
39
|
end
|
40
40
|
|
41
41
|
it 'should work with two positive values' do
|
42
|
-
point = GosuEnhanced::Point.new(
|
43
|
-
opoint = point.offset(
|
44
|
-
expect(
|
45
|
-
expect(
|
42
|
+
point = GosuEnhanced::Point.new(10, 20)
|
43
|
+
opoint = point.offset(40, 50)
|
44
|
+
expect(opoint.x).to eq 50
|
45
|
+
expect(opoint.y).to eq 70
|
46
46
|
end
|
47
47
|
|
48
48
|
it 'should work with two negative values' do
|
49
|
-
point = GosuEnhanced::Point.new(
|
50
|
-
opoint = point.offset(
|
51
|
-
expect(
|
52
|
-
expect(
|
49
|
+
point = GosuEnhanced::Point.new(60, 80)
|
50
|
+
opoint = point.offset(-40, -50)
|
51
|
+
expect(opoint.x).to eq 20
|
52
|
+
expect(opoint.y).to eq 30
|
53
53
|
end
|
54
54
|
|
55
55
|
it 'should work with values that result in negative co-ordinates' do
|
56
|
-
point = GosuEnhanced::Point.new(
|
57
|
-
opoint = point.offset(
|
58
|
-
expect(
|
59
|
-
expect(
|
56
|
+
point = GosuEnhanced::Point.new(60, 80)
|
57
|
+
opoint = point.offset(-80, -150)
|
58
|
+
expect(opoint.x).to eq(-20)
|
59
|
+
expect(opoint.y).to eq(-70)
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
63
63
|
describe '#move_by!' do
|
64
64
|
it 'should work with another Point' do
|
65
|
-
point = GosuEnhanced::Point.new(
|
66
|
-
point.move_by!(
|
67
|
-
expect(
|
68
|
-
expect(
|
65
|
+
point = GosuEnhanced::Point.new(10, 20)
|
66
|
+
point.move_by!(GosuEnhanced::Point.new(30, 40))
|
67
|
+
expect(point.x).to eq 40
|
68
|
+
expect(point.y).to eq 60
|
69
69
|
end
|
70
70
|
|
71
71
|
it 'should work with a Size' do
|
72
|
-
point = GosuEnhanced::Point.new(
|
73
|
-
point.move_by!(
|
74
|
-
expect(
|
75
|
-
expect(
|
72
|
+
point = GosuEnhanced::Point.new(10, 20)
|
73
|
+
point.move_by!(GosuEnhanced::Size.new(40, 50))
|
74
|
+
expect(point.x).to eq 50
|
75
|
+
expect(point.y).to eq 70
|
76
76
|
end
|
77
77
|
|
78
78
|
it 'should work with two positive values' do
|
79
|
-
point = GosuEnhanced::Point.new(
|
80
|
-
point.move_by!(
|
81
|
-
expect(
|
82
|
-
expect(
|
79
|
+
point = GosuEnhanced::Point.new(10, 20)
|
80
|
+
point.move_by!(40, 50)
|
81
|
+
expect(point.x).to eq 50
|
82
|
+
expect(point.y).to eq 70
|
83
83
|
end
|
84
84
|
|
85
85
|
it 'should work with two negative values' do
|
86
|
-
point = GosuEnhanced::Point.new(
|
87
|
-
point.move_by!(
|
88
|
-
expect(
|
89
|
-
expect(
|
86
|
+
point = GosuEnhanced::Point.new(60, 80)
|
87
|
+
point.move_by!(-40, -50)
|
88
|
+
expect(point.x).to eq 20
|
89
|
+
expect(point.y).to eq 30
|
90
90
|
end
|
91
91
|
|
92
92
|
it 'should work with values that result in negative co-ordinates' do
|
93
|
-
point = GosuEnhanced::Point.new(
|
94
|
-
point.move_by!(
|
95
|
-
expect(
|
96
|
-
expect(
|
93
|
+
point = GosuEnhanced::Point.new(60, 80)
|
94
|
+
point.move_by!(-80, -150)
|
95
|
+
expect(point.x).to eq(-20)
|
96
|
+
expect(point.y).to eq(-70)
|
97
97
|
end
|
98
98
|
end
|
99
99
|
|
100
100
|
describe '#move_to!' do
|
101
101
|
it 'should work with another Point' do
|
102
|
-
point = GosuEnhanced::Point.new(
|
103
|
-
point.move_to!(
|
104
|
-
expect(
|
105
|
-
expect(
|
102
|
+
point = GosuEnhanced::Point.new(10, 20)
|
103
|
+
point.move_to!(GosuEnhanced::Point.new(30, 40))
|
104
|
+
expect(point.x).to eq 30
|
105
|
+
expect(point.y).to eq 40
|
106
106
|
end
|
107
107
|
|
108
108
|
it 'should work with two positive values' do
|
109
|
-
point = GosuEnhanced::Point.new(
|
110
|
-
point.move_to!(
|
111
|
-
expect(
|
112
|
-
expect(
|
109
|
+
point = GosuEnhanced::Point.new(10, 20)
|
110
|
+
point.move_to!(40, 50)
|
111
|
+
expect(point.x).to eq 40
|
112
|
+
expect(point.y).to eq 50
|
113
113
|
end
|
114
114
|
|
115
115
|
it 'should work with two negative values' do
|
116
|
-
point = GosuEnhanced::Point.new(
|
117
|
-
point.move_to!(
|
118
|
-
expect(
|
119
|
-
expect(
|
116
|
+
point = GosuEnhanced::Point.new(60, 80)
|
117
|
+
point.move_to!(-40, -50)
|
118
|
+
expect(point.x).to eq(-40)
|
119
|
+
expect(point.y).to eq(-50)
|
120
120
|
end
|
121
121
|
end
|
122
122
|
|
@@ -124,28 +124,28 @@ describe GosuEnhanced::Point do
|
|
124
124
|
|
125
125
|
describe '#dup' do
|
126
126
|
it 'should make a copy of the Point' do
|
127
|
-
point = GosuEnhanced::Point.new(
|
127
|
+
point = GosuEnhanced::Point.new(10, 20)
|
128
128
|
npoint = point.dup
|
129
129
|
|
130
|
-
expect(
|
131
|
-
expect(
|
130
|
+
expect(point.x).to eq 10
|
131
|
+
expect(point.y).to eq 20
|
132
132
|
|
133
|
-
expect(
|
134
|
-
expect(
|
133
|
+
expect(npoint.x).to eq 10
|
134
|
+
expect(npoint.y).to eq 20
|
135
135
|
|
136
|
-
npoint.move_to!(
|
137
|
-
expect(
|
138
|
-
expect(
|
136
|
+
npoint.move_to!(40, 50)
|
137
|
+
expect(npoint.x).to eq 40
|
138
|
+
expect(npoint.y).to eq 50
|
139
139
|
|
140
|
-
expect(
|
141
|
-
expect(
|
140
|
+
expect(point.x).to eq 10
|
141
|
+
expect(point.y).to eq 20
|
142
142
|
end
|
143
143
|
end
|
144
|
-
|
144
|
+
|
145
145
|
describe '#to_s' do
|
146
146
|
it 'should render usefully.' do
|
147
|
-
point = GosuEnhanced::Point.new(
|
148
|
-
expect(
|
147
|
+
point = GosuEnhanced::Point.new(10, 20)
|
148
|
+
expect(point.to_s).to eq '#<struct GosuEnhanced::Point x=10, y=20>'
|
149
149
|
end
|
150
150
|
end
|
151
151
|
end
|
@@ -1,161 +1,161 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe GosuEnhanced::Region do
|
4
|
-
let(
|
5
|
-
let(
|
4
|
+
let(:point) { GosuEnhanced::Point.new(10, 20) }
|
5
|
+
let(:size) { GosuEnhanced::Size.new(30, 40) }
|
6
6
|
|
7
7
|
describe '#x' do
|
8
8
|
it 'should return the left (x) co-ordinate' do
|
9
|
-
reg = GosuEnhanced::Region.new(
|
10
|
-
expect(
|
9
|
+
reg = GosuEnhanced::Region.new(point, size)
|
10
|
+
expect(reg.x).to eq 10
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
14
|
describe '#y' do
|
15
15
|
it 'should return the top (y) co-ordinate' do
|
16
|
-
reg = GosuEnhanced::Region.new(
|
17
|
-
expect(
|
16
|
+
reg = GosuEnhanced::Region.new(point, size)
|
17
|
+
expect(reg.y).to eq 20
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
21
|
describe '#width' do
|
22
22
|
it 'should return the width' do
|
23
|
-
reg = GosuEnhanced::Region.new(
|
24
|
-
expect(
|
23
|
+
reg = GosuEnhanced::Region.new(point, size)
|
24
|
+
expect(reg.width).to eq 30
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
28
|
describe '#height' do
|
29
29
|
it 'should return the height' do
|
30
|
-
reg = GosuEnhanced::Region.new(
|
31
|
-
expect(
|
30
|
+
reg = GosuEnhanced::Region.new(point, size)
|
31
|
+
expect(reg.height).to eq 40
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
35
|
describe '#move_by!' do
|
36
36
|
it 'should work with a Point' do
|
37
|
-
reg = GosuEnhanced::Region.new(
|
38
|
-
reg.move_by!(
|
39
|
-
expect(
|
40
|
-
expect(
|
37
|
+
reg = GosuEnhanced::Region.new(point, size)
|
38
|
+
reg.move_by!(GosuEnhanced::Point.new(30, 40))
|
39
|
+
expect(reg.left).to eq 40
|
40
|
+
expect(reg.top).to eq 60
|
41
41
|
|
42
42
|
# The original point should not have been changed by the move_by!
|
43
|
-
expect(
|
44
|
-
expect(
|
43
|
+
expect(point.x).to eq 10
|
44
|
+
expect(point.y).to eq 20
|
45
45
|
end
|
46
46
|
|
47
47
|
it 'should work with a Size' do
|
48
|
-
reg = GosuEnhanced::Region.new(
|
49
|
-
reg.move_by!(
|
50
|
-
expect(
|
51
|
-
expect(
|
48
|
+
reg = GosuEnhanced::Region.new(point, size)
|
49
|
+
reg.move_by!(GosuEnhanced::Size.new(40, 50))
|
50
|
+
expect(reg.left).to eq 50
|
51
|
+
expect(reg.top).to eq 70
|
52
52
|
end
|
53
53
|
|
54
54
|
it 'should work with two positive values' do
|
55
|
-
reg = GosuEnhanced::Region.new(
|
56
|
-
reg.move_by!(
|
57
|
-
expect(
|
58
|
-
expect(
|
55
|
+
reg = GosuEnhanced::Region.new(point, size)
|
56
|
+
reg.move_by!(40, 50)
|
57
|
+
expect(reg.left).to eq 50
|
58
|
+
expect(reg.top).to eq 70
|
59
59
|
end
|
60
60
|
|
61
61
|
it 'should work with two negative values' do
|
62
|
-
reg = GosuEnhanced::Region.new(
|
63
|
-
reg.move_by!(
|
64
|
-
expect(
|
65
|
-
expect(
|
62
|
+
reg = GosuEnhanced::Region.new(point, size)
|
63
|
+
reg.move_by!(-5, -10)
|
64
|
+
expect(reg.left).to eq 5
|
65
|
+
expect(reg.top).to eq 10
|
66
66
|
end
|
67
67
|
|
68
68
|
it 'should work with values that result in negative co-ordinates' do
|
69
|
-
reg = GosuEnhanced::Region.new(
|
70
|
-
reg.move_by!(
|
71
|
-
expect(
|
72
|
-
expect(
|
69
|
+
reg = GosuEnhanced::Region.new(point, size)
|
70
|
+
reg.move_by!(-80, -150)
|
71
|
+
expect(reg.left).to eq(-70)
|
72
|
+
expect(reg.top).to eq(-130)
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
76
76
|
describe '#move_to!' do
|
77
77
|
it 'should work with a Point' do
|
78
|
-
reg = GosuEnhanced::Region.new(
|
79
|
-
reg.move_to!(
|
80
|
-
expect(
|
81
|
-
expect(
|
78
|
+
reg = GosuEnhanced::Region.new(point, size)
|
79
|
+
reg.move_to!(GosuEnhanced::Point.new(30, 40))
|
80
|
+
expect(reg.left).to eq 30
|
81
|
+
expect(reg.top).to eq 40
|
82
82
|
|
83
|
-
expect(
|
84
|
-
expect(
|
83
|
+
expect(point.x).to eq 10
|
84
|
+
expect(point.y).to eq 20
|
85
85
|
end
|
86
86
|
|
87
87
|
it 'should work with two positive values' do
|
88
|
-
reg = GosuEnhanced::Region.new(
|
89
|
-
reg.move_to!(
|
90
|
-
expect(
|
91
|
-
expect(
|
88
|
+
reg = GosuEnhanced::Region.new(point, size)
|
89
|
+
reg.move_to!(40, 50)
|
90
|
+
expect(reg.left).to eq 40
|
91
|
+
expect(reg.top).to eq 50
|
92
92
|
end
|
93
93
|
|
94
94
|
it 'should work with two negative values' do
|
95
|
-
reg = GosuEnhanced::Region.new(
|
96
|
-
reg.move_to!(
|
97
|
-
expect(
|
98
|
-
expect(
|
95
|
+
reg = GosuEnhanced::Region.new(point, size)
|
96
|
+
reg.move_to!(-5, -10)
|
97
|
+
expect(reg.left).to eq(-5)
|
98
|
+
expect(reg.top).to eq(-10)
|
99
99
|
end
|
100
100
|
end
|
101
101
|
|
102
102
|
describe '#inflate!' do
|
103
103
|
it 'should work with a Size' do
|
104
|
-
reg = GosuEnhanced::Region.new(
|
105
|
-
reg.inflate!(
|
106
|
-
expect(
|
107
|
-
expect(
|
104
|
+
reg = GosuEnhanced::Region.new(point, size)
|
105
|
+
reg.inflate!(GosuEnhanced::Size.new(30, 40))
|
106
|
+
expect(reg.width).to eq 60
|
107
|
+
expect(reg.height).to eq 80
|
108
108
|
|
109
109
|
# The original size should not have been changed by the inflate!
|
110
|
-
expect(
|
111
|
-
expect(
|
110
|
+
expect(size.width).to eq 30
|
111
|
+
expect(size.height).to eq 40
|
112
112
|
end
|
113
113
|
|
114
114
|
it 'should work with two values' do
|
115
|
-
reg = GosuEnhanced::Region.new(
|
116
|
-
reg.inflate!(
|
117
|
-
expect(
|
118
|
-
expect(
|
115
|
+
reg = GosuEnhanced::Region.new(point, size)
|
116
|
+
reg.inflate!(40, 50)
|
117
|
+
expect(reg.width).to eq 70
|
118
|
+
expect(reg.height).to eq 90
|
119
119
|
end
|
120
120
|
|
121
121
|
it 'should work with negative values' do
|
122
|
-
reg = GosuEnhanced::Region.new(
|
123
|
-
reg.inflate!(
|
124
|
-
expect(
|
125
|
-
expect(
|
122
|
+
reg = GosuEnhanced::Region.new(point, size)
|
123
|
+
reg.inflate!(-20, -35)
|
124
|
+
expect(reg.width).to eq 10
|
125
|
+
expect(reg.height).to eq 5
|
126
126
|
end
|
127
127
|
|
128
128
|
it 'should raise an error with out-of-range values' do
|
129
|
-
reg = GosuEnhanced::Region.new(
|
130
|
-
expect { reg.inflate!(
|
131
|
-
expect { reg.inflate!(
|
132
|
-
expect { reg.inflate!(
|
129
|
+
reg = GosuEnhanced::Region.new(point, size)
|
130
|
+
expect { reg.inflate!(-50, -20) }.to raise_error Exception
|
131
|
+
expect { reg.inflate!(-25, -60) }.to raise_error Exception
|
132
|
+
expect { reg.inflate!(-50, -70) }.to raise_error Exception
|
133
133
|
end
|
134
134
|
end
|
135
135
|
|
136
136
|
describe '#deflate!' do
|
137
137
|
it 'should work with a Size' do
|
138
|
-
reg = GosuEnhanced::Region.new(
|
139
|
-
reg.deflate!(
|
140
|
-
expect(
|
141
|
-
expect(
|
138
|
+
reg = GosuEnhanced::Region.new(point, size)
|
139
|
+
reg.deflate!(GosuEnhanced::Size.new(20, 35))
|
140
|
+
expect(reg.width).to eq 10
|
141
|
+
expect(reg.height).to eq 5
|
142
142
|
|
143
|
-
expect(
|
144
|
-
expect(
|
143
|
+
expect(size.width).to eq 30
|
144
|
+
expect(size.height).to eq 40
|
145
145
|
end
|
146
146
|
|
147
147
|
it 'should work with two values' do
|
148
|
-
reg = GosuEnhanced::Region.new(
|
149
|
-
reg.deflate!(
|
150
|
-
expect(
|
151
|
-
expect(
|
148
|
+
reg = GosuEnhanced::Region.new(point, size)
|
149
|
+
reg.deflate!(10, 25)
|
150
|
+
expect(reg.width).to eq 20
|
151
|
+
expect(reg.height).to eq 15
|
152
152
|
end
|
153
153
|
|
154
154
|
it 'should raise an error for out-of-range values' do
|
155
|
-
reg = GosuEnhanced::Region.new(
|
156
|
-
expect { reg.deflate!(
|
157
|
-
expect { reg.deflate!(
|
158
|
-
expect { reg.deflate!(
|
155
|
+
reg = GosuEnhanced::Region.new(point, size)
|
156
|
+
expect { reg.deflate!(25, 50) }.to raise_error Exception
|
157
|
+
expect { reg.deflate!(60, 35) }.to raise_error Exception
|
158
|
+
expect { reg.deflate!(80, 70) }.to raise_error Exception
|
159
159
|
end
|
160
160
|
end
|
161
161
|
end
|
data/spec/region_spec.rb
CHANGED
@@ -1,58 +1,58 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe GosuEnhanced::Region do
|
4
|
-
let(
|
5
|
-
let(
|
4
|
+
let(:point) { GosuEnhanced::Point.new(10, 20) }
|
5
|
+
let(:size) { GosuEnhanced::Size.new(30, 40) }
|
6
6
|
|
7
7
|
describe '#initialize' do
|
8
8
|
it 'should work with a Point and a Size' do
|
9
|
-
GosuEnhanced::Region.new(
|
9
|
+
GosuEnhanced::Region.new(point, size)
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
13
|
describe '#position' do
|
14
14
|
it 'should return the position as a Point' do
|
15
|
-
reg = GosuEnhanced::Region.new(
|
16
|
-
expect(
|
15
|
+
reg = GosuEnhanced::Region.new(point, size)
|
16
|
+
expect(reg.position).to eq GosuEnhanced::Point.new(10, 20)
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
20
|
describe '#top' do
|
21
21
|
it 'should return the top co-ordinate' do
|
22
|
-
reg = GosuEnhanced::Region.new(
|
23
|
-
expect(
|
22
|
+
reg = GosuEnhanced::Region.new(point, size)
|
23
|
+
expect(reg.top).to eq 20
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
27
|
describe '#left' do
|
28
28
|
it 'should return the left co-ordinate' do
|
29
|
-
reg = GosuEnhanced::Region.new(
|
30
|
-
expect(
|
29
|
+
reg = GosuEnhanced::Region.new(point, size)
|
30
|
+
expect(reg.left).to eq 10
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
34
|
describe '#size' do
|
35
35
|
it 'should return the size as a Size' do
|
36
|
-
reg = GosuEnhanced::Region.new(
|
37
|
-
expect(
|
36
|
+
reg = GosuEnhanced::Region.new(point, size)
|
37
|
+
expect(reg.size).to eq GosuEnhanced::Size.new(30, 40)
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
41
|
describe '#contains?' do
|
42
42
|
it 'should work with two co-ordinates' do
|
43
|
-
reg = GosuEnhanced::Region.new(
|
44
|
-
expect(
|
45
|
-
expect(
|
46
|
-
expect(
|
47
|
-
expect(
|
43
|
+
reg = GosuEnhanced::Region.new(point, size)
|
44
|
+
expect(reg.contains?(10, 20)).to be true
|
45
|
+
expect(reg.contains?(20, 35)).to be true
|
46
|
+
expect(reg.contains?(29, 59)).to be true
|
47
|
+
expect(reg.contains?(30, 60)).to be false
|
48
48
|
end
|
49
49
|
|
50
50
|
it 'should work with a Point' do
|
51
|
-
reg = GosuEnhanced::Region.new(
|
52
|
-
expect(
|
53
|
-
expect(
|
54
|
-
expect(
|
55
|
-
expect(
|
51
|
+
reg = GosuEnhanced::Region.new(point, size)
|
52
|
+
expect(reg.contains?(GosuEnhanced::Point.new(10, 20))).to be true
|
53
|
+
expect(reg.contains?(GosuEnhanced::Point.new(20, 35))).to be true
|
54
|
+
expect(reg.contains?(GosuEnhanced::Point.new(29, 59))).to be true
|
55
|
+
expect(reg.contains?(GosuEnhanced::Point.new(30, 60))).to be false
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
@@ -61,32 +61,34 @@ describe GosuEnhanced::Region do
|
|
61
61
|
|
62
62
|
describe '#dup' do
|
63
63
|
it 'should duplicate a region' do
|
64
|
-
reg = GosuEnhanced::Region.new(
|
64
|
+
reg = GosuEnhanced::Region.new(point, size)
|
65
65
|
new_reg = reg.dup
|
66
66
|
|
67
|
-
expect(
|
68
|
-
expect(
|
67
|
+
expect(reg.position).to eq GosuEnhanced::Point.new(10, 20)
|
68
|
+
expect(reg.size).to eq GosuEnhanced::Size.new(30, 40)
|
69
69
|
|
70
|
-
expect(
|
71
|
-
expect(
|
70
|
+
expect(new_reg.position).to eq GosuEnhanced::Point.new(10, 20)
|
71
|
+
expect(new_reg.size).to eq GosuEnhanced::Size.new(30, 40)
|
72
72
|
|
73
|
-
new_reg.move_to!(
|
74
|
-
new_reg.inflate!(
|
75
|
-
expect(
|
76
|
-
expect(
|
73
|
+
new_reg.move_to!(20, 30)
|
74
|
+
new_reg.inflate!(10, 10)
|
75
|
+
expect(new_reg.position).to eq GosuEnhanced::Point.new(20, 30)
|
76
|
+
expect(new_reg.size).to eq GosuEnhanced::Size.new(40, 50)
|
77
77
|
|
78
|
-
expect(
|
79
|
-
expect(
|
78
|
+
expect(reg.position).to eq GosuEnhanced::Point.new(10, 20)
|
79
|
+
expect(reg.size).to eq GosuEnhanced::Size.new(30, 40)
|
80
80
|
end
|
81
81
|
end
|
82
|
-
|
82
|
+
|
83
83
|
describe '#to_s' do
|
84
84
|
it 'should render usefully' do
|
85
|
-
point = GosuEnhanced::Point.new(
|
86
|
-
size = GosuEnhanced::Size.new(
|
87
|
-
region = GosuEnhanced::Region.new(
|
88
|
-
|
89
|
-
expect(
|
85
|
+
point = GosuEnhanced::Point.new(10, 20)
|
86
|
+
size = GosuEnhanced::Size.new(30, 40)
|
87
|
+
region = GosuEnhanced::Region.new(point, size)
|
88
|
+
|
89
|
+
expect(region.to_s).to eq '<GosuEnhanced::Region: ' \
|
90
|
+
'#<struct GosuEnhanced::Point x=10, y=20>' \
|
91
|
+
', <GosuEnhanced::Size 30x40>>'
|
90
92
|
end
|
91
93
|
end
|
92
94
|
end
|