add unit test for local fetcher with windows path support

This commit is contained in:
Christoph Hartmann 2016-08-24 16:06:12 +02:00
parent fe5c7c49a4
commit 1300900693
2 changed files with 10 additions and 3 deletions

View file

@ -17,7 +17,7 @@ module Fetchers
target = target.gsub(%r{^file://}, '')
else
# support for windows paths
target.tr!('\\', '/')
target = target.tr('\\', '/')
end
if !File.exist?(target)

View file

@ -9,6 +9,15 @@ describe Inspec::Fetcher do
res = Inspec::Fetcher.resolve(__FILE__)
res.must_be_kind_of Fetchers::Local
end
it 'is able to handle Windows paths' do
# simulate a local windows path
file = __FILE__
file.tr!('/', '\\')
res = Inspec::Fetcher.resolve(file)
res.must_be_kind_of Fetchers::Local
res.target.must_equal __FILE__
end
end
describe Inspec::Plugins::RelFetcher do
@ -52,8 +61,6 @@ describe Inspec::Plugins::RelFetcher do
# ignored by all tar streaming tools, its not extracted by GNU tar since 1.14
%w{/pax_global_header /a/b} => %w{b},
%w{pax_global_header a/b} => %w{b},
# windows path
%w{.\\path\\} => %w{./path/}
}.each do |ins, outs|
describe 'empty profile' do
let(:in_files) { ins }