From d839a42bf9f5b06d954296df0266a9c2ce42ccb5 Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Tue, 17 Jul 2018 17:11:05 +0800 Subject: [PATCH] Skip imagemagick tests on Travis. --- spec/models/optimized_image_spec.rb | 94 +++++++++++++++-------------- 1 file changed, 48 insertions(+), 46 deletions(-) diff --git a/spec/models/optimized_image_spec.rb b/spec/models/optimized_image_spec.rb index 7bd649bf1de..17c2fc20db2 100644 --- a/spec/models/optimized_image_spec.rb +++ b/spec/models/optimized_image_spec.rb @@ -4,64 +4,66 @@ describe OptimizedImage do let(:upload) { build(:upload) } before { upload.id = 42 } - describe '.crop' do - it 'should work correctly' do - tmp_path = "/tmp/cropped.png" + unless ENV["TRAVIS"] + describe '.crop' do + it 'should work correctly' do + tmp_path = "/tmp/cropped.png" - begin - OptimizedImage.crop( - "#{Rails.root}/spec/fixtures/images/logo.png", - tmp_path, - 5, - 5 - ) + begin + OptimizedImage.crop( + "#{Rails.root}/spec/fixtures/images/logo.png", + tmp_path, + 5, + 5 + ) - expect(File.read(tmp_path)).to eq( - File.read("#{Rails.root}/spec/fixtures/images/cropped.png") - ) - ensure - File.delete(tmp_path) if File.exists?(tmp_path) + expect(File.read(tmp_path)).to eq( + File.read("#{Rails.root}/spec/fixtures/images/cropped.png") + ) + ensure + File.delete(tmp_path) if File.exists?(tmp_path) + end end end - end - describe '.resize' do - it 'should work correctly' do - tmp_path = "/tmp/resized.png" + describe '.resize' do + it 'should work correctly' do + tmp_path = "/tmp/resized.png" - begin - OptimizedImage.resize( - "#{Rails.root}/spec/fixtures/images/logo.png", - tmp_path, - 5, - 5 - ) + begin + OptimizedImage.resize( + "#{Rails.root}/spec/fixtures/images/logo.png", + tmp_path, + 5, + 5 + ) - expect(File.read(tmp_path)).to eq( - File.read("#{Rails.root}/spec/fixtures/images/resized.png") - ) - ensure - File.delete(tmp_path) if File.exists?(tmp_path) + expect(File.read(tmp_path)).to eq( + File.read("#{Rails.root}/spec/fixtures/images/resized.png") + ) + ensure + File.delete(tmp_path) if File.exists?(tmp_path) + end end end - end - describe '.downsize' do - it 'should work correctly' do - tmp_path = "/tmp/downsized.png" + describe '.downsize' do + it 'should work correctly' do + tmp_path = "/tmp/downsized.png" - begin - OptimizedImage.downsize( - "#{Rails.root}/spec/fixtures/images/logo.png", - tmp_path, - "100x100\>" - ) + begin + OptimizedImage.downsize( + "#{Rails.root}/spec/fixtures/images/logo.png", + tmp_path, + "100x100\>" + ) - expect(File.read(tmp_path)).to eq( - File.read("#{Rails.root}/spec/fixtures/images/downsized.png") - ) - ensure - File.delete(tmp_path) if File.exists?(tmp_path) + expect(File.read(tmp_path)).to eq( + File.read("#{Rails.root}/spec/fixtures/images/downsized.png") + ) + ensure + File.delete(tmp_path) if File.exists?(tmp_path) + end end end end