gosu_enhanced 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 86a01316020552b01f0150a2bb8959dbdbdeaa21
4
- data.tar.gz: 275b3afa6758e7a4c5183ebb39ecfe66714dfab3
3
+ metadata.gz: 1ef82237800c5e7fd75f41a937f99d7b808404ab
4
+ data.tar.gz: b98df43837d6c32aea1ac89ed56535312aba3122
5
5
  SHA512:
6
- metadata.gz: 6f4abcb1c2bcaffac031df9bdd7fc1f167de6b0d96204d7657eb558c79221c8ca470d79eb3d542a7371e8f188a3cd45bf2877eac468cbc049fa42bbeba95e469
7
- data.tar.gz: 5bff949502d28ffe791207ed7b363efdfe98b7d8c75f5a25646d7b4d8a641434bdbe3829d4483502c05f79ae86633d032ec0aa369a556edf505cc5d31cbc3b2c
6
+ metadata.gz: a72b1e8286b8db6942610d7a3c5ecae0ea1f0406266141867e242d38359cf9b9bde2b0d89b5ff267f1142d725f6d43e854e76e724f29faa9daef78e84118bce0
7
+ data.tar.gz: ffb4c4a46f40322495bed1705429e7e36d13a439aa8c7dcfb2a0502d9c25c17c9bd215c2da938a98a58645cdf31586b9534addd1cf0a9673180f6ea6b5c2be3d
@@ -1,49 +1,24 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gosu_enhanced (0.3.4)
4
+ gosu_enhanced (0.4.1)
5
5
  gosu (~> 0.10)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- coderay (1.1.0)
11
- diff-lcs (1.2.5)
12
- gosu (0.10.0)
13
- method_source (0.8.2)
14
- pry (0.10.0)
15
- coderay (~> 1.1.0)
16
- method_source (~> 0.8.1)
17
- slop (~> 3.4)
18
- rake (0.9.6)
19
- rspec (3.0.0)
20
- rspec-core (~> 3.0.0)
21
- rspec-expectations (~> 3.0.0)
22
- rspec-mocks (~> 3.0.0)
23
- rspec-core (3.0.2)
24
- rspec-support (~> 3.0.0)
25
- rspec-expectations (3.0.2)
26
- diff-lcs (>= 1.2.0, < 2.0)
27
- rspec-support (~> 3.0.0)
28
- rspec-mocks (3.0.2)
29
- rspec-support (~> 3.0.0)
30
- rspec-nc (0.1.0)
31
- rspec (>= 2.9)
32
- terminal-notifier (~> 1.4.2)
33
- rspec-support (3.0.2)
34
- slop (3.5.0)
35
- terminal-notifier (1.4.2)
10
+ gosu (0.10.1.2)
11
+ minitest (5.8.0)
12
+ rake (10.4.2)
36
13
 
37
14
  PLATFORMS
38
15
  ruby
39
16
 
40
17
  DEPENDENCIES
41
- bundler
18
+ bundler (~> 1.10)
42
19
  gosu_enhanced!
43
- pry
44
- rake
45
- rspec
46
- rspec-nc
20
+ minitest (~> 5.8)
21
+ rake (~> 10.0)
47
22
 
48
23
  BUNDLED WITH
49
24
  1.10.6
data/Rakefile CHANGED
@@ -1,10 +1,10 @@
1
- require 'rspec/core/rake_task'
2
- require 'bundler/gem_tasks'
1
+ require 'rake'
2
+ require 'rake/testtask'
3
3
 
4
- # Default directory for tests is ./spec
5
- # Run with rake spec
6
- RSpec::Core::RakeTask.new(:spec) do |task|
7
- task.rspec_opts = ['--color']
4
+ Rake::TestTask.new do |t|
5
+ t.libs << 'test'
6
+ t.test_files = FileList['test/*_test.rb']
7
+ t.verbose = true
8
8
  end
9
9
 
10
- task default: :spec
10
+ task default: :test
@@ -26,7 +26,5 @@ of text in a rectangle size.)
26
26
 
27
27
  spec.add_development_dependency 'bundler', '~> 1.10'
28
28
  spec.add_development_dependency 'rake', '~> 10.0'
29
- spec.add_development_dependency 'rspec', '~> 3.0'
30
- spec.add_development_dependency 'rspec-nc', '~> 0.2'
31
- spec.add_development_dependency 'pry', '~> 0.10'
29
+ spec.add_development_dependency 'minitest', '~> 5.8'
32
30
  end
@@ -59,5 +59,7 @@ module GosuEnhanced
59
59
  def Point(x, y)
60
60
  Point.new(x, y)
61
61
  end
62
+
63
+ module_function :Point
62
64
  end
63
65
 
@@ -15,13 +15,19 @@ module GosuEnhanced
15
15
  attr_reader :size
16
16
 
17
17
  # Create a new region with specified +pos+ as top left corner and +size+
18
- # as width and height
18
+ # as width and height.
19
+ #
20
+ # Alternatively, can be initialized with 2 +Point+s.
21
+
19
22
  def initialize(pos, size)
23
+ size = Size.new(size.x - pos.x, size.y - pos.y) if size.respond_to? :x
24
+
20
25
  @position = pos.dup
21
26
  @size = size.dup
22
27
  end
23
28
 
24
29
  # Return whether the region contains the specified +row+ and +col+
30
+ # Alternatively, can be passed a +Point+
25
31
  def contains?(col, row = nil)
26
32
  return contains_point?(col) if col.respond_to? :x
27
33
 
@@ -39,7 +45,6 @@ module GosuEnhanced
39
45
  position.x
40
46
  end
41
47
 
42
- # It is necessary to override dup to produce an actual duplicate.
43
48
  def dup
44
49
  Region.new(position, size)
45
50
  end
@@ -57,10 +62,15 @@ module GosuEnhanced
57
62
 
58
63
  private
59
64
 
60
- # NODOC
61
65
  def contains_point?(pt)
62
66
  pt.x.between?(left, left + width - 1) &&
63
67
  pt.y.between?(top, top + height - 1)
64
68
  end
65
69
  end
70
+
71
+ def Region(pos, size)
72
+ Region.new(pos, size)
73
+ end
74
+
75
+ module_function :Region
66
76
  end
@@ -109,4 +109,6 @@ module GosuEnhanced
109
109
  def Size(x, y)
110
110
  Size.new(x, y)
111
111
  end
112
+
113
+ module_function :Size
112
114
  end
@@ -1,5 +1,5 @@
1
1
  # Version of the gosu_enhanced gem.
2
2
  module GosuEnhanced
3
3
  # gosu_enhanced gem version
4
- VERSION = '0.4.1'
4
+ VERSION = '0.4.2'
5
5
  end
@@ -1,25 +1,31 @@
1
- require 'spec_helper'
1
+ require 'test_helper'
2
2
 
3
3
  describe GosuEnhanced::Point do
4
4
  describe '#initialize' do
5
5
  it 'should work with two positive values' do
6
6
  point = GosuEnhanced::Point.new(10, 20)
7
- expect(point.x).to eq 10
8
- expect(point.y).to eq 20
7
+ point.x.must_equal 10
8
+ point.y.must_equal 20
9
9
  end
10
10
 
11
11
  it 'should work with negative values' do
12
12
  point = GosuEnhanced::Point.new(-10, 20)
13
- expect(point.x).to eq(-10)
14
- expect(point.y).to eq 20
13
+ point.x.must_equal(-10)
14
+ point.y.must_equal 20
15
15
 
16
16
  point = GosuEnhanced::Point.new(10, -20)
17
- expect(point.x).to eq 10
18
- expect(point.y).to eq(-20)
17
+ point.x.must_equal 10
18
+ point.y.must_equal(-20)
19
19
 
20
20
  point = GosuEnhanced::Point.new(-10, -20)
21
- expect(point.x).to eq(-10)
22
- expect(point.y).to eq(-20)
21
+ point.x.must_equal(-10)
22
+ point.y.must_equal(-20)
23
+ end
24
+
25
+ it "should work with the utility function" do
26
+ point = GosuEnhanced::Point(10, 20)
27
+ point.x.must_equal 10
28
+ point.y.must_equal 20
23
29
  end
24
30
  end
25
31
 
@@ -27,36 +33,36 @@ describe GosuEnhanced::Point do
27
33
  it 'should work with another Point' do
28
34
  point = GosuEnhanced::Point.new(10, 20)
29
35
  opoint = point.offset(GosuEnhanced::Point.new(30, 40))
30
- expect(opoint.x).to eq 40
31
- expect(opoint.y).to eq 60
36
+ opoint.x.must_equal 40
37
+ opoint.y.must_equal 60
32
38
  end
33
39
 
34
40
  it 'should work with a Size' do
35
41
  point = GosuEnhanced::Point.new(10, 20)
36
42
  opoint = point.offset(GosuEnhanced::Size.new(50, 60))
37
- expect(opoint.x).to eq 60
38
- expect(opoint.y).to eq 80
43
+ opoint.x.must_equal 60
44
+ opoint.y.must_equal 80
39
45
  end
40
46
 
41
47
  it 'should work with two positive values' do
42
48
  point = GosuEnhanced::Point.new(10, 20)
43
49
  opoint = point.offset(40, 50)
44
- expect(opoint.x).to eq 50
45
- expect(opoint.y).to eq 70
50
+ opoint.x.must_equal 50
51
+ opoint.y.must_equal 70
46
52
  end
47
53
 
48
54
  it 'should work with two negative values' do
49
55
  point = GosuEnhanced::Point.new(60, 80)
50
56
  opoint = point.offset(-40, -50)
51
- expect(opoint.x).to eq 20
52
- expect(opoint.y).to eq 30
57
+ opoint.x.must_equal 20
58
+ opoint.y.must_equal 30
53
59
  end
54
60
 
55
61
  it 'should work with values that result in negative co-ordinates' do
56
62
  point = GosuEnhanced::Point.new(60, 80)
57
63
  opoint = point.offset(-80, -150)
58
- expect(opoint.x).to eq(-20)
59
- expect(opoint.y).to eq(-70)
64
+ opoint.x.must_equal(-20)
65
+ opoint.y.must_equal(-70)
60
66
  end
61
67
  end
62
68
 
@@ -64,36 +70,36 @@ describe GosuEnhanced::Point do
64
70
  it 'should work with another Point' do
65
71
  point = GosuEnhanced::Point.new(10, 20)
66
72
  point.move_by!(GosuEnhanced::Point.new(30, 40))
67
- expect(point.x).to eq 40
68
- expect(point.y).to eq 60
73
+ point.x.must_equal 40
74
+ point.y.must_equal 60
69
75
  end
70
76
 
71
77
  it 'should work with a Size' do
72
78
  point = GosuEnhanced::Point.new(10, 20)
73
79
  point.move_by!(GosuEnhanced::Size.new(40, 50))
74
- expect(point.x).to eq 50
75
- expect(point.y).to eq 70
80
+ point.x.must_equal 50
81
+ point.y.must_equal 70
76
82
  end
77
83
 
78
84
  it 'should work with two positive values' do
79
85
  point = GosuEnhanced::Point.new(10, 20)
80
86
  point.move_by!(40, 50)
81
- expect(point.x).to eq 50
82
- expect(point.y).to eq 70
87
+ point.x.must_equal 50
88
+ point.y.must_equal 70
83
89
  end
84
90
 
85
91
  it 'should work with two negative values' do
86
92
  point = GosuEnhanced::Point.new(60, 80)
87
93
  point.move_by!(-40, -50)
88
- expect(point.x).to eq 20
89
- expect(point.y).to eq 30
94
+ point.x.must_equal 20
95
+ point.y.must_equal 30
90
96
  end
91
97
 
92
98
  it 'should work with values that result in negative co-ordinates' do
93
99
  point = GosuEnhanced::Point.new(60, 80)
94
100
  point.move_by!(-80, -150)
95
- expect(point.x).to eq(-20)
96
- expect(point.y).to eq(-70)
101
+ point.x.must_equal(-20)
102
+ point.y.must_equal(-70)
97
103
  end
98
104
  end
99
105
 
@@ -101,22 +107,22 @@ describe GosuEnhanced::Point do
101
107
  it 'should work with another Point' do
102
108
  point = GosuEnhanced::Point.new(10, 20)
103
109
  point.move_to!(GosuEnhanced::Point.new(30, 40))
104
- expect(point.x).to eq 30
105
- expect(point.y).to eq 40
110
+ point.x.must_equal 30
111
+ point.y.must_equal 40
106
112
  end
107
113
 
108
114
  it 'should work with two positive values' do
109
115
  point = GosuEnhanced::Point.new(10, 20)
110
116
  point.move_to!(40, 50)
111
- expect(point.x).to eq 40
112
- expect(point.y).to eq 50
117
+ point.x.must_equal 40
118
+ point.y.must_equal 50
113
119
  end
114
120
 
115
121
  it 'should work with two negative values' do
116
122
  point = GosuEnhanced::Point.new(60, 80)
117
123
  point.move_to!(-40, -50)
118
- expect(point.x).to eq(-40)
119
- expect(point.y).to eq(-50)
124
+ point.x.must_equal(-40)
125
+ point.y.must_equal(-50)
120
126
  end
121
127
  end
122
128
 
@@ -127,25 +133,25 @@ describe GosuEnhanced::Point do
127
133
  point = GosuEnhanced::Point.new(10, 20)
128
134
  npoint = point.dup
129
135
 
130
- expect(point.x).to eq 10
131
- expect(point.y).to eq 20
136
+ point.x.must_equal 10
137
+ point.y.must_equal 20
132
138
 
133
- expect(npoint.x).to eq 10
134
- expect(npoint.y).to eq 20
139
+ npoint.x.must_equal 10
140
+ npoint.y.must_equal 20
135
141
 
136
142
  npoint.move_to!(40, 50)
137
- expect(npoint.x).to eq 40
138
- expect(npoint.y).to eq 50
143
+ npoint.x.must_equal 40
144
+ npoint.y.must_equal 50
139
145
 
140
- expect(point.x).to eq 10
141
- expect(point.y).to eq 20
146
+ point.x.must_equal 10
147
+ point.y.must_equal 20
142
148
  end
143
149
  end
144
150
 
145
151
  describe '#to_s' do
146
152
  it 'should render usefully.' do
147
153
  point = GosuEnhanced::Point.new(10, 20)
148
- expect(point.to_s).to eq '#<struct GosuEnhanced::Point x=10, y=20>'
154
+ point.to_s.must_equal '#<struct GosuEnhanced::Point x=10, y=20>'
149
155
  end
150
156
  end
151
157
  end
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require 'test_helper'
2
2
 
3
3
  describe GosuEnhanced::Region do
4
4
  let(:point) { GosuEnhanced::Point.new(10, 20) }
@@ -7,28 +7,28 @@ describe GosuEnhanced::Region do
7
7
  describe '#x' do
8
8
  it 'should return the left (x) co-ordinate' do
9
9
  reg = GosuEnhanced::Region.new(point, size)
10
- expect(reg.x).to eq 10
10
+ reg.x.must_equal 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
16
  reg = GosuEnhanced::Region.new(point, size)
17
- expect(reg.y).to eq 20
17
+ reg.y.must_equal 20
18
18
  end
19
19
  end
20
20
 
21
21
  describe '#width' do
22
22
  it 'should return the width' do
23
23
  reg = GosuEnhanced::Region.new(point, size)
24
- expect(reg.width).to eq 30
24
+ reg.width.must_equal 30
25
25
  end
26
26
  end
27
27
 
28
28
  describe '#height' do
29
29
  it 'should return the height' do
30
30
  reg = GosuEnhanced::Region.new(point, size)
31
- expect(reg.height).to eq 40
31
+ reg.height.must_equal 40
32
32
  end
33
33
  end
34
34
 
@@ -36,40 +36,40 @@ describe GosuEnhanced::Region do
36
36
  it 'should work with a Point' do
37
37
  reg = GosuEnhanced::Region.new(point, size)
38
38
  reg.move_by!(GosuEnhanced::Point.new(30, 40))
39
- expect(reg.left).to eq 40
40
- expect(reg.top).to eq 60
39
+ reg.left.must_equal 40
40
+ reg.top.must_equal 60
41
41
 
42
42
  # The original point should not have been changed by the move_by!
43
- expect(point.x).to eq 10
44
- expect(point.y).to eq 20
43
+ point.x.must_equal 10
44
+ point.y.must_equal 20
45
45
  end
46
46
 
47
47
  it 'should work with a Size' do
48
48
  reg = GosuEnhanced::Region.new(point, size)
49
49
  reg.move_by!(GosuEnhanced::Size.new(40, 50))
50
- expect(reg.left).to eq 50
51
- expect(reg.top).to eq 70
50
+ reg.left.must_equal 50
51
+ reg.top.must_equal 70
52
52
  end
53
53
 
54
54
  it 'should work with two positive values' do
55
55
  reg = GosuEnhanced::Region.new(point, size)
56
56
  reg.move_by!(40, 50)
57
- expect(reg.left).to eq 50
58
- expect(reg.top).to eq 70
57
+ reg.left.must_equal 50
58
+ reg.top.must_equal 70
59
59
  end
60
60
 
61
61
  it 'should work with two negative values' do
62
62
  reg = GosuEnhanced::Region.new(point, size)
63
63
  reg.move_by!(-5, -10)
64
- expect(reg.left).to eq 5
65
- expect(reg.top).to eq 10
64
+ reg.left.must_equal 5
65
+ reg.top.must_equal 10
66
66
  end
67
67
 
68
68
  it 'should work with values that result in negative co-ordinates' do
69
69
  reg = GosuEnhanced::Region.new(point, size)
70
70
  reg.move_by!(-80, -150)
71
- expect(reg.left).to eq(-70)
72
- expect(reg.top).to eq(-130)
71
+ reg.left.must_equal(-70)
72
+ reg.top.must_equal(-130)
73
73
  end
74
74
  end
75
75
 
@@ -77,25 +77,25 @@ describe GosuEnhanced::Region do
77
77
  it 'should work with a Point' do
78
78
  reg = GosuEnhanced::Region.new(point, size)
79
79
  reg.move_to!(GosuEnhanced::Point.new(30, 40))
80
- expect(reg.left).to eq 30
81
- expect(reg.top).to eq 40
80
+ reg.left.must_equal 30
81
+ reg.top.must_equal 40
82
82
 
83
- expect(point.x).to eq 10
84
- expect(point.y).to eq 20
83
+ point.x.must_equal 10
84
+ point.y.must_equal 20
85
85
  end
86
86
 
87
87
  it 'should work with two positive values' do
88
88
  reg = GosuEnhanced::Region.new(point, size)
89
89
  reg.move_to!(40, 50)
90
- expect(reg.left).to eq 40
91
- expect(reg.top).to eq 50
90
+ reg.left.must_equal 40
91
+ reg.top.must_equal 50
92
92
  end
93
93
 
94
94
  it 'should work with two negative values' do
95
95
  reg = GosuEnhanced::Region.new(point, size)
96
96
  reg.move_to!(-5, -10)
97
- expect(reg.left).to eq(-5)
98
- expect(reg.top).to eq(-10)
97
+ reg.left.must_equal(-5)
98
+ reg.top.must_equal(-10)
99
99
  end
100
100
  end
101
101
 
@@ -103,33 +103,33 @@ describe GosuEnhanced::Region do
103
103
  it 'should work with a Size' do
104
104
  reg = GosuEnhanced::Region.new(point, size)
105
105
  reg.inflate!(GosuEnhanced::Size.new(30, 40))
106
- expect(reg.width).to eq 60
107
- expect(reg.height).to eq 80
106
+ reg.width.must_equal 60
107
+ reg.height.must_equal 80
108
108
 
109
109
  # The original size should not have been changed by the inflate!
110
- expect(size.width).to eq 30
111
- expect(size.height).to eq 40
110
+ size.width.must_equal 30
111
+ size.height.must_equal 40
112
112
  end
113
113
 
114
114
  it 'should work with two values' do
115
115
  reg = GosuEnhanced::Region.new(point, size)
116
116
  reg.inflate!(40, 50)
117
- expect(reg.width).to eq 70
118
- expect(reg.height).to eq 90
117
+ reg.width.must_equal 70
118
+ reg.height.must_equal 90
119
119
  end
120
120
 
121
121
  it 'should work with negative values' do
122
122
  reg = GosuEnhanced::Region.new(point, size)
123
123
  reg.inflate!(-20, -35)
124
- expect(reg.width).to eq 10
125
- expect(reg.height).to eq 5
124
+ reg.width.must_equal 10
125
+ reg.height.must_equal 5
126
126
  end
127
127
 
128
128
  it 'should raise an error with out-of-range values' do
129
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
130
+ expect { reg.inflate!(-50, -20) }.must_raise Exception
131
+ expect { reg.inflate!(-25, -60) }.must_raise Exception
132
+ expect { reg.inflate!(-50, -70) }.must_raise Exception
133
133
  end
134
134
  end
135
135
 
@@ -137,25 +137,25 @@ describe GosuEnhanced::Region do
137
137
  it 'should work with a Size' do
138
138
  reg = GosuEnhanced::Region.new(point, size)
139
139
  reg.deflate!(GosuEnhanced::Size.new(20, 35))
140
- expect(reg.width).to eq 10
141
- expect(reg.height).to eq 5
140
+ reg.width.must_equal 10
141
+ reg.height.must_equal 5
142
142
 
143
- expect(size.width).to eq 30
144
- expect(size.height).to eq 40
143
+ size.width.must_equal 30
144
+ size.height.must_equal 40
145
145
  end
146
146
 
147
147
  it 'should work with two values' do
148
148
  reg = GosuEnhanced::Region.new(point, size)
149
149
  reg.deflate!(10, 25)
150
- expect(reg.width).to eq 20
151
- expect(reg.height).to eq 15
150
+ reg.width.must_equal 20
151
+ reg.height.must_equal 15
152
152
  end
153
153
 
154
154
  it 'should raise an error for out-of-range values' do
155
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
156
+ expect { reg.deflate!(25, 50) }.must_raise Exception
157
+ expect { reg.deflate!(60, 35) }.must_raise Exception
158
+ expect { reg.deflate!(80, 70) }.must_raise Exception
159
159
  end
160
160
  end
161
161
  end
@@ -0,0 +1,112 @@
1
+ require 'test_helper'
2
+
3
+ describe GosuEnhanced::Region do
4
+ let(:point) { GosuEnhanced::Point.new(10, 20) }
5
+ let(:size) { GosuEnhanced::Size.new(30, 40) }
6
+
7
+ describe '#initialize' do
8
+ it 'should work with a Point and a Size' do
9
+ reg = GosuEnhanced::Region.new(point, size)
10
+
11
+ reg.position.must_equal GosuEnhanced::Point.new(10, 20)
12
+ reg.size.must_equal GosuEnhanced::Size.new(30, 40)
13
+ end
14
+
15
+ it 'should work with 2 Points' do
16
+ point2 = GosuEnhanced::Point.new(40, 60)
17
+ reg = GosuEnhanced::Region.new(point, point2)
18
+
19
+ reg.position.must_equal GosuEnhanced::Point.new(10, 20)
20
+ reg.size.must_equal GosuEnhanced::Size.new(30, 40)
21
+ end
22
+
23
+ it 'should work with the utility function' do
24
+ reg = GosuEnhanced.Region(point, size)
25
+
26
+ reg.position.must_equal GosuEnhanced::Point.new(10, 20)
27
+ reg.size.must_equal GosuEnhanced::Size.new(30, 40)
28
+ end
29
+ end
30
+
31
+ describe '#position' do
32
+ it 'should return the position as a Point' do
33
+ reg = GosuEnhanced::Region.new(point, size)
34
+ reg.position.must_equal GosuEnhanced::Point.new(10, 20)
35
+ end
36
+ end
37
+
38
+ describe '#top' do
39
+ it 'should return the top co-ordinate' do
40
+ reg = GosuEnhanced::Region.new(point, size)
41
+ reg.top.must_equal 20
42
+ end
43
+ end
44
+
45
+ describe '#left' do
46
+ it 'should return the left co-ordinate' do
47
+ reg = GosuEnhanced::Region.new(point, size)
48
+ reg.left.must_equal 10
49
+ end
50
+ end
51
+
52
+ describe '#size' do
53
+ it 'should return the size as a Size' do
54
+ reg = GosuEnhanced::Region.new(point, size)
55
+ reg.size.must_equal GosuEnhanced::Size.new(30, 40)
56
+ end
57
+ end
58
+
59
+ describe '#contains?' do
60
+ it 'should work with two co-ordinates' do
61
+ reg = GosuEnhanced::Region.new(point, size)
62
+ reg.contains?(10, 20).must_equal true
63
+ reg.contains?(20, 35).must_equal true
64
+ reg.contains?(29, 59).must_equal true
65
+ reg.contains?(30, 60).must_equal false
66
+ end
67
+
68
+ it 'should work with a Point' do
69
+ reg = GosuEnhanced::Region.new(point, size)
70
+ reg.contains?(GosuEnhanced::Point.new(10, 20)).must_equal true
71
+ reg.contains?(GosuEnhanced::Point.new(20, 35)).must_equal true
72
+ reg.contains?(GosuEnhanced::Point.new(29, 59)).must_equal true
73
+ reg.contains?(GosuEnhanced::Point.new(30, 60)).must_equal false
74
+ end
75
+ end
76
+
77
+ # Unlike the Point and Size, a Region needs a dup override to actually return
78
+ # a duplicate correctly.
79
+
80
+ describe '#dup' do
81
+ it 'should duplicate a region without affecting the copied region' do
82
+ reg = GosuEnhanced::Region.new(point, size)
83
+ new_reg = reg.dup
84
+
85
+ reg.position.must_equal GosuEnhanced::Point.new(10, 20)
86
+ reg.size.must_equal GosuEnhanced::Size.new(30, 40)
87
+
88
+ new_reg.position.must_equal GosuEnhanced::Point.new(10, 20)
89
+ new_reg.size.must_equal GosuEnhanced::Size.new(30, 40)
90
+
91
+ new_reg.move_to!(20, 30)
92
+ new_reg.inflate!(10, 10)
93
+ new_reg.position.must_equal GosuEnhanced::Point.new(20, 30)
94
+ new_reg.size.must_equal GosuEnhanced::Size.new(40, 50)
95
+
96
+ reg.position.must_equal GosuEnhanced::Point.new(10, 20)
97
+ reg.size.must_equal GosuEnhanced::Size.new(30, 40)
98
+ end
99
+ end
100
+
101
+ describe '#to_s' do
102
+ it 'should render usefully' do
103
+ point = GosuEnhanced::Point.new(10, 20)
104
+ size = GosuEnhanced::Size.new(30, 40)
105
+ region = GosuEnhanced::Region.new(point, size)
106
+
107
+ region.to_s.must_equal '<GosuEnhanced::Region: ' \
108
+ '#<struct GosuEnhanced::Point x=10, y=20>' \
109
+ ', <GosuEnhanced::Size 30x40>>'
110
+ end
111
+ end
112
+ end
@@ -1,17 +1,23 @@
1
- require 'spec_helper'
1
+ require 'test_helper'
2
2
 
3
3
  describe GosuEnhanced::Size do
4
4
  describe '#initialize' do
5
5
  it 'should work with two values' do
6
6
  size = GosuEnhanced::Size.new(10, 20)
7
- expect(size.width).to eq 10
8
- expect(size.height).to eq 20
7
+ size.width.must_equal 10
8
+ size.height.must_equal 20
9
9
  end
10
10
 
11
11
  it 'should reject negative values' do
12
- expect { GosuEnhanced::Size.new(-10, 20) }.to raise_error Exception
13
- expect { GosuEnhanced::Size.new(10, -20) }.to raise_error Exception
14
- expect { GosuEnhanced::Size.new(-10, -20) }.to raise_error Exception
12
+ expect { GosuEnhanced::Size.new(-10, 20) }.must_raise Exception
13
+ expect { GosuEnhanced::Size.new(10, -20) }.must_raise Exception
14
+ expect { GosuEnhanced::Size.new(-10, -20) }.must_raise Exception
15
+ end
16
+
17
+ it 'should work with the utility function' do
18
+ size = GosuEnhanced.Size(10, 20)
19
+ size.width.must_equal 10
20
+ size.height.must_equal 20
15
21
  end
16
22
  end
17
23
 
@@ -19,29 +25,29 @@ describe GosuEnhanced::Size do
19
25
  it 'should work with another Size' do
20
26
  size = GosuEnhanced::Size.new(10, 20)
21
27
  esize = size.inflate(GosuEnhanced::Size.new(30, 40))
22
- expect(esize.width).to eq 40
23
- expect(esize.height).to eq 60
28
+ esize.width.must_equal 40
29
+ esize.height.must_equal 60
24
30
  end
25
31
 
26
32
  it 'should work with two values' do
27
33
  size = GosuEnhanced::Size.new(10, 20)
28
34
  esize = size.inflate(40, 50)
29
- expect(esize.width).to eq 50
30
- expect(esize.height).to eq 70
35
+ esize.width.must_equal 50
36
+ esize.height.must_equal 70
31
37
  end
32
38
 
33
39
  it 'should work with negative values' do
34
40
  size = GosuEnhanced::Size.new(40, 50)
35
41
  esize = size.inflate(-30, -20)
36
- expect(esize.width).to eq 10
37
- expect(esize.height).to eq 30
42
+ esize.width.must_equal 10
43
+ esize.height.must_equal 30
38
44
  end
39
45
 
40
46
  it 'should raise an error with out-of-range values' do
41
47
  size = GosuEnhanced::Size.new(40, 50)
42
- expect { size.inflate(-50, -20) }.to raise_error Exception
43
- expect { size.inflate(-30, -60) }.to raise_error Exception
44
- expect { size.inflate(-50, -70) }.to raise_error Exception
48
+ expect { size.inflate(-50, -20) }.must_raise Exception
49
+ expect { size.inflate(-30, -60) }.must_raise Exception
50
+ expect { size.inflate(-50, -70) }.must_raise Exception
45
51
  end
46
52
  end
47
53
 
@@ -49,22 +55,22 @@ describe GosuEnhanced::Size do
49
55
  it 'should work with another Size' do
50
56
  size = GosuEnhanced::Size.new(60, 80)
51
57
  esize = size.deflate(GosuEnhanced::Size.new(30, 40))
52
- expect(esize.width).to eq 30
53
- expect(esize.height).to eq 40
58
+ esize.width.must_equal 30
59
+ esize.height.must_equal 40
54
60
  end
55
61
 
56
62
  it 'should work with two values' do
57
63
  size = GosuEnhanced::Size.new(70, 60)
58
64
  esize = size.deflate(40, 50)
59
- expect(esize.width).to eq 30
60
- expect(esize.height).to eq 10
65
+ esize.width.must_equal 30
66
+ esize.height.must_equal 10
61
67
  end
62
68
 
63
69
  it 'should raise an error for out-of-range values' do
64
70
  size = GosuEnhanced::Size.new(70, 60)
65
- expect { size.deflate(80, 50) }.to raise_error Exception
66
- expect { size.deflate(60, 70) }.to raise_error Exception
67
- expect { size.deflate(80, 70) }.to raise_error Exception
71
+ expect { size.deflate(80, 50) }.must_raise Exception
72
+ expect { size.deflate(60, 70) }.must_raise Exception
73
+ expect { size.deflate(80, 70) }.must_raise Exception
68
74
  end
69
75
  end
70
76
 
@@ -72,29 +78,29 @@ describe GosuEnhanced::Size do
72
78
  it 'should work with another Size' do
73
79
  size = GosuEnhanced::Size.new(10, 20)
74
80
  size.inflate!(GosuEnhanced::Size.new(30, 40))
75
- expect(size.width).to eq 40
76
- expect(size.height).to eq 60
81
+ size.width.must_equal 40
82
+ size.height.must_equal 60
77
83
  end
78
84
 
79
85
  it 'should work with two values' do
80
86
  size = GosuEnhanced::Size.new(10, 20)
81
87
  size.inflate!(40, 50)
82
- expect(size.width).to eq 50
83
- expect(size.height).to eq 70
88
+ size.width.must_equal 50
89
+ size.height.must_equal 70
84
90
  end
85
91
 
86
92
  it 'should work with negative values' do
87
93
  size = GosuEnhanced::Size.new(40, 50)
88
94
  size.inflate!(-30, -20)
89
- expect(size.width).to eq 10
90
- expect(size.height).to eq 30
95
+ size.width.must_equal 10
96
+ size.height.must_equal 30
91
97
  end
92
98
 
93
99
  it 'should raise an error with out-of-range values' do
94
100
  size = GosuEnhanced::Size.new(40, 50)
95
- expect { size.inflate!(-50, -20) }.to raise_error Exception
96
- expect { size.inflate!(-30, -60) }.to raise_error Exception
97
- expect { size.inflate!(-50, -70) }.to raise_error Exception
101
+ expect { size.inflate!(-50, -20) }.must_raise Exception
102
+ expect { size.inflate!(-30, -60) }.must_raise Exception
103
+ expect { size.inflate!(-50, -70) }.must_raise Exception
98
104
  end
99
105
  end
100
106
 
@@ -102,22 +108,22 @@ describe GosuEnhanced::Size do
102
108
  it 'should work with another Size' do
103
109
  size = GosuEnhanced::Size.new(60, 80)
104
110
  size.deflate!(GosuEnhanced::Size.new(30, 40))
105
- expect(size.width).to eq 30
106
- expect(size.height).to eq 40
111
+ size.width.must_equal 30
112
+ size.height.must_equal 40
107
113
  end
108
114
 
109
115
  it 'should work with two values' do
110
116
  size = GosuEnhanced::Size.new(70, 60)
111
117
  size.deflate!(40, 50)
112
- expect(size.width).to eq 30
113
- expect(size.height).to eq 10
118
+ size.width.must_equal 30
119
+ size.height.must_equal 10
114
120
  end
115
121
 
116
122
  it 'should raise an error for out-of-range values' do
117
123
  size = GosuEnhanced::Size.new(70, 60)
118
- expect { size.deflate!(80, 50) }.to raise_error Exception
119
- expect { size.deflate!(60, 70) }.to raise_error Exception
120
- expect { size.deflate!(80, 70) }.to raise_error Exception
124
+ expect { size.deflate!(80, 50) }.must_raise Exception
125
+ expect { size.deflate!(60, 70) }.must_raise Exception
126
+ expect { size.deflate!(80, 70) }.must_raise Exception
121
127
  end
122
128
  end
123
129
 
@@ -126,25 +132,25 @@ describe GosuEnhanced::Size do
126
132
  size = GosuEnhanced::Size.new(10, 20)
127
133
  nsize = size.dup
128
134
 
129
- expect(size.width).to eq 10
130
- expect(size.height).to eq 20
135
+ size.width.must_equal 10
136
+ size.height.must_equal 20
131
137
 
132
- expect(nsize.width).to eq 10
133
- expect(nsize.height).to eq 20
138
+ nsize.width.must_equal 10
139
+ nsize.height.must_equal 20
134
140
 
135
141
  nsize.inflate!(40, 50)
136
- expect(nsize.width).to eq 50
137
- expect(nsize.height).to eq 70
142
+ nsize.width.must_equal 50
143
+ nsize.height.must_equal 70
138
144
 
139
- expect(size.width).to eq 10
140
- expect(size.height).to eq 20
145
+ size.width.must_equal 10
146
+ size.height.must_equal 20
141
147
  end
142
148
  end
143
149
 
144
150
  describe '#to_s' do
145
151
  it 'should render usefully' do
146
152
  size = GosuEnhanced::Size.new(10, 20)
147
- expect(size.to_s).to eq '<GosuEnhanced::Size 10x20>'
153
+ size.to_s.must_equal '<GosuEnhanced::Size 10x20>'
148
154
  end
149
155
  end
150
156
  end
@@ -0,0 +1,4 @@
1
+ require 'minitest/autorun'
2
+ require 'minitest/pride'
3
+
4
+ require 'gosu_enhanced'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gosu_enhanced
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julian Nicholls
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-07 00:00:00.000000000 Z
11
+ date: 2015-09-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gosu
@@ -53,47 +53,19 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '10.0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: rspec
56
+ name: minitest
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '3.0'
61
+ version: '5.8'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '3.0'
69
- - !ruby/object:Gem::Dependency
70
- name: rspec-nc
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: '0.2'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: '0.2'
83
- - !ruby/object:Gem::Dependency
84
- name: pry
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: '0.10'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - "~>"
95
- - !ruby/object:Gem::Version
96
- version: '0.10'
68
+ version: '5.8'
97
69
  description: |-
98
70
  Point, Size, and Region classes to hold pixel co-ordinatess
99
71
  and rectangle sizes respectively.
@@ -119,11 +91,11 @@ files:
119
91
  - lib/gosu_enhanced/region.rb
120
92
  - lib/gosu_enhanced/size.rb
121
93
  - lib/gosu_enhanced/version.rb
122
- - spec/point_spec.rb
123
- - spec/region_delegation_spec.rb
124
- - spec/region_spec.rb
125
- - spec/size_spec.rb
126
- - spec/spec_helper.rb
94
+ - test/point_test.rb
95
+ - test/region_delegation_test.rb
96
+ - test/region_test.rb
97
+ - test/size_test.rb
98
+ - test/test_helper.rb
127
99
  homepage: https://github.com/JulianNicholls/gosu_enhanced-gem
128
100
  licenses:
129
101
  - MIT
@@ -144,13 +116,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
144
116
  version: '0'
145
117
  requirements: []
146
118
  rubyforge_project:
147
- rubygems_version: 2.4.7
119
+ rubygems_version: 2.4.5.1
148
120
  signing_key:
149
121
  specification_version: 4
150
122
  summary: Enhanced versions of some Gosu classes.
151
123
  test_files:
152
- - spec/point_spec.rb
153
- - spec/region_delegation_spec.rb
154
- - spec/region_spec.rb
155
- - spec/size_spec.rb
156
- - spec/spec_helper.rb
124
+ - test/point_test.rb
125
+ - test/region_delegation_test.rb
126
+ - test/region_test.rb
127
+ - test/size_test.rb
128
+ - test/test_helper.rb
@@ -1,94 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe GosuEnhanced::Region do
4
- let(:point) { GosuEnhanced::Point.new(10, 20) }
5
- let(:size) { GosuEnhanced::Size.new(30, 40) }
6
-
7
- describe '#initialize' do
8
- it 'should work with a Point and a Size' do
9
- GosuEnhanced::Region.new(point, size)
10
- end
11
- end
12
-
13
- describe '#position' do
14
- it 'should return the position as a Point' do
15
- reg = GosuEnhanced::Region.new(point, size)
16
- expect(reg.position).to eq GosuEnhanced::Point.new(10, 20)
17
- end
18
- end
19
-
20
- describe '#top' do
21
- it 'should return the top co-ordinate' do
22
- reg = GosuEnhanced::Region.new(point, size)
23
- expect(reg.top).to eq 20
24
- end
25
- end
26
-
27
- describe '#left' do
28
- it 'should return the left co-ordinate' do
29
- reg = GosuEnhanced::Region.new(point, size)
30
- expect(reg.left).to eq 10
31
- end
32
- end
33
-
34
- describe '#size' do
35
- it 'should return the size as a Size' do
36
- reg = GosuEnhanced::Region.new(point, size)
37
- expect(reg.size).to eq GosuEnhanced::Size.new(30, 40)
38
- end
39
- end
40
-
41
- describe '#contains?' do
42
- it 'should work with two co-ordinates' do
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
- end
49
-
50
- it 'should work with a Point' do
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
- end
57
- end
58
-
59
- # Unlike the Point and Size, a Region needs a dup override to actually return
60
- # a duplicate correctly.
61
-
62
- describe '#dup' do
63
- it 'should duplicate a region' do
64
- reg = GosuEnhanced::Region.new(point, size)
65
- new_reg = reg.dup
66
-
67
- expect(reg.position).to eq GosuEnhanced::Point.new(10, 20)
68
- expect(reg.size).to eq GosuEnhanced::Size.new(30, 40)
69
-
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
-
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
-
78
- expect(reg.position).to eq GosuEnhanced::Point.new(10, 20)
79
- expect(reg.size).to eq GosuEnhanced::Size.new(30, 40)
80
- end
81
- end
82
-
83
- describe '#to_s' do
84
- it 'should render usefully' do
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>>'
92
- end
93
- end
94
- end
@@ -1,3 +0,0 @@
1
- require 'rspec'
2
- require 'pry'
3
- require 'gosu_enhanced'