|
55 | 55 | end
|
56 | 56 | end
|
57 | 57 | end
|
| 58 | + |
| 59 | + describe '#optimized?' do |
| 60 | + let(:src){ instance_double(ImageOptim::Path, src_options) } |
| 61 | + let(:dst){ instance_double(ImageOptim::Path, dst_options) } |
| 62 | + let(:src_options){ {:size? => 10, :size => 10} } |
| 63 | + let(:dst_options){ {:size? => 9, :size => 9} } |
| 64 | + let(:instance){ described_class.new(ImageOptim.new, instance_options) } |
| 65 | + let(:instance_options){ {} } |
| 66 | + |
| 67 | + subject{ instance.optimized?(src, dst) } |
| 68 | + |
| 69 | + context 'when interlace option is enabled' do |
| 70 | + let(:instance_options){ {:interlace => true} } |
| 71 | + |
| 72 | + context 'when dst is empty' do |
| 73 | + let(:dst_options){ {:size? => nil} } |
| 74 | + it{ is_expected.to be_falsy } |
| 75 | + end |
| 76 | + |
| 77 | + context 'when dst is not empty' do |
| 78 | + let(:dst_options){ {:size? => 20, :size => 20} } |
| 79 | + it{ is_expected.to be_truthy } |
| 80 | + end |
| 81 | + end |
| 82 | + |
| 83 | + context 'when interlace option is disabled' do |
| 84 | + let(:instance_options){ {:interlace => false} } |
| 85 | + |
| 86 | + context 'when dst is empty' do |
| 87 | + let(:dst_options){ {:size? => nil} } |
| 88 | + it{ is_expected.to be_falsy } |
| 89 | + end |
| 90 | + |
| 91 | + context 'when dst is greater than or equal to src' do |
| 92 | + let(:dst_options){ {:size? => 10, :size => 10} } |
| 93 | + it{ is_expected.to be_falsy } |
| 94 | + end |
| 95 | + |
| 96 | + context 'when dst is less than src' do |
| 97 | + let(:dst_options){ {:size? => 9, :size => 9} } |
| 98 | + it{ is_expected.to be_truthy } |
| 99 | + end |
| 100 | + end |
| 101 | + end |
58 | 102 | end
|
0 commit comments