1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
begin
require_relative '../lib/inline_svg/finds_asset_paths'
require_relative '../lib/inline_svg/asset_file'
rescue LoadError
require "inline_svg/finds_asset_paths"
require "inline_svg/asset_file"
end
describe InlineSvg::AssetFile do
it "reads data from a file, after qualifying a full path" do
example_svg_path = File.expand_path(__FILE__, 'files/example.svg')
expect(InlineSvg::FindsAssetPaths).to receive(:by_filename).with('some filename').and_return example_svg_path
expect(InlineSvg::AssetFile.named('some filename')).to include('This is a test')
end
it "complains when the file cannot be read" do
allow(InlineSvg::FindsAssetPaths).to receive(:by_filename).and_return('/this/path/does/not/exist')
expect do
InlineSvg::AssetFile.named('some missing file')
end.to raise_error InlineSvg::AssetFile::FileNotFound
end
it "complains when the file path was not found" do
allow(InlineSvg::FindsAssetPaths).to receive(:by_filename).and_return(nil)
expect do
InlineSvg::AssetFile.named('some missing file')
end.to raise_error InlineSvg::AssetFile::FileNotFound
end
end
|