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,30 +1,30 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe ChunkyPNG::Canvas::Drawing do
4
-
4
+
5
5
  describe '#compose_pixel' do
6
6
  subject { ChunkyPNG::Canvas.new(1, 1, ChunkyPNG::Color.rgb(200, 150, 100)) }
7
-
7
+
8
8
  it "should compose colors correctly" do
9
9
  subject.compose_pixel(0,0, ChunkyPNG::Color(100, 150, 200, 128))
10
- subject[0, 0].should == ChunkyPNG::Color(150, 150, 150)
10
+ expect(subject[0, 0]).to eql ChunkyPNG::Color(150, 150, 150)
11
11
  end
12
-
12
+
13
13
  it "should return the composed color" do
14
- subject.compose_pixel(0, 0, ChunkyPNG::Color.rgba(100, 150, 200, 128)).should == ChunkyPNG::Color.rgb(150, 150, 150)
14
+ expect(subject.compose_pixel(0, 0, ChunkyPNG::Color.rgba(100, 150, 200, 128))).to eql ChunkyPNG::Color.rgb(150, 150, 150)
15
15
  end
16
-
16
+
17
17
  it "should do nothing when the coordinates are out of bounds" do
18
- subject.compose_pixel(1, -1, :black).should be_nil
19
- lambda { subject.compose_pixel(1, -1, :black) }.should_not change { subject[0, 0] }
18
+ expect(subject.compose_pixel(1, -1, :black)).to be_nil
19
+ expect { subject.compose_pixel(1, -1, :black) }.to_not change { subject[0, 0] }
20
20
  end
21
21
  end
22
-
22
+
23
23
  describe '#line' do
24
24
  it "should draw lines correctly with anti-aliasing" do
25
-
25
+
26
26
  canvas = ChunkyPNG::Canvas.new(31, 31, ChunkyPNG::Color::WHITE)
27
-
27
+
28
28
  canvas.line( 0, 0, 30, 30, ChunkyPNG::Color::BLACK)
29
29
  canvas.line( 0, 30, 30, 0, ChunkyPNG::Color::BLACK)
30
30
  canvas.line(15, 30, 15, 0, ChunkyPNG::Color.rgba(200, 0, 0, 128))
@@ -34,137 +34,137 @@ describe ChunkyPNG::Canvas::Drawing do
34
34
  canvas.line( 0, 30, 15, 0, ChunkyPNG::Color.rgba( 0, 0, 200, 128), false)
35
35
  canvas.line(15, 0, 30, 30, ChunkyPNG::Color.rgba( 0, 0, 200, 128))
36
36
 
37
- canvas.should == reference_canvas('lines')
37
+ expect(canvas).to eql reference_canvas('lines')
38
38
  end
39
-
39
+
40
40
  it "should draw partial lines if the coordinates are partially out of bounds" do
41
41
  canvas = ChunkyPNG::Canvas.new(1, 2, ChunkyPNG::Color::WHITE)
42
42
  canvas.line(-5, -5, 0, 0, '#000000')
43
- canvas.pixels.should == [ChunkyPNG::Color::BLACK, ChunkyPNG::Color::WHITE]
43
+ expect(canvas.pixels).to eql [ChunkyPNG::Color::BLACK, ChunkyPNG::Color::WHITE]
44
44
  end
45
-
45
+
46
46
  it "should return itself to allow chaining" do
47
47
  canvas = ChunkyPNG::Canvas.new(16, 16, ChunkyPNG::Color::WHITE)
48
- canvas.line(1, 1, 10, 10, :black).should equal(canvas)
48
+ expect(canvas.line(1, 1, 10, 10, :black)).to equal(canvas)
49
49
  end
50
50
  end
51
-
51
+
52
52
  describe '#rect' do
53
53
  subject { ChunkyPNG::Canvas.new(16, 16, '#ffffff') }
54
-
54
+
55
55
  it "should draw a rectangle with the correct colors" do
56
56
  subject.rect(1, 1, 10, 10, ChunkyPNG::Color.rgba(0, 255, 0, 80), ChunkyPNG::Color.rgba(255, 0, 0, 100))
57
57
  subject.rect(5, 5, 14, 14, ChunkyPNG::Color.rgba(0, 0, 255, 160), ChunkyPNG::Color.rgba(255, 255, 0, 100))
58
- subject.should == reference_canvas('rect')
58
+ expect(subject).to eql reference_canvas('rect')
59
59
  end
60
-
60
+
61
61
  it "should return itself to allow chaining" do
62
- subject.rect(1, 1, 10, 10).should equal(subject)
62
+ expect(subject.rect(1, 1, 10, 10)).to equal(subject)
63
63
  end
64
-
64
+
65
65
  it "should draw partial rectangles if the coordinates are partially out of bounds" do
66
66
  subject.rect(0, 0, 20, 20, :black, :white)
67
- subject[0, 0].should == ChunkyPNG::Color::BLACK
67
+ expect(subject[0, 0]).to eql ChunkyPNG::Color::BLACK
68
68
  end
69
-
69
+
70
70
  it "should draw the rectangle fill only if the coordinates are fully out of bounds" do
71
71
  subject.rect(-1, -1, 20, 20, :black, :white)
72
- subject[0, 0].should == ChunkyPNG::Color::WHITE
72
+ expect(subject[0, 0]).to eql ChunkyPNG::Color::WHITE
73
73
  end
74
74
  end
75
-
75
+
76
76
  describe '#circle' do
77
- subject { ChunkyPNG::Canvas.new(32, 32, ChunkyPNG::Color.rgba(0, 0, 255, 128)) }
78
-
77
+ subject { ChunkyPNG::Canvas.new(32, 32, ChunkyPNG::Color.rgba(0, 0, 255, 128)) }
78
+
79
79
  it "should draw circles" do
80
80
  subject.circle(11, 11, 10, ChunkyPNG::Color('red @ 0.5'), ChunkyPNG::Color('white @ 0.2'))
81
81
  subject.circle(21, 21, 10, ChunkyPNG::Color('green @ 0.5'))
82
- subject.should == reference_canvas('circles')
82
+ expect(subject).to eql reference_canvas('circles')
83
83
  end
84
-
84
+
85
85
  it "should draw partial circles when going of the canvas bounds" do
86
86
  subject.circle(0, 0, 10, ChunkyPNG::Color(:red))
87
87
  subject.circle(31, 16, 10, ChunkyPNG::Color(:black), ChunkyPNG::Color(:white, 0xaa))
88
- subject.should == reference_canvas('partial_circles')
88
+ expect(subject).to eql reference_canvas('partial_circles')
89
89
  end
90
90
 
91
91
  it "should return itself to allow chaining" do
92
- subject.circle(10, 10, 5, :red).should equal(subject)
92
+ expect(subject.circle(10, 10, 5, :red)).to equal(subject)
93
93
  end
94
94
  end
95
-
95
+
96
96
  describe '#polygon' do
97
97
  subject { ChunkyPNG::Canvas.new(22, 22) }
98
98
 
99
99
  it "should draw an filled triangle when using 3 control points" do
100
100
  subject.polygon('(2,2) (20,5) (5,20)', ChunkyPNG::Color(:black, 0xaa), ChunkyPNG::Color(:red, 0x44))
101
- subject.should == reference_canvas('polygon_triangle_filled')
101
+ expect(subject).to eql reference_canvas('polygon_triangle_filled')
102
102
  end
103
103
 
104
104
  it "should draw a unfilled polygon with 6 control points" do
105
105
  subject.polygon('(2,2) (12, 1) (20,5) (18,18) (5,20) (1,12)', ChunkyPNG::Color(:black))
106
- subject.should == reference_canvas('polygon_unfilled')
106
+ expect(subject).to eql reference_canvas('polygon_unfilled')
107
107
  end
108
-
108
+
109
109
  it "should draw a vertically crossed filled polygon with 4 control points" do
110
110
  subject.polygon('(2,2) (21,2) (2,21) (21,21)', ChunkyPNG::Color(:black), ChunkyPNG::Color(:red))
111
- subject.should == reference_canvas('polygon_filled_vertical')
111
+ expect(subject).to eql reference_canvas('polygon_filled_vertical')
112
112
  end
113
113
 
114
114
  it "should draw a vertically crossed filled polygon with 4 control points" do
115
115
  subject.polygon('(2,2) (2,21) (21,2) (21,21)', ChunkyPNG::Color(:black), ChunkyPNG::Color(:red))
116
- subject.should == reference_canvas('polygon_filled_horizontal')
116
+ expect(subject).to eql reference_canvas('polygon_filled_horizontal')
117
117
  end
118
118
 
119
119
  it "should return itself to allow chaining" do
120
- subject.polygon('(2,2) (20,5) (5,20)').should equal(subject)
120
+ expect(subject.polygon('(2,2) (20,5) (5,20)')).to equal(subject)
121
121
  end
122
122
  end
123
-
123
+
124
124
  describe '#bezier_curve' do
125
125
  subject { ChunkyPNG::Canvas.new(24, 24, ChunkyPNG::Color::WHITE) }
126
-
126
+
127
127
  it "should draw a bezier curve starting at the first point" do
128
128
  subject.bezier_curve('3,20 10,10, 20,20')
129
- subject[3, 20].should == ChunkyPNG::Color::BLACK
129
+ expect(subject[3, 20]).to eql ChunkyPNG::Color::BLACK
130
130
  end
131
-
131
+
132
132
  it "should draw a bezier curve ending at the last point" do
133
133
  subject.bezier_curve('3,20 10,10, 20,20')
134
- subject[20, 20].should == ChunkyPNG::Color::BLACK
134
+ expect(subject[20, 20]).to eql ChunkyPNG::Color::BLACK
135
135
  end
136
-
136
+
137
137
  it "should draw a bezier curve with a color of green" do
138
138
  subject.bezier_curve('3,20 10,10, 20,20', :green)
139
- subject[3, 20].should == ChunkyPNG::Color(:green)
139
+ expect(subject[3, 20]).to eql ChunkyPNG::Color(:green)
140
140
  end
141
-
141
+
142
142
  it "should draw a three point bezier curve" do
143
- subject.bezier_curve('1,23 12,10 23,23').should == reference_canvas('bezier_three_point')
143
+ expect(subject.bezier_curve('1,23 12,10 23,23')).to eql reference_canvas('bezier_three_point')
144
144
  end
145
-
145
+
146
146
  it "should draw a three point bezier curve flipped" do
147
- subject.bezier_curve('1,1 12,15 23,1').should == reference_canvas('bezier_three_point_flipped')
147
+ expect(subject.bezier_curve('1,1 12,15 23,1')).to eql reference_canvas('bezier_three_point_flipped')
148
148
  end
149
-
149
+
150
150
  it "should draw a four point bezier curve" do
151
- subject.bezier_curve('1,23 1,5 22,5 22,23').should == reference_canvas('bezier_four_point')
151
+ expect(subject.bezier_curve('1,23 1,5 22,5 22,23')).to eql reference_canvas('bezier_four_point')
152
152
  end
153
-
153
+
154
154
  it "should draw a four point bezier curve flipped" do
155
- subject.bezier_curve('1,1 1,19 22,19 22,1').should == reference_canvas('bezier_four_point_flipped')
155
+ expect(subject.bezier_curve('1,1 1,19 22,19 22,1')).to eql reference_canvas('bezier_four_point_flipped')
156
156
  end
157
-
157
+
158
158
  it "should draw a four point bezier curve with a shape of an s" do
159
- subject.bezier_curve('1,23 1,5 22,23 22,5').should == reference_canvas('bezier_four_point_s')
159
+ expect(subject.bezier_curve('1,23 1,5 22,23 22,5')).to eql reference_canvas('bezier_four_point_s')
160
160
  end
161
-
161
+
162
162
  it "should draw a five point bezier curve" do
163
- subject.bezier_curve('10,23 1,10 12,5 23,10 14,23').should == reference_canvas('bezier_five_point')
163
+ expect(subject.bezier_curve('10,23 1,10 12,5 23,10 14,23')).to eql reference_canvas('bezier_five_point')
164
164
  end
165
-
165
+
166
166
  it "should draw a six point bezier curve" do
167
- subject.bezier_curve('1,23 4,15 8,20 2,2 23,15 23,1').should == reference_canvas('bezier_six_point')
167
+ expect(subject.bezier_curve('1,23 4,15 8,20 2,2 23,15 23,1')).to eql reference_canvas('bezier_six_point')
168
168
  end
169
169
  end
170
170
  end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe ChunkyPNG::Canvas::Masking do
4
-
4
+
5
5
  subject { reference_canvas('clock') }
6
6
 
7
7
  before(:all) do
@@ -9,43 +9,43 @@ describe ChunkyPNG::Canvas::Masking do
9
9
  @new_color = ChunkyPNG::Color('#ff0000')
10
10
  @background_color = ChunkyPNG::Color('white')
11
11
  end
12
-
12
+
13
13
  describe '#change_theme_color!' do
14
14
  it "should change the theme color correctly" do
15
15
  subject.change_theme_color!(@theme_color, @new_color)
16
- subject.should == reference_canvas('clock_updated')
16
+ expect(subject).to eql reference_canvas('clock_updated')
17
17
  end
18
18
  end
19
-
19
+
20
20
  describe '#extract_mask' do
21
21
  it "should create the correct base and mask image" do
22
22
  base, mask = subject.extract_mask(@theme_color, @background_color)
23
- base.should == reference_canvas('clock_base')
24
- mask.should == reference_canvas('clock_mask')
23
+ expect(base).to eql reference_canvas('clock_base')
24
+ expect(mask).to eql reference_canvas('clock_mask')
25
25
  end
26
-
26
+
27
27
  it "should create a mask image with only one opaque color" do
28
28
  base, mask = subject.extract_mask(@theme_color, @background_color)
29
- mask.palette.opaque_palette.size.should == 1
29
+ expect(mask.palette.opaque_palette.size).to eql 1
30
30
  end
31
31
  end
32
-
32
+
33
33
  describe '#change_mask_color!' do
34
34
  before { @mask = reference_canvas('clock_mask') }
35
-
35
+
36
36
  it "should replace the mask color correctly" do
37
37
  @mask.change_mask_color!(@new_color)
38
- @mask.should == reference_canvas('clock_mask_updated')
38
+ expect(@mask).to eql reference_canvas('clock_mask_updated')
39
39
  end
40
-
40
+
41
41
  it "should still only have one opaque color" do
42
42
  @mask.change_mask_color!(@new_color)
43
- @mask.palette.opaque_palette.size.should == 1
43
+ expect(@mask.palette.opaque_palette.size).to eql 1
44
44
  end
45
-
45
+
46
46
  it "should raise an exception when the mask image has more than once color" do
47
47
  not_a_mask = reference_canvas('operations')
48
- lambda { not_a_mask.change_mask_color!(@new_color) }.should raise_error(ChunkyPNG::ExpectationFailed)
48
+ expect { not_a_mask.change_mask_color!(@new_color) }.to raise_error(ChunkyPNG::ExpectationFailed)
49
49
  end
50
50
  end
51
51
  end
@@ -10,28 +10,28 @@ describe ChunkyPNG::Canvas::Operations do
10
10
  end
11
11
 
12
12
  it "should convert the image correctly" do
13
- subject.grayscale.should == reference_canvas('operations_grayscale')
13
+ expect(subject.grayscale).to eql reference_canvas('operations_grayscale')
14
14
  end
15
15
 
16
16
  it "should not adjust the current image" do
17
- lambda { subject.grayscale }.should_not change(subject, :pixels)
17
+ expect { subject.grayscale }.to_not change { subject.pixels }
18
18
  end
19
19
  end
20
20
 
21
21
  describe '#grayscale!' do
22
22
  it "should return itself" do
23
- subject.grayscale!.should equal(subject)
23
+ expect(subject.grayscale!).to equal(subject)
24
24
  end
25
25
 
26
26
  it "should convert the image correctly" do
27
27
  subject.grayscale!
28
- subject.should == reference_canvas('operations_grayscale')
28
+ expect(subject).to eql reference_canvas('operations_grayscale')
29
29
  end
30
30
  end
31
31
 
32
32
  describe '#crop' do
33
33
  it "should crop the right pixels from the original canvas" do
34
- subject.crop(10, 5, 4, 8).should == reference_canvas('cropped')
34
+ expect(subject.crop(10, 5, 4, 8)).to eql reference_canvas('cropped')
35
35
  end
36
36
 
37
37
  it "should not return itself" do
@@ -39,44 +39,43 @@ describe ChunkyPNG::Canvas::Operations do
39
39
  end
40
40
 
41
41
  it "should not adjust the current image" do
42
- lambda { subject.crop(10, 5, 4, 8) }.should_not change(subject, :pixels)
42
+ expect { subject.crop(10, 5, 4, 8) }.to_not change { subject.pixels }
43
43
  end
44
44
 
45
45
  it "should raise an exception when the cropped image falls outside the oiginal image" do
46
- lambda { subject.crop(16, 16, 2, 2) }.should raise_error(ChunkyPNG::OutOfBounds)
46
+ expect { subject.crop(16, 16, 2, 2) }.to raise_error(ChunkyPNG::OutOfBounds)
47
47
  end
48
48
  end
49
49
 
50
50
  describe '#crop!' do
51
51
  it "should crop the right pixels from the original canvas" do
52
52
  subject.crop!(10, 5, 4, 8)
53
- subject.should == reference_canvas('cropped')
53
+ expect(subject).to eql reference_canvas('cropped')
54
54
  end
55
55
 
56
56
  it "should have a new width and height" do
57
- lambda { subject.crop!(10, 5, 4, 8) }.should change(subject, :dimension).
58
- from(ChunkyPNG::Dimension('16x16')).
59
- to(ChunkyPNG::Dimension('4x8'))
57
+ expect { subject.crop!(10, 5, 4, 8) }.to change { subject.dimension }.
58
+ from(ChunkyPNG::Dimension('16x16')).to(ChunkyPNG::Dimension('4x8'))
60
59
  end
61
60
 
62
61
  it "should raise an exception when the cropped image falls outside the oiginal image" do
63
- lambda { subject.crop!(16, 16, 2, 2) }.should raise_error(ChunkyPNG::OutOfBounds)
62
+ expect { subject.crop!(16, 16, 2, 2) }.to raise_error(ChunkyPNG::OutOfBounds)
64
63
  end
65
64
 
66
65
  it "should return itself" do
67
- subject.crop!(10, 5, 4, 8).should equal(subject)
66
+ expect(subject.crop!(10, 5, 4, 8)).to equal(subject)
68
67
  end
69
68
  end
70
69
 
71
70
  describe '#compose' do
72
71
  it "should compose pixels correctly" do
73
72
  subcanvas = ChunkyPNG::Canvas.new(4, 8, ChunkyPNG::Color.rgba(0, 0, 0, 75))
74
- subject.compose(subcanvas, 8, 4).should == reference_canvas('composited')
73
+ expect(subject.compose(subcanvas, 8, 4)).to eql reference_canvas('composited')
75
74
  end
76
75
 
77
76
  it "should leave the original intact" do
78
77
  subject.compose(ChunkyPNG::Canvas.new(1,1))
79
- subject.should == reference_canvas('operations')
78
+ expect(subject).to eql reference_canvas('operations')
80
79
  end
81
80
 
82
81
  it "should not return itself" do
@@ -84,7 +83,7 @@ describe ChunkyPNG::Canvas::Operations do
84
83
  end
85
84
 
86
85
  it "should raise an exception when the pixels to compose fall outside the image" do
87
- lambda { subject.compose(ChunkyPNG::Canvas.new(1,1), 16, 16) }.should raise_error(ChunkyPNG::OutOfBounds)
86
+ expect { subject.compose(ChunkyPNG::Canvas.new(1,1), 16, 16) }.to raise_error(ChunkyPNG::OutOfBounds)
88
87
  end
89
88
  end
90
89
 
@@ -92,29 +91,29 @@ describe ChunkyPNG::Canvas::Operations do
92
91
  it "should compose pixels correctly" do
93
92
  subcanvas = ChunkyPNG::Canvas.new(4, 8, ChunkyPNG::Color.rgba(0, 0, 0, 75))
94
93
  subject.compose!(subcanvas, 8, 4)
95
- subject.should == reference_canvas('composited')
94
+ expect(subject).to eql reference_canvas('composited')
96
95
  end
97
96
 
98
97
  it "should return itself" do
99
- subject.compose!(ChunkyPNG::Canvas.new(1,1)).should equal(subject)
98
+ expect(subject.compose!(ChunkyPNG::Canvas.new(1,1))).to equal(subject)
100
99
  end
101
100
 
102
101
  it "should compose a base image and mask correctly" do
103
102
  base = reference_canvas('clock_base')
104
103
  mask = reference_canvas('clock_mask_updated')
105
104
  base.compose!(mask)
106
- base.should == reference_canvas('clock_updated')
105
+ expect(base).to eql reference_canvas('clock_updated')
107
106
  end
108
107
 
109
108
  it "should raise an exception when the pixels to compose fall outside the image" do
110
- lambda { subject.compose!(ChunkyPNG::Canvas.new(1,1), 16, 16) }.should raise_error(ChunkyPNG::OutOfBounds)
109
+ expect { subject.compose!(ChunkyPNG::Canvas.new(1,1), 16, 16) }.to raise_error(ChunkyPNG::OutOfBounds)
111
110
  end
112
111
  end
113
112
 
114
113
  describe '#replace' do
115
114
  it "should replace the correct pixels" do
116
115
  subcanvas = ChunkyPNG::Canvas.new(3, 2, ChunkyPNG::Color.rgb(200, 255, 0))
117
- subject.replace(subcanvas, 5, 4).should == reference_canvas('replaced')
116
+ expect(subject.replace(subcanvas, 5, 4)).to eql reference_canvas('replaced')
118
117
  end
119
118
 
120
119
  it "should not return itself" do
@@ -123,11 +122,11 @@ describe ChunkyPNG::Canvas::Operations do
123
122
 
124
123
  it "should leave the original intact" do
125
124
  subject.replace(ChunkyPNG::Canvas.new(1,1))
126
- subject.should == reference_canvas('operations')
125
+ expect(subject).to eql reference_canvas('operations')
127
126
  end
128
127
 
129
128
  it "should raise an exception when the pixels to replace fall outside the image" do
130
- lambda { subject.replace(ChunkyPNG::Canvas.new(1,1), 16, 16) }.should raise_error(ChunkyPNG::OutOfBounds)
129
+ expect { subject.replace(ChunkyPNG::Canvas.new(1,1), 16, 16) }.to raise_error(ChunkyPNG::OutOfBounds)
131
130
  end
132
131
  end
133
132
 
@@ -135,15 +134,15 @@ describe ChunkyPNG::Canvas::Operations do
135
134
  it "should replace the correct pixels" do
136
135
  subcanvas = ChunkyPNG::Canvas.new(3, 2, ChunkyPNG::Color.rgb(200, 255, 0))
137
136
  subject.replace!(subcanvas, 5, 4)
138
- subject.should == reference_canvas('replaced')
137
+ expect(subject).to eql reference_canvas('replaced')
139
138
  end
140
139
 
141
140
  it "should return itself" do
142
- subject.replace!(ChunkyPNG::Canvas.new(1,1)).should equal(subject)
141
+ expect(subject.replace!(ChunkyPNG::Canvas.new(1,1))).to equal(subject)
143
142
  end
144
143
 
145
144
  it "should raise an exception when the pixels to replace fall outside the image" do
146
- lambda { subject.replace!(ChunkyPNG::Canvas.new(1,1), 16, 16) }.should raise_error(ChunkyPNG::OutOfBounds)
145
+ expect { subject.replace!(ChunkyPNG::Canvas.new(1,1), 16, 16) }.to raise_error(ChunkyPNG::OutOfBounds)
147
146
  end
148
147
  end
149
148
  end
@@ -155,17 +154,17 @@ describe ChunkyPNG::Canvas::Operations do
155
154
  describe '#flip_horizontally!' do
156
155
  it "should flip the pixels horizontally in place" do
157
156
  subject.flip_horizontally!
158
- subject.should == ChunkyPNG::Canvas.new(2, 3, [5, 6, 3, 4, 1, 2])
157
+ expect(subject).to eql ChunkyPNG::Canvas.new(2, 3, [5, 6, 3, 4, 1, 2])
159
158
  end
160
159
 
161
160
  it "should return itself" do
162
- subject.flip_horizontally!.should equal(subject)
161
+ expect(subject.flip_horizontally!).to equal(subject)
163
162
  end
164
163
  end
165
164
 
166
165
  describe '#flip_horizontally' do
167
166
  it "should flip the pixels horizontally" do
168
- subject.flip_horizontally.should == ChunkyPNG::Canvas.new(2, 3, [5, 6, 3, 4, 1, 2])
167
+ expect(subject.flip_horizontally).to eql ChunkyPNG::Canvas.new(2, 3, [5, 6, 3, 4, 1, 2])
169
168
  end
170
169
 
171
170
  it "should not return itself" do
@@ -173,24 +172,24 @@ describe ChunkyPNG::Canvas::Operations do
173
172
  end
174
173
 
175
174
  it "should return a copy of itself when applied twice" do
176
- subject.flip_horizontally.flip_horizontally.should == subject
175
+ expect(subject.flip_horizontally.flip_horizontally).to eql subject
177
176
  end
178
177
  end
179
178
 
180
179
  describe '#flip_vertically!' do
181
180
  it "should flip the pixels vertically" do
182
181
  subject.flip_vertically!
183
- subject.should == ChunkyPNG::Canvas.new(2, 3, [2, 1, 4, 3, 6, 5])
182
+ expect(subject).to eql ChunkyPNG::Canvas.new(2, 3, [2, 1, 4, 3, 6, 5])
184
183
  end
185
184
 
186
185
  it "should return itself" do
187
- subject.flip_horizontally!.should equal(subject)
186
+ expect(subject.flip_horizontally!).to equal(subject)
188
187
  end
189
188
  end
190
189
 
191
190
  describe '#flip_vertically' do
192
191
  it "should flip the pixels vertically" do
193
- subject.flip_vertically.should == ChunkyPNG::Canvas.new(2, 3, [2, 1, 4, 3, 6, 5])
192
+ expect(subject.flip_vertically).to eql ChunkyPNG::Canvas.new(2, 3, [2, 1, 4, 3, 6, 5])
194
193
  end
195
194
 
196
195
  it "should not return itself" do
@@ -198,13 +197,13 @@ describe ChunkyPNG::Canvas::Operations do
198
197
  end
199
198
 
200
199
  it "should return a copy of itself when applied twice" do
201
- subject.flip_vertically.flip_vertically.should == subject
200
+ expect(subject.flip_vertically.flip_vertically).to eql subject
202
201
  end
203
202
  end
204
203
 
205
204
  describe '#rotate_left' do
206
205
  it "should rotate the pixels 90 degrees counter-clockwise" do
207
- subject.rotate_left.should == ChunkyPNG::Canvas.new(3, 2, [2, 4, 6, 1, 3, 5] )
206
+ expect(subject.rotate_left).to eql ChunkyPNG::Canvas.new(3, 2, [2, 4, 6, 1, 3, 5] )
208
207
  end
209
208
 
210
209
  it "should not return itself" do
@@ -212,40 +211,41 @@ describe ChunkyPNG::Canvas::Operations do
212
211
  end
213
212
 
214
213
  it "should not change the image dimensions" do
215
- lambda { subject.rotate_left }.should_not change(subject, :dimension)
214
+ expect { subject.rotate_left }.to_not change { subject.dimension }
216
215
  end
217
216
 
218
217
  it "it should rotate 180 degrees when applied twice" do
219
- subject.rotate_left.rotate_left.should == subject.rotate_180
218
+ expect(subject.rotate_left.rotate_left).to eql subject.rotate_180
220
219
  end
221
220
 
222
221
  it "it should rotate right when applied three times" do
223
- subject.rotate_left.rotate_left.rotate_left.should == subject.rotate_right
222
+ expect(subject.rotate_left.rotate_left.rotate_left).to eql subject.rotate_right
224
223
  end
225
224
 
226
225
  it "should return itself when applied four times" do
227
- subject.rotate_left.rotate_left.rotate_left.rotate_left.should == subject
226
+ expect(subject.rotate_left.rotate_left.rotate_left.rotate_left).to eql subject
228
227
  end
229
228
  end
230
229
 
231
230
  describe '#rotate_left!' do
232
231
  it "should rotate the pixels 90 degrees clockwise" do
233
232
  subject.rotate_left!
234
- subject.should == ChunkyPNG::Canvas.new(3, 2, [2, 4, 6, 1, 3, 5] )
233
+ expect(subject).to eql ChunkyPNG::Canvas.new(3, 2, [2, 4, 6, 1, 3, 5] )
235
234
  end
236
235
 
237
236
  it "should return itself" do
238
- subject.rotate_left!.should equal(subject)
237
+ expect(subject.rotate_left!).to equal(subject)
239
238
  end
240
239
 
241
240
  it "should change the image dimensions" do
242
- lambda { subject.rotate_left! }.should change(subject, :dimension).from(ChunkyPNG::Dimension('2x3')).to(ChunkyPNG::Dimension('3x2'))
241
+ expect { subject.rotate_left! }.to change { subject.dimension }.
242
+ from(ChunkyPNG::Dimension('2x3')).to(ChunkyPNG::Dimension('3x2'))
243
243
  end
244
244
  end
245
245
 
246
246
  describe '#rotate_right' do
247
247
  it "should rotate the pixels 90 degrees clockwise" do
248
- subject.rotate_right.should == ChunkyPNG::Canvas.new(3, 2, [5, 3, 1, 6, 4, 2] )
248
+ expect(subject.rotate_right).to eql ChunkyPNG::Canvas.new(3, 2, [5, 3, 1, 6, 4, 2] )
249
249
  end
250
250
 
251
251
  it "should not return itself" do
@@ -253,40 +253,41 @@ describe ChunkyPNG::Canvas::Operations do
253
253
  end
254
254
 
255
255
  it "should not change the image dimensions" do
256
- lambda { subject.rotate_right }.should_not change(subject, :dimension)
256
+ expect { subject.rotate_right }.to_not change { subject.dimension }
257
257
  end
258
258
 
259
259
  it "it should rotate 180 degrees when applied twice" do
260
- subject.rotate_right.rotate_right.should == subject.rotate_180
260
+ expect(subject.rotate_right.rotate_right).to eql subject.rotate_180
261
261
  end
262
262
 
263
263
  it "it should rotate left when applied three times" do
264
- subject.rotate_right.rotate_right.rotate_right.should == subject.rotate_left
264
+ expect(subject.rotate_right.rotate_right.rotate_right).to eql subject.rotate_left
265
265
  end
266
266
 
267
267
  it "should return itself when applied four times" do
268
- subject.rotate_right.rotate_right.rotate_right.rotate_right.should == subject
268
+ expect(subject.rotate_right.rotate_right.rotate_right.rotate_right).to eql subject
269
269
  end
270
270
  end
271
271
 
272
272
  describe '#rotate_right!' do
273
273
  it "should rotate the pixels 90 degrees clockwise" do
274
274
  subject.rotate_right!
275
- subject.should == ChunkyPNG::Canvas.new(3, 2, [5, 3, 1, 6, 4, 2] )
275
+ expect(subject).to eql ChunkyPNG::Canvas.new(3, 2, [5, 3, 1, 6, 4, 2] )
276
276
  end
277
277
 
278
278
  it "should return itself" do
279
- subject.rotate_right!.should equal(subject)
279
+ expect(subject.rotate_right!).to equal(subject)
280
280
  end
281
281
 
282
282
  it "should change the image dimensions" do
283
- lambda { subject.rotate_right! }.should change(subject, :dimension).from(ChunkyPNG::Dimension('2x3')).to(ChunkyPNG::Dimension('3x2'))
283
+ expect { subject.rotate_right! }.to change { subject.dimension }.
284
+ from(ChunkyPNG::Dimension('2x3')).to(ChunkyPNG::Dimension('3x2'))
284
285
  end
285
286
  end
286
287
 
287
288
  describe '#rotate_180' do
288
289
  it "should rotate the pixels 180 degrees" do
289
- subject.rotate_180.should == ChunkyPNG::Canvas.new(2, 3, [6, 5, 4, 3, 2, 1])
290
+ expect(subject.rotate_180).to eql ChunkyPNG::Canvas.new(2, 3, [6, 5, 4, 3, 2, 1])
290
291
  end
291
292
 
292
293
  it "should return not itself" do
@@ -294,18 +295,18 @@ describe ChunkyPNG::Canvas::Operations do
294
295
  end
295
296
 
296
297
  it "should return a copy of itself when applied twice" do
297
- subject.rotate_180.rotate_180.should == subject
298
+ expect(subject.rotate_180.rotate_180).to eql subject
298
299
  end
299
300
  end
300
301
 
301
302
  describe '#rotate_180!' do
302
303
  it "should rotate the pixels 180 degrees" do
303
304
  subject.rotate_180!
304
- subject.should == ChunkyPNG::Canvas.new(2, 3, [6, 5, 4, 3, 2, 1])
305
+ expect(subject).to eql ChunkyPNG::Canvas.new(2, 3, [6, 5, 4, 3, 2, 1])
305
306
  end
306
307
 
307
308
  it "should return itself" do
308
- subject.rotate_180!.should equal(subject)
309
+ expect(subject.rotate_180!).to equal(subject)
309
310
  end
310
311
  end
311
312
  end
@@ -316,7 +317,7 @@ describe ChunkyPNG::Canvas::Operations do
316
317
 
317
318
  describe "#trim" do
318
319
  it "should trim the border" do
319
- subject.trim.should == ChunkyPNG::Canvas.new(2, 2, 255)
320
+ expect(subject.trim).to eql ChunkyPNG::Canvas.new(2, 2, 255)
320
321
  end
321
322
 
322
323
  it "should not return itself" do
@@ -324,26 +325,27 @@ describe ChunkyPNG::Canvas::Operations do
324
325
  end
325
326
 
326
327
  it "should be able to fail to trim a specified color" do
327
- lambda { subject.trim(ChunkyPNG::Color::BLACK) }.should_not change(subject, :pixels)
328
+ expect { subject.trim(ChunkyPNG::Color::BLACK) }.to_not change { subject.pixels }
328
329
  end
329
330
 
330
331
  it "should be the same after trimming an added border" do
331
- subject.border(2).trim.should == subject
332
+ expect(subject.border(2).trim).to eql subject
332
333
  end
333
334
  end
334
335
 
335
336
  describe "#trim!" do
336
337
  it "should trim the border" do
337
338
  subject.trim!
338
- subject.should == ChunkyPNG::Canvas.new(2, 2, 255)
339
+ expect(subject).to eql ChunkyPNG::Canvas.new(2, 2, 255)
339
340
  end
340
341
 
341
342
  it "should return itself" do
342
- subject.trim!.should equal(subject)
343
+ expect(subject.trim!).to equal(subject)
343
344
  end
344
345
 
345
346
  it "should change the image dimensions" do
346
- lambda { subject.trim! }.should change(subject, :dimension).from(ChunkyPNG::Dimension('4x4')).to(ChunkyPNG::Dimension('2x2'))
347
+ expect { subject.trim! }.to change { subject.dimension }.
348
+ from(ChunkyPNG::Dimension('4x4')).to(ChunkyPNG::Dimension('2x2'))
347
349
  end
348
350
  end
349
351
  end
@@ -354,7 +356,7 @@ describe ChunkyPNG::Canvas::Operations do
354
356
 
355
357
  describe "#border" do
356
358
  it "should add the border" do
357
- subject.border(2).should == reference_canvas('operations_border')
359
+ expect(subject.border(2)).to eql reference_canvas('operations_border')
358
360
  end
359
361
 
360
362
  it "should not return itself" do
@@ -362,27 +364,28 @@ describe ChunkyPNG::Canvas::Operations do
362
364
  end
363
365
 
364
366
  it "should retain transparency" do
365
- ChunkyPNG::Canvas.new(1, 1).border(1).pixels.should include(0)
367
+ expect(ChunkyPNG::Canvas.new(1, 1).border(1).pixels).to include(0)
366
368
  end
367
369
  end
368
370
 
369
371
  describe "#border!" do
370
372
  it "should add the border" do
371
373
  subject.border!(2)
372
- subject.should == reference_canvas('operations_border')
374
+ expect(subject).to eql reference_canvas('operations_border')
373
375
  end
374
376
 
375
377
  it "should return itself" do
376
- subject.border!(1).should equal(subject)
378
+ expect(subject.border!(1)).to equal(subject)
377
379
  end
378
380
 
379
381
  it "should retain transparency" do
380
382
  subject.border!(1)
381
- subject.pixels.should include(0)
383
+ expect(subject.pixels).to include(0)
382
384
  end
383
385
 
384
386
  it "should change the image dimensions" do
385
- lambda { subject.border!(1) }.should change(subject, :dimension).from(ChunkyPNG::Dimension('4x4')).to(ChunkyPNG::Dimension('6x6'))
387
+ expect { subject.border!(1) }.to change { subject.dimension }.
388
+ from(ChunkyPNG::Dimension('4x4')).to(ChunkyPNG::Dimension('6x6'))
386
389
  end
387
390
  end
388
391
  end