Sha256: 26b4dfa086dde00fea07db45c16eebf5c80baa46598bd4c3d5c32d08fb6c9cec

Contents?: true

Size: 1.5 KB

Versions: 13

Compression:

Stored size: 1.5 KB

Contents

# encoding: utf-8
require 'spec_helper'

RSpec.describe AssetStore do
  context '#add' do
    it 'adds asset to store' do
      asset = instance_double('Middleman::Presentation::Asset')

      store = AssetStore.new
      expect { store.add asset }.not_to raise_error
    end

    it 'merges existing assets' do
      asset2 = instance_double('Middleman::Presentation::Asset')
      allow(asset2).to receive(:source_path).and_return('source/path')

      asset1 = instance_double('Middleman::Presentation::Asset')
      allow(asset1).to receive(:source_path).and_return('source/path')
      expect(asset1).to receive(:merge!).with(asset2)

      store = AssetStore.new
      store.add asset1
      store.add asset2
    end
  end

  context '#find' do
    it 'finds existing assets' do
      asset = OpenStruct.new(source_path: 'asset/path', loadable: false)

      store = AssetStore.new
      store.add asset

      asset = store.find source_path: asset.source_path

      expect(asset).to be asset
    end

    it 'uses a block as well' do
      asset = OpenStruct.new(source_path: 'asset/path', loadable: false)

      store = AssetStore.new
      store.add asset

      asset = store.find { |a| a.source_path == asset.source_path }

      expect(asset).to be asset
    end
  end

  context '#assets' do
    it 'returns assets stored in asset store' do
      asset = instance_double('Middleman::Presentation::Asset')

      store = AssetStore.new
      store.add asset

      expect(store.assets).to include asset
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
middleman-presentation-core-0.17.7 spec/asset_store_spec.rb
middleman-presentation-core-0.17.6 spec/asset_store_spec.rb
middleman-presentation-core-0.17.5 spec/asset_store_spec.rb
middleman-presentation-core-0.17.2 spec/asset_store_spec.rb
middleman-presentation-core-0.17.1 spec/asset_store_spec.rb
middleman-presentation-core-0.17.0 spec/asset_store_spec.rb
middleman-presentation-core-0.16.3 spec/asset_store_spec.rb
middleman-presentation-core-0.16.2 spec/asset_store_spec.rb
middleman-presentation-core-0.16.0 spec/asset_store_spec.rb
middleman-presentation-core-0.16.0.rc2 spec/asset_store_spec.rb
middleman-presentation-core-0.16.0.rc1 spec/asset_store_spec.rb
middleman-presentation-core-0.16.0.beta spec/asset_store_spec.rb
middleman-presentation-core-0.16.0.alpha spec/asset_store_spec.rb