Sha256: 8e3769e2c5babf65a1cd53f510d989591a6bf6dc4407d9d63beb37e0431abcd9

Contents?: true

Size: 1.55 KB

Versions: 12

Compression:

Stored size: 1.55 KB

Contents

# frozen_string_literal: true

require 'image_optim/optimized_path'

describe ImageOptim::OptimizedPath do
  describe '#initialize' do
    context 'when second argument is original' do
      subject{ described_class.new('a', 'b') }

      before do
        allow_any_instance_of(ImageOptim::Path).
          to receive(:size).and_return(616)
      end

      it 'delegates to optimized path as Path' do
        is_expected.to eq(ImageOptim::Path.new('a'))
      end

      it 'returns original path as Path for original' do
        expect(subject.original).to eq(ImageOptim::Path.new('b'))
      end

      it 'returns original size for original_size' do
        expect(subject.original_size).to eq(616)
      end
    end

    context 'when second argument is size' do
      subject{ described_class.new('a', 616) }

      it 'delegates to optimized path as Path' do
        is_expected.to eq(ImageOptim::Path.new('a'))
      end

      it 'returns optimized path as Path for original' do
        expect(subject.original).to eq(ImageOptim::Path.new('a'))
      end

      it 'returns size for original_size' do
        expect(subject.original_size).to eq(616)
      end
    end

    context 'when no second argument' do
      subject{ described_class.new('a') }

      it 'delegates to optimized path as Path' do
        is_expected.to eq(ImageOptim::Path.new('a'))
      end

      it 'returns nil for original' do
        expect(subject.original).to eq(nil)
      end

      it 'returns nil for original_size' do
        expect(subject.original_size).to eq(nil)
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
image_optim-0.31.4 spec/image_optim/optimized_path_spec.rb
image_optim-0.31.3 spec/image_optim/optimized_path_spec.rb
image_optim-0.31.2 spec/image_optim/optimized_path_spec.rb
image_optim-0.31.1 spec/image_optim/optimized_path_spec.rb
image_optim-0.31.0 spec/image_optim/optimized_path_spec.rb
image_optim-0.30.0 spec/image_optim/optimized_path_spec.rb
image_optim-0.29.0 spec/image_optim/optimized_path_spec.rb
image_optim-0.28.0 spec/image_optim/optimized_path_spec.rb
image_optim-0.27.1 spec/image_optim/optimized_path_spec.rb
image_optim-0.27.0 spec/image_optim/optimized_path_spec.rb
image_optim-0.26.5 spec/image_optim/optimized_path_spec.rb
image_optim-0.26.4 spec/image_optim/optimized_path_spec.rb