Sha256: 3e5f4398e2b73e9d38b390af62876302419d969a7a47541f8270a45228ffe1a8

Contents?: true

Size: 1.52 KB

Versions: 14

Compression:

Stored size: 1.52 KB

Contents

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

14 entries across 14 versions & 2 rubygems

Version Path
image_optim-0.26.3 spec/image_optim/optimized_path_spec.rb
image_optim-0.26.2 spec/image_optim/optimized_path_spec.rb
discourse_image_optim-0.26.2 spec/image_optim/optimized_path_spec.rb
discourse_image_optim-0.26.1 spec/image_optim/optimized_path_spec.rb
image_optim-0.26.1 spec/image_optim/optimized_path_spec.rb
image_optim-0.26.0 spec/image_optim/optimized_path_spec.rb
image_optim-0.25.0 spec/image_optim/optimized_path_spec.rb
discourse_image_optim-0.24.5 spec/image_optim/optimized_path_spec.rb
image_optim-0.24.3 spec/image_optim/optimized_path_spec.rb
discourse_image_optim-0.24.4 spec/image_optim/optimized_path_spec.rb
image_optim-0.24.2 spec/image_optim/optimized_path_spec.rb
image_optim-0.24.1 spec/image_optim/optimized_path_spec.rb
image_optim-0.24.0 spec/image_optim/optimized_path_spec.rb
image_optim-0.23.0 spec/image_optim/optimized_path_spec.rb