Skip imagemagick tests on Travis.

This commit is contained in:
Guo Xiang Tan 2018-07-17 17:11:05 +08:00
parent 3553375dd2
commit d839a42bf9
1 changed files with 48 additions and 46 deletions

View File

@ -4,64 +4,66 @@ describe OptimizedImage do
let(:upload) { build(:upload) } let(:upload) { build(:upload) }
before { upload.id = 42 } before { upload.id = 42 }
describe '.crop' do unless ENV["TRAVIS"]
it 'should work correctly' do describe '.crop' do
tmp_path = "/tmp/cropped.png" it 'should work correctly' do
tmp_path = "/tmp/cropped.png"
begin begin
OptimizedImage.crop( OptimizedImage.crop(
"#{Rails.root}/spec/fixtures/images/logo.png", "#{Rails.root}/spec/fixtures/images/logo.png",
tmp_path, tmp_path,
5, 5,
5 5
) )
expect(File.read(tmp_path)).to eq( expect(File.read(tmp_path)).to eq(
File.read("#{Rails.root}/spec/fixtures/images/cropped.png") File.read("#{Rails.root}/spec/fixtures/images/cropped.png")
) )
ensure ensure
File.delete(tmp_path) if File.exists?(tmp_path) File.delete(tmp_path) if File.exists?(tmp_path)
end
end end
end end
end
describe '.resize' do describe '.resize' do
it 'should work correctly' do it 'should work correctly' do
tmp_path = "/tmp/resized.png" tmp_path = "/tmp/resized.png"
begin begin
OptimizedImage.resize( OptimizedImage.resize(
"#{Rails.root}/spec/fixtures/images/logo.png", "#{Rails.root}/spec/fixtures/images/logo.png",
tmp_path, tmp_path,
5, 5,
5 5
) )
expect(File.read(tmp_path)).to eq( expect(File.read(tmp_path)).to eq(
File.read("#{Rails.root}/spec/fixtures/images/resized.png") File.read("#{Rails.root}/spec/fixtures/images/resized.png")
) )
ensure ensure
File.delete(tmp_path) if File.exists?(tmp_path) File.delete(tmp_path) if File.exists?(tmp_path)
end
end end
end end
end
describe '.downsize' do describe '.downsize' do
it 'should work correctly' do it 'should work correctly' do
tmp_path = "/tmp/downsized.png" tmp_path = "/tmp/downsized.png"
begin begin
OptimizedImage.downsize( OptimizedImage.downsize(
"#{Rails.root}/spec/fixtures/images/logo.png", "#{Rails.root}/spec/fixtures/images/logo.png",
tmp_path, tmp_path,
"100x100\>" "100x100\>"
) )
expect(File.read(tmp_path)).to eq( expect(File.read(tmp_path)).to eq(
File.read("#{Rails.root}/spec/fixtures/images/downsized.png") File.read("#{Rails.root}/spec/fixtures/images/downsized.png")
) )
ensure ensure
File.delete(tmp_path) if File.exists?(tmp_path) File.delete(tmp_path) if File.exists?(tmp_path)
end
end end
end end
end end