chunky_png 1.3.2 → 1.3.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,18 +1,18 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe ChunkyPNG::Canvas do
4
-
4
+
5
5
  describe '#to_rgba_stream' do
6
6
  it "should export a sample canvas to an RGBA stream correctly" do
7
7
  canvas = ChunkyPNG::Canvas.new(2, 2, [ChunkyPNG::Color.rgba(1,2,3,4), ChunkyPNG::Color.rgba(5,6,7,8),
8
8
  ChunkyPNG::Color.rgba(4,3,2,1), ChunkyPNG::Color.rgba(8,7,6,5)])
9
9
 
10
- canvas.to_rgba_stream.should == [1,2,3,4,5,6,7,8,4,3,2,1,8,7,6,5].pack('C16')
10
+ expect(canvas.to_rgba_stream).to eql [1,2,3,4,5,6,7,8,4,3,2,1,8,7,6,5].pack('C16')
11
11
  end
12
-
12
+
13
13
  it "should export an image to an RGBA datastream correctly" do
14
- reference_canvas('pixelstream_reference').to_rgba_stream.should == resource_data('pixelstream.rgba')
15
- end
14
+ expect(reference_canvas('pixelstream_reference').to_rgba_stream).to eql resource_data('pixelstream.rgba')
15
+ end
16
16
  end
17
17
 
18
18
  describe '#to_rgb_stream' do
@@ -20,40 +20,40 @@ describe ChunkyPNG::Canvas do
20
20
  canvas = ChunkyPNG::Canvas.new(2, 2, [ChunkyPNG::Color.rgba(1,2,3,4), ChunkyPNG::Color.rgba(5,6,7,8),
21
21
  ChunkyPNG::Color.rgba(4,3,2,1), ChunkyPNG::Color.rgba(8,7,6,5)])
22
22
 
23
- canvas.to_rgb_stream.should == [1,2,3,5,6,7,4,3,2,8,7,6].pack('C12')
24
- end
25
-
23
+ expect(canvas.to_rgb_stream).to eql [1,2,3,5,6,7,4,3,2,8,7,6].pack('C12')
24
+ end
25
+
26
26
  it "should export an image to an RGB datastream correctly" do
27
- reference_canvas('pixelstream_reference').to_rgb_stream.should == resource_data('pixelstream.rgb')
27
+ expect(reference_canvas('pixelstream_reference').to_rgb_stream).to eql resource_data('pixelstream.rgb')
28
28
  end
29
29
  end
30
-
30
+
31
31
  describe '#to_grayscale_stream' do
32
-
32
+
33
33
  it "should export a grayscale image to a grayscale datastream correctly" do
34
34
  canvas = ChunkyPNG::Canvas.new(2, 2, [ChunkyPNG::Color.grayscale(1), ChunkyPNG::Color.grayscale(2),
35
35
  ChunkyPNG::Color.grayscale(3), ChunkyPNG::Color.grayscale(4)])
36
- canvas.to_grayscale_stream.should == [1,2,3,4].pack('C4')
37
- end
36
+ expect(canvas.to_grayscale_stream).to eql [1,2,3,4].pack('C4')
37
+ end
38
+
38
39
 
39
-
40
40
  it "should export a color image to a grayscale datastream, using B values" do
41
41
  canvas = ChunkyPNG::Canvas.new(2, 2, [ChunkyPNG::Color.rgba(1,2,3,4), ChunkyPNG::Color.rgba(5,6,7,8),
42
42
  ChunkyPNG::Color.rgba(4,3,2,1), ChunkyPNG::Color.rgba(8,7,6,5)])
43
- canvas.to_grayscale_stream.should == [3,7,2,6].pack('C4')
44
- end
43
+ expect(canvas.to_grayscale_stream).to eql [3,7,2,6].pack('C4')
44
+ end
45
45
  end
46
-
46
+
47
47
  describe '#to_alpha_channel_stream' do
48
48
  it "should export an opaque image to an alpha channel datastream correctly" do
49
49
  grayscale_array = Array.new(reference_canvas('pixelstream_reference').pixels.length, 255)
50
- reference_canvas('pixelstream_reference').to_alpha_channel_stream.should == grayscale_array.pack('C*')
50
+ expect(reference_canvas('pixelstream_reference').to_alpha_channel_stream).to eql grayscale_array.pack('C*')
51
51
  end
52
-
52
+
53
53
  it "should export a transparent image to an alpha channel datastream correctly" do
54
54
  canvas = ChunkyPNG::Canvas.new(2, 2, [ChunkyPNG::Color.rgba(1,2,3,4), ChunkyPNG::Color.rgba(5,6,7,8),
55
55
  ChunkyPNG::Color.rgba(4,3,2,1), ChunkyPNG::Color.rgba(8,7,6,5)])
56
- canvas.to_alpha_channel_stream.should == [4,8,1,5].pack('C4')
56
+ expect(canvas.to_alpha_channel_stream).to eql [4,8,1,5].pack('C4')
57
57
  end
58
58
  end
59
59
  end
@@ -6,7 +6,7 @@ describe ChunkyPNG::Canvas do
6
6
  it "should load an image correctly from a datastream" do
7
7
  File.open(resource_file('pixelstream.rgb')) do |stream|
8
8
  matrix = ChunkyPNG::Canvas.from_rgb_stream(240, 180, stream)
9
- matrix.should == reference_canvas('pixelstream_reference')
9
+ expect(matrix).to eql reference_canvas('pixelstream_reference')
10
10
  end
11
11
  end
12
12
  end
@@ -15,7 +15,7 @@ describe ChunkyPNG::Canvas do
15
15
  it "should load an image correctly from a datastream" do
16
16
  File.open(resource_file('pixelstream.bgr')) do |stream|
17
17
  matrix = ChunkyPNG::Canvas.from_bgr_stream(240, 180, stream)
18
- matrix.should == reference_canvas('pixelstream_reference')
18
+ expect(matrix).to eql reference_canvas('pixelstream_reference')
19
19
  end
20
20
  end
21
21
  end
@@ -24,7 +24,7 @@ describe ChunkyPNG::Canvas do
24
24
  it "should load an image correctly from a datastream" do
25
25
  File.open(resource_file('pixelstream.rgba')) do |stream|
26
26
  matrix = ChunkyPNG::Canvas.from_rgba_stream(240, 180, stream)
27
- matrix.should == reference_canvas('pixelstream_reference')
27
+ expect(matrix).to eql reference_canvas('pixelstream_reference')
28
28
  end
29
29
  end
30
30
  end
@@ -11,216 +11,219 @@ describe ChunkyPNG::Canvas do
11
11
  describe '#initialize' do
12
12
  it "should accept a single color value as background color" do
13
13
  canvas = ChunkyPNG::Canvas.new(2, 2, 'red @ 0.8')
14
- canvas[1, 0].should == ChunkyPNG::Color.parse('red @ 0.8')
14
+ expect(canvas[1, 0]).to eql ChunkyPNG::Color.parse('red @ 0.8')
15
15
  end
16
-
16
+
17
17
  it "should raise an error if the color value is not understood" do
18
- lambda { ChunkyPNG::Canvas.new(2, 2, :nonsense) }.should raise_error(ArgumentError)
18
+ expect { ChunkyPNG::Canvas.new(2, 2, :nonsense) }.to raise_error(ArgumentError)
19
19
  end
20
-
20
+
21
21
  it "should accept an array as initial pixel values" do
22
22
  canvas = ChunkyPNG::Canvas.new(2, 2, [1,2,3,4])
23
- canvas[0, 0].should == 1
24
- canvas[1, 0].should == 2
25
- canvas[0, 1].should == 3
26
- canvas[1, 1].should == 4
23
+ expect(canvas[0, 0]).to eql 1
24
+ expect(canvas[1, 0]).to eql 2
25
+ expect(canvas[0, 1]).to eql 3
26
+ expect(canvas[1, 1]).to eql 4
27
27
  end
28
-
28
+
29
29
  it "should raise an ArgumentError if the initial array does not have the correct number of elements" do
30
- lambda { ChunkyPNG::Canvas.new(2, 2, [1,2,3]) }.should raise_error(ArgumentError)
31
- lambda { ChunkyPNG::Canvas.new(2, 2, [1,2,3,4,5]) }.should raise_error(ArgumentError)
30
+ expect { ChunkyPNG::Canvas.new(2, 2, [1,2,3]) }.to raise_error(ArgumentError)
31
+ expect { ChunkyPNG::Canvas.new(2, 2, [1,2,3,4,5]) }.to raise_error(ArgumentError)
32
32
  end
33
-
33
+
34
34
  it "should use a transparent background by default" do
35
35
  canvas = ChunkyPNG::Canvas.new(1, 1)
36
- canvas[0,0].should == ChunkyPNG::Color::TRANSPARENT
36
+ expect(canvas[0,0]).to eql ChunkyPNG::Color::TRANSPARENT
37
37
  end
38
38
  end
39
39
 
40
40
  describe '#dimension' do
41
41
  it "should return the dimensions as a Dimension instance" do
42
- subject.dimension.should == ChunkyPNG::Dimension('1x1')
42
+ expect(subject.dimension).to eql ChunkyPNG::Dimension('1x1')
43
43
  end
44
44
  end
45
-
45
+
46
46
  describe '#area' do
47
47
  it "should return the dimensions as two-item array" do
48
- subject.area.should == ChunkyPNG::Dimension('1x1').area
48
+ expect(subject.area).to eql ChunkyPNG::Dimension('1x1').area
49
49
  end
50
50
  end
51
51
 
52
52
  describe '#include?' do
53
53
  it "should return true if the coordinates are within bounds, false otherwise" do
54
- subject.include_xy?( 0, 0).should be_true
55
-
56
- subject.include_xy?(-1, 0).should be_false
57
- subject.include_xy?( 1, 0).should be_false
58
- subject.include_xy?( 0, -1).should be_false
59
- subject.include_xy?( 0, 1).should be_false
60
- subject.include_xy?(-1, -1).should be_false
61
- subject.include_xy?(-1, 1).should be_false
62
- subject.include_xy?( 1, -1).should be_false
63
- subject.include_xy?( 1, 1).should be_false
64
- end
65
-
54
+ expect(subject.include_xy?( 0, 0)).to eql true
55
+
56
+ expect(subject.include_xy?(-1, 0)).to eql false
57
+ expect(subject.include_xy?( 1, 0)).to eql false
58
+ expect(subject.include_xy?( 0, -1)).to eql false
59
+ expect(subject.include_xy?( 0, 1)).to eql false
60
+ expect(subject.include_xy?(-1, -1)).to eql false
61
+ expect(subject.include_xy?(-1, 1)).to eql false
62
+ expect(subject.include_xy?( 1, -1)).to eql false
63
+ expect(subject.include_xy?( 1, 1)).to eql false
64
+ end
65
+
66
66
  it "should accept strings, arrays, hashes and points as well" do
67
- subject.should include('0, 0')
67
+ expect(subject).to include('0, 0')
68
68
  subject.should_not include('0, 1')
69
- subject.should include([0, 0])
69
+ expect(subject).to include([0, 0])
70
70
  subject.should_not include([0, 1])
71
- subject.should include(:y => 0, :x => 0)
71
+ expect(subject).to include(:y => 0, :x => 0)
72
72
  subject.should_not include(:y => 1, :x => 0)
73
- subject.should include(ChunkyPNG::Point.new(0, 0))
73
+ expect(subject).to include(ChunkyPNG::Point.new(0, 0))
74
74
  subject.should_not include(ChunkyPNG::Point.new(0, 1))
75
75
  end
76
76
  end
77
-
77
+
78
78
  describe '#include_x?' do
79
79
  it "should return true if the x-coordinate is within bounds, false otherwise" do
80
- subject.include_x?( 0).should be_true
81
- subject.include_x?(-1).should be_false
82
- subject.include_x?( 1).should be_false
80
+ expect(subject.include_x?( 0)).to eql true
81
+ expect(subject.include_x?(-1)).to eql false
82
+ expect(subject.include_x?( 1)).to eql false
83
83
  end
84
84
  end
85
-
85
+
86
86
  describe '#include_y?' do
87
87
  it "should return true if the y-coordinate is within bounds, false otherwise" do
88
- subject.include_y?( 0).should be_true
89
- subject.include_y?(-1).should be_false
90
- subject.include_y?( 1).should be_false
88
+ expect(subject.include_y?( 0)).to eql true
89
+ expect(subject.include_y?(-1)).to eql false
90
+ expect(subject.include_y?( 1)).to eql false
91
91
  end
92
92
  end
93
-
93
+
94
94
  describe '#assert_xy!' do
95
95
  it "should not raise an exception if the coordinates are within bounds" do
96
- subject.should_receive(:include_xy?).with(0, 0).and_return(true)
97
- lambda { subject.send(:assert_xy!, 0, 0) }.should_not raise_error
96
+ expect(subject).to receive(:include_xy?).with(0, 0).and_return(true)
97
+ expect { subject.send(:assert_xy!, 0, 0) }.to_not raise_error
98
98
  end
99
-
99
+
100
100
  it "should raise an exception if the coordinates are out of bounds bounds" do
101
- subject.should_receive(:include_xy?).with(0, -1).and_return(false)
102
- lambda { subject.send(:assert_xy!, 0, -1) }.should raise_error(ChunkyPNG::OutOfBounds)
101
+ expect(subject).to receive(:include_xy?).with(0, -1).and_return(false)
102
+ expect { subject.send(:assert_xy!, 0, -1) }.to raise_error(ChunkyPNG::OutOfBounds)
103
103
  end
104
104
  end
105
-
105
+
106
106
  describe '#assert_x!' do
107
107
  it "should not raise an exception if the x-coordinate is within bounds" do
108
- subject.should_receive(:include_x?).with(0).and_return(true)
109
- lambda { subject.send(:assert_x!, 0) }.should_not raise_error
108
+ expect(subject).to receive(:include_x?).with(0).and_return(true)
109
+ expect { subject.send(:assert_x!, 0) }.to_not raise_error
110
110
  end
111
-
111
+
112
112
  it "should raise an exception if the x-coordinate is out of bounds bounds" do
113
- subject.should_receive(:include_y?).with(-1).and_return(false)
114
- lambda { subject.send(:assert_y!, -1) }.should raise_error(ChunkyPNG::OutOfBounds)
113
+ expect(subject).to receive(:include_y?).with(-1).and_return(false)
114
+ expect { subject.send(:assert_y!, -1) }.to raise_error(ChunkyPNG::OutOfBounds)
115
115
  end
116
116
  end
117
-
117
+
118
118
  describe '#[]' do
119
119
  it "should return the pixel value if the coordinates are within bounds" do
120
- subject[0, 0].should == ChunkyPNG::Color::WHITE
120
+ expect(subject[0, 0]).to eql ChunkyPNG::Color::WHITE
121
121
  end
122
-
122
+
123
123
  it "should assert the coordinates to be within bounds" do
124
- subject.should_receive(:assert_xy!).with(0, 0)
124
+ expect(subject).to receive(:assert_xy!).with(0, 0)
125
125
  subject[0, 0]
126
126
  end
127
127
  end
128
-
128
+
129
129
  describe '#get_pixel' do
130
130
  it "should return the pixel value if the coordinates are within bounds" do
131
- subject.get_pixel(0, 0).should == ChunkyPNG::Color::WHITE
131
+ expect(subject.get_pixel(0, 0)).to eql ChunkyPNG::Color::WHITE
132
132
  end
133
-
133
+
134
134
  it "should not assert nor check the coordinates" do
135
- subject.should_not_receive(:assert_xy!)
136
- subject.should_not_receive(:include_xy?)
135
+ expect(subject).to_not receive(:assert_xy!)
136
+ expect(subject).to_not receive(:include_xy?)
137
137
  subject.get_pixel(0, 0)
138
138
  end
139
139
  end
140
-
140
+
141
141
  describe '#[]=' do
142
142
  it "should change the pixel's color value" do
143
- lambda { subject[0, 0] = ChunkyPNG::Color::BLACK }.should change { subject[0, 0] }.from(ChunkyPNG::Color::WHITE).to(ChunkyPNG::Color::BLACK)
143
+ expect { subject[0, 0] = ChunkyPNG::Color::BLACK }.to change { subject[0, 0] }.
144
+ from(ChunkyPNG::Color::WHITE).to(ChunkyPNG::Color::BLACK)
144
145
  end
145
-
146
+
146
147
  it "should assert the bounds of the image" do
147
- subject.should_receive(:assert_xy!).with(0, 0)
148
+ expect(subject).to receive(:assert_xy!).with(0, 0)
148
149
  subject[0, 0] = ChunkyPNG::Color::BLACK
149
150
  end
150
151
  end
151
-
152
+
152
153
  describe 'set_pixel' do
153
154
  it "should change the pixel's color value" do
154
- lambda { subject.set_pixel(0, 0, ChunkyPNG::Color::BLACK) }.should change { subject[0, 0] }.from(ChunkyPNG::Color::WHITE).to(ChunkyPNG::Color::BLACK)
155
+ expect { subject.set_pixel(0, 0, ChunkyPNG::Color::BLACK) }.to change { subject[0, 0] }.
156
+ from(ChunkyPNG::Color::WHITE).to(ChunkyPNG::Color::BLACK)
155
157
  end
156
-
158
+
157
159
  it "should not assert or check the bounds of the image" do
158
- subject.should_not_receive(:assert_xy!)
159
- subject.should_not_receive(:include_xy?)
160
+ expect(subject).to_not receive(:assert_xy!)
161
+ expect(subject).to_not receive(:include_xy?)
160
162
  subject.set_pixel(0, 0, ChunkyPNG::Color::BLACK)
161
163
  end
162
164
  end
163
-
165
+
164
166
  describe '#set_pixel_if_within_bounds' do
165
167
  it "should change the pixel's color value" do
166
- lambda { subject.set_pixel_if_within_bounds(0, 0, ChunkyPNG::Color::BLACK) }.should change { subject[0, 0] }.from(ChunkyPNG::Color::WHITE).to(ChunkyPNG::Color::BLACK)
168
+ expect { subject.set_pixel_if_within_bounds(0, 0, ChunkyPNG::Color::BLACK) }.to change { subject[0, 0] }.
169
+ from(ChunkyPNG::Color::WHITE).to(ChunkyPNG::Color::BLACK)
167
170
  end
168
171
 
169
172
  it "should not assert, but only check the coordinates" do
170
- subject.should_not_receive(:assert_xy!)
171
- subject.should_receive(:include_xy?).with(0, 0)
173
+ expect(subject).to_not receive(:assert_xy!)
174
+ expect(subject).to receive(:include_xy?).with(0, 0)
172
175
  subject.set_pixel_if_within_bounds(0, 0, ChunkyPNG::Color::BLACK)
173
176
  end
174
177
 
175
178
  it "should do nothing if the coordinates are out of bounds" do
176
- subject.set_pixel_if_within_bounds(-1, 1, ChunkyPNG::Color::BLACK).should be_nil
177
- subject[0, 0].should == ChunkyPNG::Color::WHITE
179
+ expect(subject.set_pixel_if_within_bounds(-1, 1, ChunkyPNG::Color::BLACK)).to be_nil
180
+ expect(subject[0, 0]).to eql ChunkyPNG::Color::WHITE
178
181
  end
179
182
  end
180
-
183
+
181
184
  describe '#row' do
182
185
  before { @canvas = reference_canvas('operations') }
183
186
 
184
187
  it "should give an out of bounds exception when y-coordinate is out of bounds" do
185
- lambda { @canvas.row(-1) }.should raise_error(ChunkyPNG::OutOfBounds)
186
- lambda { @canvas.row(16) }.should raise_error(ChunkyPNG::OutOfBounds)
188
+ expect { @canvas.row(-1) }.to raise_error(ChunkyPNG::OutOfBounds)
189
+ expect { @canvas.row(16) }.to raise_error(ChunkyPNG::OutOfBounds)
187
190
  end
188
191
 
189
192
  it "should return the correct pixels" do
190
193
  data = @canvas.row(0)
191
- data.should have(@canvas.width).items
192
- data.should == [65535, 268500991, 536936447, 805371903, 1073807359, 1342242815, 1610678271, 1879113727, 2147549183, 2415984639, 2684420095, 2952855551, 3221291007, 3489726463, 3758161919, 4026597375]
194
+ expect(data.length).to eql @canvas.width
195
+ expect(data).to eql [65535, 268500991, 536936447, 805371903, 1073807359, 1342242815, 1610678271, 1879113727, 2147549183, 2415984639, 2684420095, 2952855551, 3221291007, 3489726463, 3758161919, 4026597375]
193
196
  end
194
197
  end
195
-
198
+
196
199
  describe '#column' do
197
200
  before { @canvas = reference_canvas('operations') }
198
201
 
199
202
  it "should give an out of bounds exception when x-coordinate is out of bounds" do
200
- lambda { @canvas.column(-1) }.should raise_error(ChunkyPNG::OutOfBounds)
201
- lambda { @canvas.column(16) }.should raise_error(ChunkyPNG::OutOfBounds)
203
+ expect { @canvas.column(-1) }.to raise_error(ChunkyPNG::OutOfBounds)
204
+ expect { @canvas.column(16) }.to raise_error(ChunkyPNG::OutOfBounds)
202
205
  end
203
206
 
204
207
  it "should return the correct pixels" do
205
208
  data = @canvas.column(0)
206
- data.should have(@canvas.height).items
207
- data.should == [65535, 1114111, 2162687, 3211263, 4259839, 5308415, 6356991, 7405567, 8454143, 9502719, 10551295, 11599871, 12648447, 13697023, 14745599, 15794175]
209
+ expect(data.length).to eql @canvas.height
210
+ expect(data).to eql [65535, 1114111, 2162687, 3211263, 4259839, 5308415, 6356991, 7405567, 8454143, 9502719, 10551295, 11599871, 12648447, 13697023, 14745599, 15794175]
208
211
  end
209
212
  end
210
-
213
+
211
214
  describe '#replace_canvas' do
212
215
  it "should change the dimension of the canvas" do
213
- lambda { subject.send(:replace_canvas!, 2, 2, [1,2,3,4]) }.should change(subject, :dimension).
216
+ expect { subject.send(:replace_canvas!, 2, 2, [1,2,3,4]) }.to change { subject.dimension }.
214
217
  from(ChunkyPNG::Dimension('1x1')).to(ChunkyPNG::Dimension('2x2'))
215
218
  end
216
-
219
+
217
220
  it "should change the pixel array" do
218
- lambda { subject.send(:replace_canvas!, 2, 2, [1,2,3,4]) }.should change(subject, :pixels).
221
+ expect { subject.send(:replace_canvas!, 2, 2, [1,2,3,4]) }.to change { subject.pixels }.
219
222
  from([ChunkyPNG::Color('white')]).to([1,2,3,4])
220
223
  end
221
-
224
+
222
225
  it "should return itself" do
223
- subject.send(:replace_canvas!, 2, 2, [1,2,3,4]).should equal(subject)
226
+ expect(subject.send(:replace_canvas!, 2, 2, [1,2,3,4])).to equal(subject)
224
227
  end
225
228
  end
226
229
  end
@@ -2,20 +2,20 @@ require 'spec_helper'
2
2
 
3
3
  describe 'ChunyPNG.Color' do
4
4
  it 'should interpret 4 arguments as RGBA values' do
5
- ChunkyPNG::Color(1, 2, 3, 4).should == ChunkyPNG::Color.rgba(1, 2, 3, 4)
5
+ expect(ChunkyPNG::Color(1, 2, 3, 4)).to eql ChunkyPNG::Color.rgba(1, 2, 3, 4)
6
6
  end
7
7
 
8
8
  it 'should interpret 3 arguments as RGBA values' do
9
- ChunkyPNG::Color(1, 2, 3).should == ChunkyPNG::Color.rgb(1, 2, 3)
9
+ expect(ChunkyPNG::Color(1, 2, 3)).to eql ChunkyPNG::Color.rgb(1, 2, 3)
10
10
  end
11
11
 
12
12
  it 'should interpret 2 arguments as a color to parse and an opacity value' do
13
- ChunkyPNG::Color('0x0a649664', 0xaa).should == 0x0a6496aa
14
- ChunkyPNG::Color('spring green @ 0.6666', 0xff).should == 0x00ff7fff
13
+ expect(ChunkyPNG::Color('0x0a649664', 0xaa)).to eql 0x0a6496aa
14
+ expect(ChunkyPNG::Color('spring green @ 0.6666', 0xff)).to eql 0x00ff7fff
15
15
  end
16
16
 
17
17
  it 'should interpret 1 argument as a color to parse' do
18
- ChunkyPNG::Color.should_receive(:parse).with('0x0a649664')
18
+ expect(ChunkyPNG::Color).to receive(:parse).with('0x0a649664')
19
19
  ChunkyPNG::Color('0x0a649664')
20
20
  end
21
21
  end
@@ -36,128 +36,128 @@ describe ChunkyPNG::Color do
36
36
 
37
37
  describe '#parse' do
38
38
  it 'should interpret a hex string correctly' do
39
- parse('0x0a649664').should == ChunkyPNG::Color.from_hex('#0a649664')
39
+ expect(parse('0x0a649664')).to eql ChunkyPNG::Color.from_hex('#0a649664')
40
40
  end
41
41
 
42
42
  it 'should interpret a color name correctly' do
43
- parse(:spring_green).should == 0x00ff7fff
44
- parse('spring green').should == 0x00ff7fff
45
- parse('spring green @ 0.6666').should == 0x00ff7faa
43
+ expect(parse(:spring_green)).to eql 0x00ff7fff
44
+ expect(parse('spring green')).to eql 0x00ff7fff
45
+ expect(parse('spring green @ 0.6666')).to eql 0x00ff7faa
46
46
  end
47
47
 
48
48
  it 'should return numbers as is' do
49
- parse('12345').should == 12345
50
- parse(12345).should == 12345
49
+ expect(parse('12345')).to eql 12345
50
+ expect(parse(12345)).to eql 12345
51
51
  end
52
52
  end
53
53
 
54
54
  describe '#pixel_bytesize' do
55
55
  it 'should return the normal amount of bytes with a bit depth of 8' do
56
- pixel_bytesize(ChunkyPNG::COLOR_TRUECOLOR, 8).should == 3
56
+ expect(pixel_bytesize(ChunkyPNG::COLOR_TRUECOLOR, 8)).to eql 3
57
57
  end
58
58
 
59
59
  it 'should return a multiple of the normal amount of bytes with a bit depth greater than 8' do
60
- pixel_bytesize(ChunkyPNG::COLOR_TRUECOLOR, 16).should == 6
61
- pixel_bytesize(ChunkyPNG::COLOR_TRUECOLOR_ALPHA, 16).should == 8
62
- pixel_bytesize(ChunkyPNG::COLOR_GRAYSCALE_ALPHA, 16).should == 4
60
+ expect(pixel_bytesize(ChunkyPNG::COLOR_TRUECOLOR, 16)).to eql 6
61
+ expect(pixel_bytesize(ChunkyPNG::COLOR_TRUECOLOR_ALPHA, 16)).to eql 8
62
+ expect(pixel_bytesize(ChunkyPNG::COLOR_GRAYSCALE_ALPHA, 16)).to eql 4
63
63
  end
64
64
 
65
65
  it 'should return 1 with a bit depth lower than 0' do
66
- pixel_bytesize(ChunkyPNG::COLOR_TRUECOLOR, 4).should == 1
67
- pixel_bytesize(ChunkyPNG::COLOR_INDEXED, 2).should == 1
68
- pixel_bytesize(ChunkyPNG::COLOR_GRAYSCALE_ALPHA, 1).should == 1
66
+ expect(pixel_bytesize(ChunkyPNG::COLOR_TRUECOLOR, 4)).to eql 1
67
+ expect(pixel_bytesize(ChunkyPNG::COLOR_INDEXED, 2)).to eql 1
68
+ expect(pixel_bytesize(ChunkyPNG::COLOR_GRAYSCALE_ALPHA, 1)).to eql 1
69
69
  end
70
70
  end
71
71
 
72
72
  describe '#pass_bytesize' do
73
73
  it 'should calculate a pass size correctly' do
74
- pass_bytesize(ChunkyPNG::COLOR_TRUECOLOR, 8, 10, 10).should == 310
74
+ expect(pass_bytesize(ChunkyPNG::COLOR_TRUECOLOR, 8, 10, 10)).to eql 310
75
75
  end
76
76
 
77
77
  it 'should return 0 if one of the dimensions is zero' do
78
- pass_bytesize(ChunkyPNG::COLOR_TRUECOLOR, 8, 0, 10).should == 0
79
- pass_bytesize(ChunkyPNG::COLOR_TRUECOLOR, 8, 10, 0).should == 0
78
+ expect(pass_bytesize(ChunkyPNG::COLOR_TRUECOLOR, 8, 0, 10)).to eql 0
79
+ expect(pass_bytesize(ChunkyPNG::COLOR_TRUECOLOR, 8, 10, 0)).to eql 0
80
80
  end
81
81
  end
82
82
 
83
83
  describe '#rgba' do
84
84
  it 'should represent pixels as the correct number' do
85
- rgba(255, 255, 255, 255).should == @white
86
- rgba( 0, 0, 0, 255).should == @black
87
- rgba( 10, 100, 150, 255).should == @opaque
88
- rgba( 10, 100, 150, 100).should == @non_opaque
89
- rgba( 10, 100, 150, 0).should == @fully_transparent
85
+ expect(rgba(255, 255, 255, 255)).to eql @white
86
+ expect(rgba( 0, 0, 0, 255)).to eql @black
87
+ expect(rgba( 10, 100, 150, 255)).to eql @opaque
88
+ expect(rgba( 10, 100, 150, 100)).to eql @non_opaque
89
+ expect(rgba( 10, 100, 150, 0)).to eql @fully_transparent
90
90
  end
91
91
  end
92
92
 
93
93
  describe '#from_hex' do
94
94
  it 'should load colors correctly from hex notation' do
95
- from_hex('0a649664').should == @non_opaque
96
- from_hex('#0a649664').should == @non_opaque
97
- from_hex('0x0a649664').should == @non_opaque
98
- from_hex('0a6496').should == @opaque
99
- from_hex('#0a6496').should == @opaque
100
- from_hex('0x0a6496').should == @opaque
101
- from_hex('abc').should == 0xaabbccff
102
- from_hex('#abc').should == 0xaabbccff
103
- from_hex('0xabc').should == 0xaabbccff
95
+ expect(from_hex('0a649664')).to eql @non_opaque
96
+ expect(from_hex('#0a649664')).to eql @non_opaque
97
+ expect(from_hex('0x0a649664')).to eql @non_opaque
98
+ expect(from_hex('0a6496')).to eql @opaque
99
+ expect(from_hex('#0a6496')).to eql @opaque
100
+ expect(from_hex('0x0a6496')).to eql @opaque
101
+ expect(from_hex('abc')).to eql 0xaabbccff
102
+ expect(from_hex('#abc')).to eql 0xaabbccff
103
+ expect(from_hex('0xabc')).to eql 0xaabbccff
104
104
  end
105
105
 
106
106
  it 'should allow setting opacity explicitly' do
107
- from_hex('0x0a6496', 0x64).should == @non_opaque
108
- from_hex('#0a6496', 0x64).should == @non_opaque
109
- from_hex('0xabc', 0xdd).should == 0xaabbccdd
110
- from_hex('#abc', 0xdd).should == 0xaabbccdd
107
+ expect(from_hex('0x0a6496', 0x64)).to eql @non_opaque
108
+ expect(from_hex('#0a6496', 0x64)).to eql @non_opaque
109
+ expect(from_hex('0xabc', 0xdd)).to eql 0xaabbccdd
110
+ expect(from_hex('#abc', 0xdd)).to eql 0xaabbccdd
111
111
  end
112
112
  end
113
113
 
114
114
  describe '#from_hsv' do
115
115
  it 'should load colors correctly from an HSV triple' do
116
116
  # At 0 brightness, should be @black independent of hue or sat
117
- from_hsv(0, 0, 0).should == @black
118
- from_hsv(100, 1, 0).should == @black
119
- from_hsv(100, 0.5, 0).should == @black
120
-
117
+ expect(from_hsv(0, 0, 0)).to eql @black
118
+ expect(from_hsv(100, 1, 0)).to eql @black
119
+ expect(from_hsv(100, 0.5, 0)).to eql @black
120
+
121
121
  # At brightness 1 and sat 0, should be @white regardless of hue
122
- from_hsv(0, 0, 1).should == @white
123
- from_hsv(100, 0, 1).should == @white
122
+ expect(from_hsv(0, 0, 1)).to eql @white
123
+ expect(from_hsv(100, 0, 1)).to eql @white
124
124
 
125
125
  # Converting the "pure" colors should work
126
- from_hsv(0, 1, 1).should == @red
127
- from_hsv(120, 1, 1).should == @green
128
- from_hsv(240, 1, 1).should == @blue
126
+ expect(from_hsv(0, 1, 1)).to eql @red
127
+ expect(from_hsv(120, 1, 1)).to eql @green
128
+ expect(from_hsv(240, 1, 1)).to eql @blue
129
129
 
130
130
  # And, finally, one random color
131
- from_hsv(120, 0.5, 0.80).should == 0x66cc66ff
131
+ expect(from_hsv(120, 0.5, 0.80)).to eql 0x66cc66ff
132
132
  end
133
133
 
134
134
  it 'should optionally accept a fourth param for alpha' do
135
- from_hsv(0, 1, 1, 255).should == @red
136
- from_hsv(120, 1, 1, 255).should == @green
137
- from_hsv(240, 1, 1, 255).should == @blue
138
- from_hsv(0, 1, 1, 0).should == 0xff000000 # transparent red
139
- from_hsv(120, 1, 1, 0).should == 0x00ff0000 # transparent green
140
- from_hsv(240, 1, 1, 0).should == 0x0000ff00 # transparent blue
135
+ expect(from_hsv(0, 1, 1, 255)).to eql @red
136
+ expect(from_hsv(120, 1, 1, 255)).to eql @green
137
+ expect(from_hsv(240, 1, 1, 255)).to eql @blue
138
+ expect(from_hsv(0, 1, 1, 0)).to eql 0xff000000 # transparent red
139
+ expect(from_hsv(120, 1, 1, 0)).to eql 0x00ff0000 # transparent green
140
+ expect(from_hsv(240, 1, 1, 0)).to eql 0x0000ff00 # transparent blue
141
141
  end
142
142
  end
143
143
 
144
144
  describe '#from_hsl' do
145
145
  it 'should load colors correctly from an HSL triple' do
146
146
  # At 0 lightness, should always be black
147
- from_hsl(0, 0, 0).should == @black
148
- from_hsl(100, 0, 0).should == @black
149
- from_hsl(54, 0.5, 0).should == @black
150
-
147
+ expect(from_hsl(0, 0, 0)).to eql @black
148
+ expect(from_hsl(100, 0, 0)).to eql @black
149
+ expect(from_hsl(54, 0.5, 0)).to eql @black
150
+
151
151
  # At 1 lightness, should always be white
152
- from_hsl(0, 0, 1).should == @white
153
- from_hsl(0, 0.5, 1).should == @white
154
- from_hsl(110, 0, 1).should == @white
155
-
152
+ expect(from_hsl(0, 0, 1)).to eql @white
153
+ expect(from_hsl(0, 0.5, 1)).to eql @white
154
+ expect(from_hsl(110, 0, 1)).to eql @white
155
+
156
156
  # 'Pure' colors should work
157
- from_hsl(0, 1, 0.5).should == @red
158
- from_hsl(120, 1, 0.5).should == @green
159
- from_hsl(240, 1, 0.5).should == @blue
160
-
157
+ expect(from_hsl(0, 1, 0.5)).to eql @red
158
+ expect(from_hsl(120, 1, 0.5)).to eql @green
159
+ expect(from_hsl(240, 1, 0.5)).to eql @blue
160
+
161
161
  # Random colors
162
162
  from_hsl(87.27, 0.5, 0.5686) == 0x96c85aff
163
163
  from_hsl(271.83, 0.5399, 0.4176) == 0x6e31a4ff
@@ -165,194 +165,194 @@ describe ChunkyPNG::Color do
165
165
  end
166
166
 
167
167
  it 'should optionally accept a fourth param for alpha' do
168
- from_hsl(0, 1, 0.5, 255).should == @red
169
- from_hsl(120, 1, 0.5, 255).should == @green
170
- from_hsl(240, 1, 0.5, 255).should == @blue
171
- from_hsl(0, 1, 0.5, 0).should == 0xff000000 # transparent red
172
- from_hsl(120, 1, 0.5, 0).should == 0x00ff0000 # transparent green
173
- from_hsl(240, 1, 0.5, 0).should == 0x0000ff00 # transparent blue
168
+ expect(from_hsl(0, 1, 0.5, 255)).to eql @red
169
+ expect(from_hsl(120, 1, 0.5, 255)).to eql @green
170
+ expect(from_hsl(240, 1, 0.5, 255)).to eql @blue
171
+ expect(from_hsl(0, 1, 0.5, 0)).to eql 0xff000000 # transparent red
172
+ expect(from_hsl(120, 1, 0.5, 0)).to eql 0x00ff0000 # transparent green
173
+ expect(from_hsl(240, 1, 0.5, 0)).to eql 0x0000ff00 # transparent blue
174
174
  end
175
175
  end
176
176
 
177
177
  describe '#html_color' do
178
178
  it 'should find the correct color value' do
179
- html_color(:springgreen).should == 0x00ff7fff
180
- html_color(:spring_green).should == 0x00ff7fff
181
- html_color('springgreen').should == 0x00ff7fff
182
- html_color('spring green').should == 0x00ff7fff
183
- html_color('SpringGreen').should == 0x00ff7fff
184
- html_color('SPRING_GREEN').should == 0x00ff7fff
179
+ expect(html_color(:springgreen)).to eql 0x00ff7fff
180
+ expect(html_color(:spring_green)).to eql 0x00ff7fff
181
+ expect(html_color('springgreen')).to eql 0x00ff7fff
182
+ expect(html_color('spring green')).to eql 0x00ff7fff
183
+ expect(html_color('SpringGreen')).to eql 0x00ff7fff
184
+ expect(html_color('SPRING_GREEN')).to eql 0x00ff7fff
185
185
  end
186
186
 
187
187
  it 'should set the opacity level explicitly' do
188
- html_color(:springgreen, 0xff).should == 0x00ff7fff
189
- html_color(:springgreen, 0xaa).should == 0x00ff7faa
190
- html_color(:springgreen, 0x00).should == 0x00ff7f00
188
+ expect(html_color(:springgreen, 0xff)).to eql 0x00ff7fff
189
+ expect(html_color(:springgreen, 0xaa)).to eql 0x00ff7faa
190
+ expect(html_color(:springgreen, 0x00)).to eql 0x00ff7f00
191
191
  end
192
192
 
193
193
  it 'should set opacity levels from the color name' do
194
- html_color('Spring green @ 1.0').should == 0x00ff7fff
195
- html_color('Spring green @ 0.666').should == 0x00ff7faa
196
- html_color('Spring green @ 0.0').should == 0x00ff7f00
194
+ expect(html_color('Spring green @ 1.0')).to eql 0x00ff7fff
195
+ expect(html_color('Spring green @ 0.666')).to eql 0x00ff7faa
196
+ expect(html_color('Spring green @ 0.0')).to eql 0x00ff7f00
197
197
  end
198
198
 
199
199
  it 'should raise for an unkown color name' do
200
- lambda { html_color(:nonsense) }.should raise_error(ArgumentError)
200
+ expect { html_color(:nonsense) }.to raise_error(ArgumentError)
201
201
  end
202
202
  end
203
203
 
204
204
  describe '#opaque?' do
205
205
  it 'should correctly check for opaqueness' do
206
- opaque?(@white).should be_true
207
- opaque?(@black).should be_true
208
- opaque?(@opaque).should be_true
209
- opaque?(@non_opaque).should be_false
210
- opaque?(@fully_transparent).should be_false
206
+ expect(opaque?(@white)).to eql true
207
+ expect(opaque?(@black)).to eql true
208
+ expect(opaque?(@opaque)).to eql true
209
+ expect(opaque?(@non_opaque)).to eql false
210
+ expect(opaque?(@fully_transparent)).to eql false
211
211
  end
212
212
  end
213
213
 
214
214
  describe 'extraction of separate color channels' do
215
215
  it 'should extract components from a color correctly' do
216
- r(@opaque).should == 10
217
- g(@opaque).should == 100
218
- b(@opaque).should == 150
219
- a(@opaque).should == 255
216
+ expect(r(@opaque)).to eql 10
217
+ expect(g(@opaque)).to eql 100
218
+ expect(b(@opaque)).to eql 150
219
+ expect(a(@opaque)).to eql 255
220
220
  end
221
221
  end
222
222
 
223
223
  describe '#grayscale_teint' do
224
224
  it 'should calculate the correct grayscale teint' do
225
- grayscale_teint(@opaque).should == 79
226
- grayscale_teint(@non_opaque).should == 79
225
+ expect(grayscale_teint(@opaque)).to eql 79
226
+ expect(grayscale_teint(@non_opaque)).to eql 79
227
227
  end
228
228
  end
229
229
 
230
230
  describe '#to_grayscale' do
231
231
  it 'should use the grayscale teint for r, g and b' do
232
232
  gs = to_grayscale(@non_opaque)
233
- r(gs).should == grayscale_teint(@non_opaque)
234
- g(gs).should == grayscale_teint(@non_opaque)
235
- b(gs).should == grayscale_teint(@non_opaque)
233
+ expect(r(gs)).to eql grayscale_teint(@non_opaque)
234
+ expect(g(gs)).to eql grayscale_teint(@non_opaque)
235
+ expect(b(gs)).to eql grayscale_teint(@non_opaque)
236
236
  end
237
237
 
238
238
  it 'should preserve the alpha channel' do
239
- a(to_grayscale(@non_opaque)).should == a(@non_opaque)
240
- a(to_grayscale(@opaque)).should == ChunkyPNG::Color::MAX
239
+ expect(a(to_grayscale(@non_opaque))).to eql a(@non_opaque)
240
+ expect(a(to_grayscale(@opaque))).to eql ChunkyPNG::Color::MAX
241
241
  end
242
242
  end
243
243
 
244
244
  describe '#to_hex' do
245
245
  it 'should represent colors correcly using hex notation' do
246
- to_hex(@white).should == '#ffffffff'
247
- to_hex(@black).should == '#000000ff'
248
- to_hex(@opaque).should == '#0a6496ff'
249
- to_hex(@non_opaque).should == '#0a649664'
250
- to_hex(@fully_transparent).should == '#0a649600'
246
+ expect(to_hex(@white)).to eql '#ffffffff'
247
+ expect(to_hex(@black)).to eql '#000000ff'
248
+ expect(to_hex(@opaque)).to eql '#0a6496ff'
249
+ expect(to_hex(@non_opaque)).to eql '#0a649664'
250
+ expect(to_hex(@fully_transparent)).to eql '#0a649600'
251
251
  end
252
252
 
253
253
  it 'should represent colors correcly using hex notation without alpha channel' do
254
- to_hex(@white, false).should == '#ffffff'
255
- to_hex(@black, false).should == '#000000'
256
- to_hex(@opaque, false).should == '#0a6496'
257
- to_hex(@non_opaque, false).should == '#0a6496'
258
- to_hex(@fully_transparent, false).should == '#0a6496'
254
+ expect(to_hex(@white, false)).to eql '#ffffff'
255
+ expect(to_hex(@black, false)).to eql '#000000'
256
+ expect(to_hex(@opaque, false)).to eql '#0a6496'
257
+ expect(to_hex(@non_opaque, false)).to eql '#0a6496'
258
+ expect(to_hex(@fully_transparent, false)).to eql '#0a6496'
259
259
  end
260
260
  end
261
261
 
262
262
  describe '#to_hsv' do
263
263
  it 'should return a [hue, saturation, value] array' do
264
- to_hsv(@white).should == [0, 0, 1]
265
- to_hsv(@black).should == [0, 0, 0]
266
- to_hsv(@red).should == [0, 1, 1]
267
- to_hsv(@blue).should == [240, 1, 1]
268
- to_hsv(@green).should == [120, 1, 1]
269
- to_hsv(0x805440ff)[0].should be_within(1).of(19)
270
- to_hsv(0x805440ff)[1].should be_within(0.01).of(0.5)
271
- to_hsv(0x805440ff)[2].should be_within(0.01).of(0.5)
264
+ expect(to_hsv(@white)).to eql [0, 0.0, 1.0]
265
+ expect(to_hsv(@black)).to eql [0, 0.0, 0.0]
266
+ expect(to_hsv(@red)).to eql [0, 1.0, 1.0]
267
+ expect(to_hsv(@blue)).to eql [240, 1.0, 1.0]
268
+ expect(to_hsv(@green)).to eql [120, 1.0, 1.0]
269
+ expect(to_hsv(0x805440ff)[0]).to be_within(1).of(19)
270
+ expect(to_hsv(0x805440ff)[1]).to be_within(0.01).of(0.5)
271
+ expect(to_hsv(0x805440ff)[2]).to be_within(0.01).of(0.5)
272
272
  end
273
273
 
274
274
  it 'should optionally include the alpha channel' do
275
- to_hsv(@white, true).should == [0, 0, 1, 255]
276
- to_hsv(@red, true).should == [0, 1, 1, 255]
277
- to_hsv(@blue, true).should == [240, 1, 1, 255]
278
- to_hsv(@green, true).should == [120, 1, 1, 255]
279
- to_hsv(@opaque, true)[3].should == 255
280
- to_hsv(@fully_transparent, true)[3].should == 0
275
+ expect(to_hsv(@white, true)).to eql [0, 0.0, 1.0, 255]
276
+ expect(to_hsv(@red, true)).to eql [0, 1.0, 1.0, 255]
277
+ expect(to_hsv(@blue, true)).to eql [240, 1.0, 1.0, 255]
278
+ expect(to_hsv(@green, true)).to eql [120, 1.0, 1.0, 255]
279
+ expect(to_hsv(@opaque, true)[3]).to eql 255
280
+ expect(to_hsv(@fully_transparent, true)[3]).to eql 0
281
281
  end
282
282
  end
283
283
 
284
284
  describe '#to_hsl' do
285
285
  it 'should return a [hue, saturation, lightness] array' do
286
- to_hsl(@white).should == [0, 0, 1]
287
- to_hsl(@black).should == [0, 0, 0]
288
- to_hsl(@red).should == [0, 1, 0.5]
289
- to_hsl(@blue).should == [240, 1, 0.5]
290
- to_hsl(@green).should == [120, 1, 0.5]
286
+ expect(to_hsl(@white)).to eql [0, 0.0, 1.0]
287
+ expect(to_hsl(@black)).to eql [0, 0.0, 0.0]
288
+ expect(to_hsl(@red)).to eql [0, 1.0, 0.5]
289
+ expect(to_hsl(@blue)).to eql [240, 1.0, 0.5]
290
+ expect(to_hsl(@green)).to eql [120, 1.0, 0.5]
291
291
  end
292
292
 
293
293
  it 'should optionally include the alpha channel in the returned array' do
294
- to_hsl(@white, true).should == [0, 0, 1, 255]
295
- to_hsl(@black, true).should == [0, 0, 0, 255]
296
- to_hsl(@red, true).should == [0, 1, 0.5, 255]
297
- to_hsl(@blue, true).should == [240, 1, 0.5, 255]
298
- to_hsl(@green, true).should == [120, 1, 0.5, 255]
299
- to_hsl(@opaque, true)[3].should == 255
300
- to_hsl(@fully_transparent, true)[3].should == 0
294
+ expect(to_hsl(@white, true)).to eql [0, 0.0, 1.0, 255]
295
+ expect(to_hsl(@black, true)).to eql [0, 0.0, 0.0, 255]
296
+ expect(to_hsl(@red, true)).to eql [0, 1.0, 0.5, 255]
297
+ expect(to_hsl(@blue, true)).to eql [240, 1.0, 0.5, 255]
298
+ expect(to_hsl(@green, true)).to eql [120, 1.0, 0.5, 255]
299
+ expect(to_hsl(@opaque, true)[3]).to eql 255
300
+ expect(to_hsl(@fully_transparent, true)[3]).to eql 0
301
301
  end
302
302
  end
303
303
 
304
304
  describe 'conversion to other formats' do
305
305
  it 'should convert the individual color values back correctly' do
306
- to_truecolor_bytes(@opaque).should == [10, 100, 150]
307
- to_truecolor_alpha_bytes(@non_opaque).should == [10, 100, 150, 100]
306
+ expect(to_truecolor_bytes(@opaque)).to eql [10, 100, 150]
307
+ expect(to_truecolor_alpha_bytes(@non_opaque)).to eql [10, 100, 150, 100]
308
308
  end
309
309
  end
310
310
 
311
311
  describe '#compose' do
312
312
 
313
313
  it 'should use the foregorund color as is when the background color is fully transparent' do
314
- compose(@non_opaque, @fully_transparent).should == @non_opaque
314
+ expect(compose(@non_opaque, @fully_transparent)).to eql @non_opaque
315
315
  end
316
316
 
317
317
  it 'should use the foregorund color as is when an opaque color is given as foreground color' do
318
- compose(@opaque, @white).should == @opaque
318
+ expect(compose(@opaque, @white)).to eql @opaque
319
319
  end
320
320
 
321
321
  it 'should use the background color as is when a fully transparent pixel is given as foreground color' do
322
- compose(@fully_transparent, @white).should == @white
322
+ expect(compose(@fully_transparent, @white)).to eql @white
323
323
  end
324
324
 
325
325
  it 'should compose pixels correctly with both algorithms' do
326
- compose_quick(@non_opaque, @white).should == 0x9fc2d6ff
327
- compose_precise(@non_opaque, @white).should == 0x9fc2d6ff
326
+ expect(compose_quick(@non_opaque, @white)).to eql 0x9fc2d6ff
327
+ expect(compose_precise(@non_opaque, @white)).to eql 0x9fc2d6ff
328
328
  end
329
329
  end
330
330
 
331
331
  describe '#decompose_alpha' do
332
332
  it 'should decompose the alpha channel correctly' do
333
- decompose_alpha(0x9fc2d6ff, @opaque, @white).should == 0x00000064
333
+ expect(decompose_alpha(0x9fc2d6ff, @opaque, @white)).to eql 0x00000064
334
334
  end
335
335
 
336
336
  it 'should return fully transparent if the background channel matches the resulting color' do
337
- decompose_alpha(0xabcdefff, 0xff000000, 0xabcdefff).should == 0x00
337
+ expect(decompose_alpha(0xabcdefff, 0xff000000, 0xabcdefff)).to eql 0x00
338
338
  end
339
339
 
340
340
  it 'should return fully opaque if the background channel matches the mask color' do
341
- decompose_alpha(0xff000000, 0xabcdefff, 0xabcdefff).should == 0xff
341
+ expect(decompose_alpha(0xff000000, 0xabcdefff, 0xabcdefff)).to eql 0xff
342
342
  end
343
343
 
344
344
  it 'should return fully opaque if the resulting color matches the mask color' do
345
- decompose_alpha(0xabcdefff, 0xabcdefff, 0xffffffff).should == 255
345
+ expect(decompose_alpha(0xabcdefff, 0xabcdefff, 0xffffffff)).to eql 255
346
346
  end
347
347
  end
348
348
 
349
349
  describe '#blend' do
350
350
  it 'should blend colors correctly' do
351
- blend(@opaque, @black).should == 0x05324bff
351
+ expect(blend(@opaque, @black)).to eql 0x05324bff
352
352
  end
353
353
 
354
354
  it 'should not matter what color is used as foreground, and what as background' do
355
- blend(@opaque, @black).should == blend(@black, @opaque)
355
+ expect(blend(@opaque, @black)).to eql blend(@black, @opaque)
356
356
  end
357
357
  end
358
358