Sha256: 108149177d7f552fed4010fc253338fba437076bbd28f1012e9136d143d1be9b

Contents?: true

Size: 1.29 KB

Versions: 3

Compression:

Stored size: 1.29 KB

Contents

$LOAD_PATH.unshift File.expand_path('../../../lib', __FILE__)
require 'rspec'
require 'image_optim/image_path'

describe ImageOptim::ImagePath do
  ImagePath = ImageOptim::ImagePath

  describe 'convert' do
    it 'should return ImagePath for string' do
      path = 'a'

      expect(ImagePath.convert(path)).to be_a(ImageOptim::ImagePath)
      expect(ImagePath.convert(path)).to eq(ImageOptim::ImagePath.new(path))

      expect(ImagePath.convert(path)).not_to eq(path)
      expect(ImagePath.convert(path)).not_to be(path)
    end

    it 'should return ImagePath for Pathname' do
      pathname = Pathname.new('a')

      expect(ImagePath.convert(pathname)).to be_a(ImageOptim::ImagePath)
      expect(ImagePath.convert(pathname)).to eq(ImageOptim::ImagePath.new(pathname))

      expect(ImagePath.convert(pathname)).to eq(pathname)
      expect(ImagePath.convert(pathname)).not_to be(pathname)
    end

    it 'should return same instance for ImagePath' do
      image_path = ImageOptim::ImagePath.new('a')

      expect(ImagePath.convert(image_path)).to be_a(ImageOptim::ImagePath)
      expect(ImagePath.convert(image_path)).to eq(ImageOptim::ImagePath.new(image_path))

      expect(ImagePath.convert(image_path)).to eq(image_path)
      expect(ImagePath.convert(image_path)).to be(image_path)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
image_optim-0.16.0 spec/image_optim/image_path_spec.rb
image_optim-0.15.0 spec/image_optim/image_path_spec.rb
image_optim-0.14.0 spec/image_optim/image_path_spec.rb