Sha256: aa0727b855560364272402bdca043cede2389943dcd2780dc2a9c22b40ee4e94

Contents?: true

Size: 1.54 KB

Versions: 23

Compression:

Stored size: 1.54 KB

Contents

require 'pathname'
require_relative '../lib/inline_svg'

describe InlineSvg::FindsAssetPaths do
  context "when sprockets finder returns an object which supports only the pathname method" do
    it "returns fully qualified file paths from Sprockets" do
      sprockets = double('SprocketsDouble')

      expect(sprockets).to receive(:find_asset).with('some-file').
        and_return(double(pathname: Pathname('/full/path/to/some-file')))

      InlineSvg.configure do |config|
        config.asset_finder = sprockets
      end

      expect(InlineSvg::FindsAssetPaths.by_filename('some-file')).to eq Pathname('/full/path/to/some-file')
    end
  end

  context "when sprockets finder returns an object which supports only the filename method" do
    it "returns fully qualified file paths from Sprockets" do
      sprockets = double('SprocketsDouble')

      expect(sprockets).to receive(:find_asset).with('some-file').
        and_return(double(filename: Pathname('/full/path/to/some-file')))

      InlineSvg.configure do |config|
        config.asset_finder = sprockets
      end

      expect(InlineSvg::FindsAssetPaths.by_filename('some-file')).to eq Pathname('/full/path/to/some-file')
    end
  end

  context "when asset is not found" do
    it "returns nil" do
      sprockets = double('SprocketsDouble')

      expect(sprockets).to receive(:find_asset).with('some-file').and_return(nil)

      InlineSvg.configure do |config|
        config.asset_finder = sprockets
      end

      expect(InlineSvg::FindsAssetPaths.by_filename('some-file')).to be_nil
    end
  end
end

Version data entries

23 entries across 23 versions & 2 rubygems

Version Path
rails_mini_profiler-0.2.0 vendor/bundle/ruby/3.0.0/gems/inline_svg-1.7.2/spec/finds_asset_paths_spec.rb
inline_svg-1.7.2 spec/finds_asset_paths_spec.rb
inline_svg-1.7.1 spec/finds_asset_paths_spec.rb
inline_svg-1.7.0 spec/finds_asset_paths_spec.rb
inline_svg-1.6.0 spec/finds_asset_paths_spec.rb
inline_svg-1.5.2 spec/finds_asset_paths_spec.rb
inline_svg-1.5.1 spec/finds_asset_paths_spec.rb
inline_svg-1.5.0 spec/finds_asset_paths_spec.rb
inline_svg-1.4.0 spec/finds_asset_paths_spec.rb
inline_svg-1.3.1 spec/finds_asset_paths_spec.rb
inline_svg-1.3.0 spec/finds_asset_paths_spec.rb
inline_svg-1.2.3 spec/finds_asset_paths_spec.rb
inline_svg-1.2.2 spec/finds_asset_paths_spec.rb
inline_svg-1.2.1 spec/finds_asset_paths_spec.rb
inline_svg-1.2.0 spec/finds_asset_paths_spec.rb
inline_svg-1.1.0 spec/finds_asset_paths_spec.rb
inline_svg-1.0.1 spec/finds_asset_paths_spec.rb
inline_svg-1.0.0 spec/finds_asset_paths_spec.rb
inline_svg-0.12.1 spec/finds_asset_paths_spec.rb
inline_svg-0.12.0 spec/finds_asset_paths_spec.rb