Sha256: 3ce7ae635e9c218cea93c9d7219eb3eddafce9820a35853c260a7d9d374823e4

Contents?: true

Size: 962 Bytes

Versions: 2

Compression:

Stored size: 962 Bytes

Contents

require_relative '../lib/inline_svg'

describe InlineSvg::StaticAssetFinder do
  context "when the file is not found" do
    it "returns nil" do
      stub_const('Rails', double('Rails').as_null_object)
      expect(::Rails.application.config.assets).to receive(:compile).and_return(true)

      expect(described_class.find_asset('some-file').pathname).to be_nil
    end
  end

  context "when the file is found" do
    it "returns fully qualified file path from Sprockets" do
      stub_const('Rails', double('Rails').as_null_object)
      expect(::Rails.application.config.assets).to receive(:compile).and_return(true)
      pathname = Pathname.new('/full/path/to/some-file')
      asset = double('Asset')
      expect(asset).to receive(:filename).and_return(pathname)
      expect(::Rails.application.assets).to receive(:[]).with('some-file').and_return(asset)

      expect(described_class.find_asset('some-file').pathname).to eq(pathname)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
inline_svg-1.10.0 spec/static_asset_finder_spec.rb
inline_svg-1.9.0 spec/static_asset_finder_spec.rb