Remove some warnings during the test run

This commit is contained in:
Steven Danna 2016-09-07 12:10:35 +01:00
parent f431794917
commit 3777f06927
No known key found for this signature in database
GPG key ID: 94DFB46E861A7DAE
13 changed files with 18 additions and 19 deletions

View file

@ -11,14 +11,14 @@ describe 'example inheritance profile' do
it 'check succeeds with --profiles-path' do
out = inspec('check ' + path + ' --profiles-path ' + examples_path)
out.stderr.must_equal ''
out.stdout.must_match /Valid.*true/
out.stdout.must_match(/Valid.*true/)
out.exit_status.must_equal 0
end
it 'check succeeds without --profiles-path using inspec.yml' do
out = inspec('check ' + path)
out.stderr.must_equal ''
out.stdout.must_match /Valid.*true/
out.stdout.must_match(/Valid.*true/)
out.exit_status.must_equal 0
end

View file

@ -11,7 +11,7 @@ describe 'inspec archive' do
it 'archive is successful' do
out = inspec('archive ' + example_profile + ' --overwrite')
out.exit_status.must_equal 0
out.stdout.must_match /Generate archive [^ ]*profile.tar.gz/
out.stdout.must_match(/Generate archive [^ ]*profile.tar.gz/)
out.stdout.must_include 'Finished archive generation.'
end

View file

@ -93,7 +93,7 @@ Summary: \e[32m0 successful\e[0m, \e[31m0 failures\e[0m, \e[37m0 skipped\e[0m
let(:json) { JSON.load(out.stdout) }
it 'exits with an error' do
out.stderr.must_match /^This OS\/platform \(.+\) is not supported by this profile.$/
out.stderr.must_match(/^This OS\/platform \(.+\) is not supported by this profile.$/)
out.exit_status.must_equal 1
end
end

View file

@ -72,7 +72,7 @@ describe 'inspec json' do
end
it 'has a the source code' do
control['code'].must_match /\Acontrol \"tmp-1.0\" do.*end\n\Z/m
control['code'].must_match(/\Acontrol \"tmp-1.0\" do.*end\n\Z/m)
end
end
end

View file

@ -143,7 +143,7 @@ describe 'inspec shell tests' do
it 'exposes all resources' do
out = do_shell('os')
out.stdout.must_match /\=> .*Operating.* .*System.* .*Detection/
out.stdout.must_match(/\=> .*Operating.* .*System.* .*Detection/)
end
it 'can run ruby expressions' do

View file

@ -46,7 +46,7 @@ describe 'command tests' do
describe 'check' do
it 'verifies that a profile is ok' do
out = inspec('check ' + example_profile)
out.stdout.must_match /Valid.*true/
out.stdout.must_match(/Valid.*true/)
out.exit_status.must_equal 0
end
end

View file

@ -30,7 +30,7 @@ describe Fetchers::Tar do
end
it 'must read the contents of the file' do
_(res.read('inspec.yml')).must_match /^name: complete$/
_(res.read('inspec.yml')).must_match(/^name: complete$/)
end
end
end

View file

@ -105,7 +105,7 @@ describe Fetchers::Url do
end
it 'must read the contents of the file' do
_(res.read('inspec.yml')).must_match /^name: complete$/
_(res.read('inspec.yml')).must_match(/^name: complete$/)
end
end
@ -134,7 +134,7 @@ describe Fetchers::Url do
end
it 'must read the contents of the file' do
_(res.read('inspec.yml')).must_match /^name: complete$/
_(res.read('inspec.yml')).must_match(/^name: complete$/)
end
end

View file

@ -30,7 +30,7 @@ describe Fetchers::Zip do
end
it 'must read the contents of the file' do
_(res.read('inspec.yml')).must_match /^name: complete$/
_(res.read('inspec.yml')).must_match(/^name: complete$/)
end
end
end

View file

@ -20,7 +20,7 @@ describe Inspec::Plugins::Resource do
random_name = (0...50).map { (65 + rand(26)).chr }.join
Class.new(base) do
name random_name
instance_eval &block
instance_eval(&block)
end
Inspec::Resource.registry[random_name]
end

View file

@ -91,7 +91,7 @@ describe Inspec::ProfileContext do
it 'supports empty describe calls' do
load('describe').must_output ''
profile.rules.keys.length.must_equal 1
profile.rules.keys[0].must_match /^\(generated from \(eval\):1 [0-9a-f]+\)$/
profile.rules.keys[0].must_match(/^\(generated from \(eval\):1 [0-9a-f]+\)$/)
profile.rules.values[0].must_be_kind_of Inspec::Rule
end
@ -99,7 +99,7 @@ describe Inspec::ProfileContext do
load('describe true do; it { should_eq true }; end')
.must_output ''
profile.rules.keys.length.must_equal 1
profile.rules.keys[0].must_match /^\(generated from \(eval\):1 [0-9a-f]+\)$/
profile.rules.keys[0].must_match(/^\(generated from \(eval\):1 [0-9a-f]+\)$/)
profile.rules.values[0].must_be_kind_of Inspec::Rule
end
@ -108,7 +108,7 @@ describe Inspec::ProfileContext do
.must_output ''
profile.rules.keys.length.must_equal 3
[0, 1, 2].each do |i|
profile.rules.keys[i].must_match /^\(generated from \(eval\):2 [0-9a-f]+\)$/
profile.rules.keys[i].must_match(/^\(generated from \(eval\):2 [0-9a-f]+\)$/)
profile.rules.values[i].must_be_kind_of Inspec::Rule
end
end

View file

@ -96,7 +96,6 @@ describe Inspec::Profile do
let(:profile_id) { 'legacy-empty-metadata' }
it 'prints loads of warnings' do
metadata_rb = "#{home}/mock/profiles/#{profile_id}/metadata.rb"
logger.expect :info, nil, ["Checking profile in #{home}/mock/profiles/#{profile_id}"]
logger.expect :error, nil, ["Missing profile name in metadata.rb"]
logger.expect :warn, nil, ['The use of `metadata.rb` is deprecated. Use `inspec.yml`.']

View file

@ -13,7 +13,7 @@ describe SourceReaders::InspecReader do
end
describe 'with a valid profile' do
let(:mock_file) { mock_file = MockLoader.profile_tgz('complete-profile') }
let(:mock_file) { MockLoader.profile_tgz('complete-profile') }
let(:target) { Inspec::Fetcher.resolve(mock_file) }
let(:res) { Inspec::SourceReader.resolve(target) }
@ -27,12 +27,12 @@ describe SourceReaders::InspecReader do
it 'retrieves all files' do
_(res.tests.keys).must_equal %w{controls/filesystem_spec.rb}
_(res.tests.values[0]).must_match /^control 'test01' do$/
_(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$/
_(res.libraries.values[0]).must_match(/^# Library resource$/)
end
end
end