Sha256: ecc4a447c430cf77fbbc401b6cc7ba318133fc3f366fda52e0de180ec589a713

Contents?: true

Size: 1.86 KB

Versions: 6

Compression:

Stored size: 1.86 KB

Contents

require 'spec_helper'

describe GeoWorks::Processors::Image do
  before do
    class TestProcessor
      include GeoWorks::Processors::Image
    end
  end

  after { Object.send(:remove_const, :TestProcessor) }

  subject { TestProcessor.new }

  let(:shell) { double }
  let(:output_file_png) { 'output/geo.png' }
  let(:output_file) { output_file_png }
  let(:file_name) { 'files/geo.tif' }
  let(:options) { { output_size: '150 150' } }

  describe '#convert' do
    let(:args) {
      [['convert', 'files/geo.tif', '-resize', '150x150', '-extent',
        '150x150', '-background', 'white', '-gravity', 'center',
        'output/geo.png'], { whiny: false, stderr: false }]
    }

    before do
      allow(MiniMagick::Shell).to receive(:new).and_return(shell)
    end

    it 'transforms the image and saves it as a PNG' do
      expect(shell).to receive(:run).with(*args).and_return('output message')
      subject.class.convert(file_name, output_file_png, options)
    end
  end

  describe '#trim' do
    let(:args) { [['convert', 'files/geo.tif', '-trim', 'output/geo.png'], { whiny: true }] }

    before do
      allow(MiniMagick::Shell).to receive(:new).and_return(shell)
    end
    it 'transforms the image and saves it as a PNG' do
      expect(shell).to receive(:run).with(*args).and_return('output message')
      subject.class.trim(file_name, output_file_png, options)
    end
  end

  describe '#center' do
    let(:args) {
      [['convert', '-size', '150x150', 'xc:white', 'files/geo.tif',
        '-gravity', 'center', '-composite', 'output/geo.png'],
       { whiny: true }]
    }

    before do
      allow(MiniMagick::Shell).to receive(:new).and_return(shell)
    end
    it 'transforms the image and saves it as a PNG' do
      expect(shell).to receive(:run).with(*args).and_return('output message')
      subject.class.center(file_name, output_file_png, options)
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
geo_works-0.2.0 spec/processors/geo_works/processors/image_spec.rb
geo_works-0.1.4 spec/processors/geo_works/processors/image_spec.rb
geo_works-0.1.3 spec/processors/geo_works/processors/image_spec.rb
geo_works-0.1.2 spec/processors/geo_works/processors/image_spec.rb
geo_works-0.1.1 spec/processors/geo_works/processors/image_spec.rb
geo_works-0.1.0 spec/processors/geo_works/processors/image_spec.rb