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.
@@ -5,12 +5,12 @@ describe ChunkyPNG::Datastream do
5
5
  describe '.from_io'do
6
6
  it "should raise an error when loading a file with a bad signature" do
7
7
  filename = resource_file('damaged_signature.png')
8
- lambda { ChunkyPNG::Datastream.from_file(filename) }.should raise_error
8
+ expect { ChunkyPNG::Datastream.from_file(filename) }.to raise_error
9
9
  end
10
10
 
11
11
  it "should raise an error if the CRC of a chunk is incorrect" do
12
12
  filename = resource_file('damaged_chunk.png')
13
- lambda { ChunkyPNG::Datastream.from_file(filename) }.should raise_error
13
+ expect { ChunkyPNG::Datastream.from_file(filename) }.to raise_error
14
14
  end
15
15
  end
16
16
 
@@ -18,15 +18,15 @@ describe ChunkyPNG::Datastream do
18
18
  it "should load uncompressed tXTt chunks correctly" do
19
19
  filename = resource_file('text_chunk.png')
20
20
  ds = ChunkyPNG::Datastream.from_file(filename)
21
- ds.metadata['Title'].should == 'My amazing icon!'
22
- ds.metadata['Author'].should == "Willem van Bergen"
21
+ expect(ds.metadata['Title']).to eql 'My amazing icon!'
22
+ expect(ds.metadata['Author']).to eql "Willem van Bergen"
23
23
  end
24
24
 
25
25
  it "should load compressed zTXt chunks correctly" do
26
26
  filename = resource_file('ztxt_chunk.png')
27
27
  ds = ChunkyPNG::Datastream.from_file(filename)
28
- ds.metadata['Title'].should == 'PngSuite'
29
- ds.metadata['Copyright'].should == "Copyright Willem van Schaik, Singapore 1995-96"
28
+ expect(ds.metadata['Title']).to eql 'PngSuite'
29
+ expect(ds.metadata['Copyright']).to eql "Copyright Willem van Schaik, Singapore 1995-96"
30
30
  end
31
31
  end
32
32
  end
@@ -2,30 +2,30 @@ require 'spec_helper'
2
2
 
3
3
  describe ChunkyPNG::Dimension do
4
4
  subject { ChunkyPNG::Dimension.new(2, 3) }
5
-
5
+
6
6
  it { should respond_to(:width) }
7
7
  it { should respond_to(:height) }
8
-
8
+
9
9
  describe '#area' do
10
10
  it "should calculate the area correctly" do
11
- subject.area.should == 6
11
+ expect(subject.area).to eql 6
12
12
  end
13
13
  end
14
14
  end
15
15
 
16
16
  describe 'ChunkyPNG.Dimension' do
17
17
  subject { ChunkyPNG::Dimension.new(1, 2) }
18
-
18
+
19
19
  it "should create a dimension from a 2-item array" do
20
- ChunkyPNG::Dimension([1, 2]).should == subject
21
- ChunkyPNG::Dimension(['1', '2']).should == subject
20
+ expect(ChunkyPNG::Dimension([1, 2])).to eql subject
21
+ expect(ChunkyPNG::Dimension(['1', '2'])).to eql subject
22
22
  end
23
-
23
+
24
24
  it "should create a dimension from a hash with x and y keys" do
25
- ChunkyPNG::Dimension(:width => 1, :height => 2).should == subject
26
- ChunkyPNG::Dimension('width' => '1', 'height' => '2').should == subject
25
+ expect(ChunkyPNG::Dimension(:width => 1, :height => 2)).to eql subject
26
+ expect(ChunkyPNG::Dimension('width' => '1', 'height' => '2')).to eql subject
27
27
  end
28
-
28
+
29
29
  it "should create a dimension from a point-like string" do
30
30
  [
31
31
  ChunkyPNG::Dimension('1,2'),
@@ -35,14 +35,14 @@ describe 'ChunkyPNG.Dimension' do
35
35
  ChunkyPNG::Dimension("[1\t2}"),
36
36
  ].all? { |point| point == subject }
37
37
  end
38
-
38
+
39
39
  it "should create a dimension from an object that responds to width and height" do
40
40
  mock_object = Struct.new(:width, :height).new(1, 2)
41
- ChunkyPNG::Dimension(mock_object).should == subject
41
+ expect(ChunkyPNG::Dimension(mock_object)).to eql subject
42
42
  end
43
-
43
+
44
44
  it "should raise an exception if the input is not understood" do
45
- lambda { ChunkyPNG::Dimension(Object.new) }.should raise_error(ArgumentError)
46
- lambda { ChunkyPNG::Dimension(1, 2, 3) }.should raise_error(ArgumentError)
45
+ expect { ChunkyPNG::Dimension(Object.new) }.to raise_error(ArgumentError)
46
+ expect { ChunkyPNG::Dimension(1, 2, 3) }.to raise_error(ArgumentError)
47
47
  end
48
48
  end
@@ -5,8 +5,8 @@ describe ChunkyPNG::Image do
5
5
 
6
6
  it "should load metadata from an existing file" do
7
7
  image = ChunkyPNG::Image.from_file(resource_file('text_chunk.png'))
8
- image.metadata['Title'].should == 'My amazing icon!'
9
- image.metadata['Author'].should == 'Willem van Bergen'
8
+ expect(image.metadata['Title']).to eql 'My amazing icon!'
9
+ expect(image.metadata['Author']).to eql 'Willem van Bergen'
10
10
  end
11
11
 
12
12
  it "should write metadata to the file correctly" do
@@ -18,8 +18,8 @@ describe ChunkyPNG::Image do
18
18
  image.save(filename)
19
19
 
20
20
  metadata = ChunkyPNG::Datastream.from_file(filename).metadata
21
- metadata['Title'].should == 'My amazing icon!'
22
- metadata['Author'].should == 'Willem van Bergen'
21
+ expect(metadata['Title']).to eql 'My amazing icon!'
22
+ expect(metadata['Author']).to eql 'Willem van Bergen'
23
23
  end
24
24
 
25
25
  it "should load empty images correctly" do
@@ -1,42 +1,42 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe ChunkyPNG::Point do
4
-
4
+
5
5
  subject { ChunkyPNG::Point.new(1, 2) }
6
-
6
+
7
7
  it { should respond_to(:x) }
8
8
  it { should respond_to(:y) }
9
-
9
+
10
10
  describe '#within_bounds?' do
11
11
  it { should be_within_bounds(2, 3) }
12
12
  it { should_not be_within_bounds('1x3') }
13
13
  it { should_not be_within_bounds(2, 2) }
14
14
  it { should_not be_within_bounds('[1 2]') }
15
15
  end
16
-
16
+
17
17
  describe '#<=>' do
18
18
  it "should return 0 if the coordinates are identical" do
19
- (subject <=> ChunkyPNG::Point.new(1, 2)).should == 0
19
+ expect((subject <=> ChunkyPNG::Point.new(1, 2))).to eql 0
20
20
  end
21
21
 
22
22
  it "should return -1 if the y coordinate is smaller than the other one" do
23
- (subject <=> ChunkyPNG::Point.new(1, 3)).should == -1
24
- (subject <=> ChunkyPNG::Point.new(0, 3)).should == -1 # x doesn't matter
25
- (subject <=> ChunkyPNG::Point.new(2, 3)).should == -1 # x doesn't matter
23
+ expect((subject <=> ChunkyPNG::Point.new(1, 3))).to eql -1
24
+ expect((subject <=> ChunkyPNG::Point.new(0, 3))).to eql -1 # x doesn't matter
25
+ expect((subject <=> ChunkyPNG::Point.new(2, 3))).to eql -1 # x doesn't matter
26
26
  end
27
27
 
28
28
  it "should return 1 if the y coordinate is larger than the other one" do
29
- (subject <=> ChunkyPNG::Point.new(1, 0)).should == 1
30
- (subject <=> ChunkyPNG::Point.new(0, 0)).should == 1 # x doesn't matter
31
- (subject <=> ChunkyPNG::Point.new(2, 0)).should == 1 # x doesn't matter
29
+ expect((subject <=> ChunkyPNG::Point.new(1, 0))).to eql 1
30
+ expect((subject <=> ChunkyPNG::Point.new(0, 0))).to eql 1 # x doesn't matter
31
+ expect((subject <=> ChunkyPNG::Point.new(2, 0))).to eql 1 # x doesn't matter
32
32
  end
33
33
 
34
34
  it "should return -1 if the x coordinate is smaller and y is the same" do
35
- (subject <=> ChunkyPNG::Point.new(2, 2)).should == -1
35
+ expect((subject <=> ChunkyPNG::Point.new(2, 2))).to eql -1
36
36
  end
37
37
 
38
38
  it "should return 1 if the x coordinate is larger and y is the same" do
39
- (subject <=> ChunkyPNG::Point.new(0, 2)).should == 1
39
+ expect((subject <=> ChunkyPNG::Point.new(0, 2))).to eql 1
40
40
  end
41
41
  end
42
42
  end
@@ -44,22 +44,22 @@ end
44
44
  describe 'ChunkyPNG.Point' do
45
45
  subject { ChunkyPNG::Point.new(1, 2) }
46
46
 
47
-
47
+
48
48
  it "should create a point from a 2-item array" do
49
- ChunkyPNG::Point([1, 2]).should == subject
50
- ChunkyPNG::Point(['1', '2']).should == subject
49
+ expect(ChunkyPNG::Point([1, 2])).to eql subject
50
+ expect(ChunkyPNG::Point(['1', '2'])).to eql subject
51
51
  end
52
-
52
+
53
53
  it "should create a point from a hash with x and y keys" do
54
- ChunkyPNG::Point(:x => 1, :y => 2).should == subject
55
- ChunkyPNG::Point('x' => '1', 'y' => '2').should == subject
54
+ expect(ChunkyPNG::Point(:x => 1, :y => 2)).to eql subject
55
+ expect(ChunkyPNG::Point('x' => '1', 'y' => '2')).to eql subject
56
56
  end
57
57
 
58
58
  it "should create a point from a ChunkyPNG::Dimension object" do
59
59
  dimension = ChunkyPNG::Dimension.new(1, 2)
60
60
  ChunkyPNG::Point(dimension) == subject
61
61
  end
62
-
62
+
63
63
  it "should create a point from a point-like string" do
64
64
  [
65
65
  ChunkyPNG::Point('1,2'),
@@ -69,14 +69,14 @@ describe 'ChunkyPNG.Point' do
69
69
  ChunkyPNG::Point("[1 2}"),
70
70
  ].all? { |point| point == subject }
71
71
  end
72
-
72
+
73
73
  it "should create a point from an object that responds to x and y" do
74
74
  mock_object = Struct.new(:x, :y).new(1, 2)
75
- ChunkyPNG::Point(mock_object).should == subject
75
+ expect(ChunkyPNG::Point(mock_object)).to eql subject
76
76
  end
77
-
77
+
78
78
  it "should raise an exception if the input is not understood" do
79
- lambda { ChunkyPNG::Point(Object.new) }.should raise_error(ArgumentError)
80
- lambda { ChunkyPNG::Point(1, 2, 3) }.should raise_error(ArgumentError)
79
+ expect { ChunkyPNG::Point(Object.new) }.to raise_error(ArgumentError)
80
+ expect { ChunkyPNG::Point(1, 2, 3) }.to raise_error(ArgumentError)
81
81
  end
82
82
  end
@@ -4,18 +4,18 @@ begin
4
4
  require 'chunky_png/rmagick'
5
5
 
6
6
  describe ChunkyPNG::RMagick do
7
-
7
+
8
8
  it "should import an image from RMagick correctly" do
9
9
  image = Magick::Image.read(resource_file('composited.png')).first
10
10
  canvas = ChunkyPNG::RMagick.import(image)
11
- canvas.should == reference_canvas('composited')
11
+ expect(canvas).to eql reference_canvas('composited')
12
12
  end
13
-
13
+
14
14
  it "should export an image to RMagick correctly" do
15
15
  canvas = reference_canvas('composited')
16
16
  image = ChunkyPNG::RMagick.export(canvas)
17
17
  image.format = 'PNG32'
18
- canvas.should == ChunkyPNG::Canvas.from_blob(image.to_blob)
18
+ expect(canvas).to eql ChunkyPNG::Canvas.from_blob(image.to_blob)
19
19
  end
20
20
  end
21
21
  rescue LoadError => e
@@ -4,75 +4,80 @@ describe ChunkyPNG::Vector do
4
4
  subject { ChunkyPNG::Vector.new([ChunkyPNG::Point.new(2, 5), ChunkyPNG::Point.new(1, 3), ChunkyPNG::Point.new(4, 6)]) }
5
5
 
6
6
  it { should respond_to(:points) }
7
- it { should have(3).items }
7
+
8
+ describe '#length' do
9
+ it "shopuld have 3 items" do
10
+ expect(subject.length).to eql 3
11
+ end
12
+ end
8
13
 
9
14
  describe '#x_range' do
10
15
  it "should get the right range of x values" do
11
- subject.x_range.should == (1..4)
16
+ expect(subject.x_range).to eql (1..4)
12
17
  end
13
-
18
+
14
19
  it "should find the minimum x-coordinate" do
15
- subject.min_x.should == 1
20
+ expect(subject.min_x).to eql 1
16
21
  end
17
-
22
+
18
23
  it "should find the maximum x-coordinate" do
19
- subject.max_x.should == 4
24
+ expect(subject.max_x).to eql 4
20
25
  end
21
-
26
+
22
27
  it "should calculate the width correctly" do
23
- subject.width.should == 4
28
+ expect(subject.width).to eql 4
24
29
  end
25
30
  end
26
31
 
27
32
  describe '#y_range' do
28
33
  it "should get the right range of y values" do
29
- subject.y_range.should == (3..6)
34
+ expect(subject.y_range).to eql (3..6)
30
35
  end
31
-
36
+
32
37
  it "should find the minimum x-coordinate" do
33
- subject.min_y.should == 3
38
+ expect(subject.min_y).to eql 3
34
39
  end
35
-
40
+
36
41
  it "should find the maximum x-coordinate" do
37
- subject.max_y.should == 6
42
+ expect(subject.max_y).to eql 6
38
43
  end
39
-
44
+
40
45
  it "should calculate the height correctly" do
41
- subject.height.should == 4
46
+ expect(subject.height).to eql 4
42
47
  end
43
48
  end
44
-
49
+
45
50
  describe '#offset' do
46
51
  it "should return a ChunkyPNG::Point" do
47
- subject.offset.should be_kind_of(ChunkyPNG::Point)
52
+ expect(subject.offset).to be_kind_of(ChunkyPNG::Point)
48
53
  end
49
-
54
+
50
55
  it "should use the mininum x and y coordinates as values for the point" do
51
- subject.offset.x.should == subject.min_x
52
- subject.offset.y.should == subject.min_y
56
+ expect(subject.offset.x).to eql subject.min_x
57
+ expect(subject.offset.y).to eql subject.min_y
53
58
  end
54
59
  end
55
60
 
56
61
  describe '#dimension' do
57
62
  it "should return a ChunkyPNG::Dimension" do
58
- subject.dimension.should be_kind_of(ChunkyPNG::Dimension)
63
+ expect(subject.dimension).to be_kind_of(ChunkyPNG::Dimension)
59
64
  end
60
-
65
+
61
66
  it "should use the width and height of the vector for the dimension" do
62
- subject.dimension.width.should == subject.width
63
- subject.dimension.height.should == subject.height
67
+ expect(subject.dimension.width).to eql subject.width
68
+ expect(subject.dimension.height).to eql subject.height
64
69
  end
65
70
  end
66
71
 
67
72
  describe '#edges' do
68
73
  it "should get three edges when closing the path" do
69
- subject.edges(true).to_a.should == [[ChunkyPNG::Point.new(2, 5), ChunkyPNG::Point.new(1, 3)],
74
+ expect(subject.edges(true).to_a).to eql [[ChunkyPNG::Point.new(2, 5), ChunkyPNG::Point.new(1, 3)],
70
75
  [ChunkyPNG::Point.new(1, 3), ChunkyPNG::Point.new(4, 6)],
71
76
  [ChunkyPNG::Point.new(4, 6), ChunkyPNG::Point.new(2, 5)]]
72
77
  end
73
78
 
74
79
  it "should get two edges when not closing the path" do
75
- subject.edges(false).to_a.should == [[ChunkyPNG::Point.new(2, 5), ChunkyPNG::Point.new(1, 3)],
80
+ expect(subject.edges(false).to_a).to eql [[ChunkyPNG::Point.new(2, 5), ChunkyPNG::Point.new(1, 3)],
76
81
  [ChunkyPNG::Point.new(1, 3), ChunkyPNG::Point.new(4, 6)]]
77
82
  end
78
83
  end
@@ -80,25 +85,25 @@ end
80
85
 
81
86
  describe 'ChunkyPNG.Vector' do
82
87
  let(:example) { ChunkyPNG::Vector.new([ChunkyPNG::Point.new(2, 4), ChunkyPNG::Point.new(1, 2), ChunkyPNG::Point.new(3, 6)]) }
83
-
88
+
84
89
  it "should return an empty vector when given an empty array" do
85
- ChunkyPNG::Vector().should == ChunkyPNG::Vector.new([])
86
- ChunkyPNG::Vector(*[]).should == ChunkyPNG::Vector.new([])
90
+ expect(ChunkyPNG::Vector()).to eql ChunkyPNG::Vector.new([])
91
+ expect(ChunkyPNG::Vector(*[])).to eql ChunkyPNG::Vector.new([])
87
92
  end
88
93
 
89
94
  it "should raise an error when an odd number of numerics is given" do
90
- lambda { ChunkyPNG::Vector(1, 2, 3) }.should raise_error(ArgumentError)
95
+ expect { ChunkyPNG::Vector(1, 2, 3) }.to raise_error(ArgumentError)
91
96
  end
92
97
 
93
98
  it "should create a vector from a string" do
94
- ChunkyPNG::Vector('(2,4) (1,2) (3,6)').should == example
99
+ expect(ChunkyPNG::Vector('(2,4) (1,2) (3,6)')).to eql example
95
100
  end
96
-
101
+
97
102
  it "should create a vector from a flat array" do
98
- ChunkyPNG::Vector(2,4,1,2,3,6).should == example
103
+ expect(ChunkyPNG::Vector(2,4,1,2,3,6)).to eql example
99
104
  end
100
105
 
101
106
  it "should create a vector from a nested array" do
102
- ChunkyPNG::Vector('(2,4)', [1, 2], :x => 3, :y => 6).should == example
107
+ expect(ChunkyPNG::Vector('(2,4)', [1, 2], :x => 3, :y => 6)).to eql example
103
108
  end
104
109
  end
@@ -1,8 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe ChunkyPNG do
4
-
5
4
  it "should have a VERSION constant" do
6
- ChunkyPNG.const_defined?('VERSION').should be_true
5
+ expect(ChunkyPNG.const_defined?('VERSION')).to eql true
7
6
  end
8
7
  end
@@ -1,120 +1,120 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe 'PNG testuite' do
4
-
4
+
5
5
  context 'Decoding broken images' do
6
6
  png_suite_files(:broken).each do |file|
7
7
  it "should report #{File.basename(file)} as broken" do
8
- lambda { ChunkyPNG::Image.from_file(file) }.should raise_error(ChunkyPNG::Exception)
8
+ expect { ChunkyPNG::Image.from_file(file) }.to raise_error(ChunkyPNG::Exception)
9
9
  end
10
10
  end
11
11
  end
12
-
12
+
13
13
  context 'Decoding supported images' do
14
14
  png_suite_files(:basic, '*.png').each do |file|
15
15
 
16
16
  reference = file.sub(/\.png$/, '.rgba')
17
17
  color_mode = file.match(/[in](\d)[apgc](\d\d)\.png$/)[1].to_i
18
18
  bit_depth = file.match(/[in](\d)[apgc](\d\d)\.png$/)[2].to_i
19
-
19
+
20
20
  it "should decode #{File.basename(file)} (color mode: #{color_mode}, bit depth: #{bit_depth}) exactly the same as the reference image" do
21
21
  decoded = ChunkyPNG::Canvas.from_file(file)
22
- File.open(reference, 'rb') { |f| decoded.to_rgba_stream.should == f.read }
22
+ File.open(reference, 'rb') { |f| expect(decoded.to_rgba_stream).to eql f.read }
23
23
  end
24
24
  end
25
25
  end
26
-
26
+
27
27
  context 'Decoding text chunks' do
28
-
28
+
29
29
  it "should not find metadata in a file without text chunks" do
30
30
  image = ChunkyPNG::Image.from_file(png_suite_file(:metadata, 'cm0n0g04.png'))
31
- image.metadata.should be_empty
31
+ expect(image.metadata).to be_empty
32
32
  end
33
-
33
+
34
34
  # it "should find metadata in a file with uncompressed text chunks" do
35
35
  # image = ChunkyPNG::Image.from_file(png_suite_file(:metadata, 'cm7n0g04.png'))
36
36
  # image.metadata.should_not be_empty
37
37
  # end
38
- #
38
+ #
39
39
  # it "should find metadata in a file with compressed text chunks" do
40
40
  # image = ChunkyPNG::Image.from_file(png_suite_file(:metadata, 'cm9n0g04.png'))
41
41
  # image.metadata.should_not be_empty
42
42
  # end
43
43
  end
44
-
44
+
45
45
  context 'Decoding filter methods' do
46
46
  png_suite_files(:filtering, '*_reference.png').each do |reference_file|
47
47
 
48
48
  file = reference_file.sub(/_reference\.png$/, '.png')
49
49
  filter_method = file.match(/f(\d\d)[a-z0-9]+\.png/)[1].to_i
50
-
50
+
51
51
  it "should decode #{File.basename(file)} (filter method: #{filter_method}) exactly the same as the reference image" do
52
52
  decoded = ChunkyPNG::Canvas.from_file(file)
53
53
  reference = ChunkyPNG::Canvas.from_file(reference_file)
54
- decoded.should == reference
54
+ expect(decoded).to eql reference
55
55
  end
56
56
  end
57
57
  end
58
-
58
+
59
59
  context 'Decoding different chunk splits' do
60
60
  it "should decode grayscale images successfully regardless of the data chunk ordering and splitting" do
61
61
  reference = ChunkyPNG::Datastream.from_file(png_suite_file(:chunk_ordering, 'oi1n0g16.png')).imagedata
62
- ChunkyPNG::Datastream.from_file(png_suite_file(:chunk_ordering, 'oi2n0g16.png')).imagedata.should == reference
63
- ChunkyPNG::Datastream.from_file(png_suite_file(:chunk_ordering, 'oi4n0g16.png')).imagedata.should == reference
64
- ChunkyPNG::Datastream.from_file(png_suite_file(:chunk_ordering, 'oi9n0g16.png')).imagedata.should == reference
62
+ expect(ChunkyPNG::Datastream.from_file(png_suite_file(:chunk_ordering, 'oi2n0g16.png')).imagedata).to eql reference
63
+ expect(ChunkyPNG::Datastream.from_file(png_suite_file(:chunk_ordering, 'oi4n0g16.png')).imagedata).to eql reference
64
+ expect(ChunkyPNG::Datastream.from_file(png_suite_file(:chunk_ordering, 'oi9n0g16.png')).imagedata).to eql reference
65
65
  end
66
-
66
+
67
67
  it "should decode color images successfully regardless of the data chunk ordering and splitting" do
68
68
  reference = ChunkyPNG::Datastream.from_file(png_suite_file(:chunk_ordering, 'oi1n2c16.png')).imagedata
69
- ChunkyPNG::Datastream.from_file(png_suite_file(:chunk_ordering, 'oi2n2c16.png')).imagedata.should == reference
70
- ChunkyPNG::Datastream.from_file(png_suite_file(:chunk_ordering, 'oi4n2c16.png')).imagedata.should == reference
71
- ChunkyPNG::Datastream.from_file(png_suite_file(:chunk_ordering, 'oi9n2c16.png')).imagedata.should == reference
69
+ expect(ChunkyPNG::Datastream.from_file(png_suite_file(:chunk_ordering, 'oi2n2c16.png')).imagedata).to eql reference
70
+ expect(ChunkyPNG::Datastream.from_file(png_suite_file(:chunk_ordering, 'oi4n2c16.png')).imagedata).to eql reference
71
+ expect(ChunkyPNG::Datastream.from_file(png_suite_file(:chunk_ordering, 'oi9n2c16.png')).imagedata).to eql reference
72
72
  end
73
73
  end
74
-
74
+
75
75
  context 'Decoding different compression levels' do
76
76
  it "should decode the image successfully regardless of the compression level" do
77
77
  reference = ChunkyPNG::Datastream.from_file(png_suite_file(:compression_levels, 'z00n2c08.png')).imagedata
78
- ChunkyPNG::Datastream.from_file(png_suite_file(:compression_levels, 'z03n2c08.png')).imagedata.should == reference
79
- ChunkyPNG::Datastream.from_file(png_suite_file(:compression_levels, 'z06n2c08.png')).imagedata.should == reference
80
- ChunkyPNG::Datastream.from_file(png_suite_file(:compression_levels, 'z09n2c08.png')).imagedata.should == reference
78
+ expect(ChunkyPNG::Datastream.from_file(png_suite_file(:compression_levels, 'z03n2c08.png')).imagedata).to eql reference
79
+ expect(ChunkyPNG::Datastream.from_file(png_suite_file(:compression_levels, 'z06n2c08.png')).imagedata).to eql reference
80
+ expect(ChunkyPNG::Datastream.from_file(png_suite_file(:compression_levels, 'z09n2c08.png')).imagedata).to eql reference
81
81
  end
82
82
  end
83
-
83
+
84
84
  context 'Decoding transparency' do
85
85
  png_suite_files(:transparency, 'tp0*.png').each do |file|
86
86
  it "should not have transparency in #{File.basename(file)}" do
87
- ChunkyPNG::Color.a(ChunkyPNG::Image.from_file(file)[0,0]).should == 255
87
+ expect(ChunkyPNG::Color.a(ChunkyPNG::Image.from_file(file)[0,0])).to eql 255
88
88
  end
89
89
  end
90
-
90
+
91
91
  png_suite_files(:transparency, 'tp1*.png').each do |file|
92
92
  it "should have transparency in #{File.basename(file)}" do
93
- ChunkyPNG::Color.a(ChunkyPNG::Image.from_file(file)[0,0]).should == 0
93
+ expect(ChunkyPNG::Color.a(ChunkyPNG::Image.from_file(file)[0,0])).to eql 0
94
94
  end
95
95
  end
96
-
96
+
97
97
  png_suite_files(:transparency, 'tb*.png').each do |file|
98
98
  it "should have transparency in #{File.basename(file)}" do
99
- ChunkyPNG::Color.a(ChunkyPNG::Image.from_file(file)[0,0]).should == 0
99
+ expect(ChunkyPNG::Color.a(ChunkyPNG::Image.from_file(file)[0,0])).to eql 0
100
100
  end
101
101
  end
102
102
  end
103
-
103
+
104
104
  context 'Decoding different sizes' do
105
-
105
+
106
106
  png_suite_files(:sizes, '*n*.png').each do |file|
107
107
  dimension = file.match(/s(\d\d)n\dp\d\d/)[1].to_i
108
-
108
+
109
109
  it "should create a canvas with a #{dimension}x#{dimension} size" do
110
110
  canvas = ChunkyPNG::Image.from_file(file)
111
- canvas.width.should == dimension
112
- canvas.height.should == dimension
111
+ expect(canvas.width).to eql dimension
112
+ expect(canvas.height).to eql dimension
113
113
  end
114
-
114
+
115
115
  it "should decode the #{dimension}x#{dimension} interlaced image exactly the same the non-interlaced version" do
116
116
  interlaced_file = file.sub(/n3p(\d\d)\.png$/, 'i3p\\1.png')
117
- ChunkyPNG::Image.from_file(interlaced_file).should == ChunkyPNG::Image.from_file(file)
117
+ expect(ChunkyPNG::Image.from_file(interlaced_file)).to eql ChunkyPNG::Image.from_file(file)
118
118
  end
119
119
  end
120
120
  end