Sha256: 2728bf8c0b16dec4e7e8877fdf1963efc5ea23c8c1e28871461fb0ca20c400e1

Contents?: true

Size: 1.03 KB

Versions: 2

Compression:

Stored size: 1.03 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

describe LinkThumbnailer::ImageComparators::Size do

  let(:image)     { double(size: [20, 20]) }
  let(:instance)  { described_class.new(image) }

  describe '#call' do

    let(:other)   { double(size: other_size) }
    let(:action)  { instance.call(other) }

    context 'when other has a better image' do

      let(:other_size) { [10, 10] }

      it { expect(action).to eq(-1) }

    end

    context 'when other has an identical image' do

      let(:other_size) { [20, 20] }

      it { expect(action).to eq(0) }

    end

    context 'when other has a weaker image' do

      let(:other_size) { [30, 30] }

      it { expect(action).to eq(1) }

    end

    context 'when other image size could not be computed' do

      let(:other_size) { [] }

      it { expect(action).to eq(-1) }

    end

    context 'when self image size could not be computed' do

      let(:image) { double(size: []) }
      let(:other_size) { [10, 10] }

      it { expect(action).to eq(1) }

    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
link_thumbnailer-3.4.0 spec/image_comparators/size_spec.rb
link_thumbnailer-3.3.2 spec/image_comparators/size_spec.rb