inspec/test/unit/source_readers/inspec_test.rb
Steven Danna 85cbe713d7
Add GitFetcher and rework Fetchers+SourceReaders
This adds a new git fetcher. In doing so, it also refactors how the
fetchers work a bit to better support fetchers that need to resolve
user-provided sources to fully specified sources appropriate for a
lockfile.

Signed-off-by: Steven Danna <steve@chef.io>
2016-09-09 14:14:36 +01:00

38 lines
1.1 KiB
Ruby

# encoding: utf-8
# author: Dominik Richter
# author: Christoph Hartmann
require 'helper'
describe SourceReaders::InspecReader do
let(:reader) { SourceReaders::InspecReader }
it 'registers with the source readers registry' do
reg = Inspec::SourceReader.registry
_(reg['inspec']).must_equal reader
end
describe 'with a valid profile' do
let(:mock_file) { MockLoader.profile_tgz('complete-profile') }
let(:target) { Inspec::FileProvider.for_path(mock_file) }
let(:res) { Inspec::SourceReader.resolve(target) }
it 'resolves the target to inspec' do
_(res).must_be_kind_of reader
end
it 'retrieves metadata' do
_(res.metadata.params[:name]).must_equal 'complete'
end
it 'retrieves all files' do
_(res.tests.keys).must_equal %w{controls/filesystem_spec.rb}
_(res.tests.values[0]).must_match(/^control 'test01' do$/)
end
it 'retrieves all libraries' do
_(res.libraries.keys).must_equal %w{libraries/testlib.rb}
_(res.libraries.values[0]).must_match(/^# Library resource$/)
end
end
end