Sha256: a319cd81b0a7da6f9ac742627fd0405c95fb19dc52962a73a5e9bf895345acac

Contents?: true

Size: 1.21 KB

Versions: 2

Compression:

Stored size: 1.21 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(ImagePath)
      expect(ImagePath.convert(path)).to eq(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(ImagePath)
      expect(ImagePath.convert(pathname)).to eq(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 = ImagePath.new('a')

      expect(ImagePath.convert(image_path)).to be_a(ImagePath)
      expect(ImagePath.convert(image_path)).to eq(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

2 entries across 2 versions & 1 rubygems

Version Path
image_optim-0.17.1 spec/image_optim/image_path_spec.rb
image_optim-0.17.0 spec/image_optim/image_path_spec.rb