lib/inspec/runner.rb in inspec-0.34.1 vs lib/inspec/runner.rb in inspec-0.35.0

- old
+ new

@@ -64,11 +64,10 @@ @test_collector.backend = @backend end def run(with = nil) Inspec::Log.debug "Starting run with targets: #{@target_profiles.map(&:to_s)}" - Inspec::Log.debug "Backend is #{@backend}" all_controls = [] @target_profiles.each do |profile| @test_collector.add_profile(profile) profile.locked_dependencies @@ -147,21 +146,20 @@ profile_id = meta.params[:name] unless meta.nil? Inspec::ProfileContext.new(profile_id, @backend, @conf.merge(options)) end def supports_profile?(profile) - return true if profile.metadata.nil? || @ignore_supports + return true if @ignore_supports - if !profile.metadata.supports_runtime? + if !profile.supports_runtime? fail 'This profile requires InSpec version '\ "#{profile.metadata.inspec_requirement}. You are running "\ "InSpec v#{Inspec::VERSION}.\n" end - if !profile.metadata.supports_transport?(@backend) - os_info = @backend.os[:name].to_s - fail "This OS/platform (#{os_info}) is not supported by this profile." + if !profile.supports_os? + fail "This OS/platform (#{@backend.os[:name]}) is not supported by this profile." end true end @@ -229,23 +227,13 @@ def register_rule(rule) Inspec::Log.debug "Registering rule #{rule}" @rules << rule checks = ::Inspec::Rule.prepare_checks(rule) - examples = checks.map do |m, a, b| + examples = checks.flat_map do |m, a, b| get_check_example(m, a, b) - end.flatten.compact + end.compact - examples.each do |example| - # TODO: Remove this!! It is very dangerous to do this here. - # The goal of this is to make the audit DSL available to all - # describe blocks. Right now, these blocks are executed outside - # the scope of this run, thus not gaining ony of the DSL pieces. - # To circumvent this, the full DSL is attached to the example's - # scope. - dsl = Inspec::Resource.create_dsl(backend) - example.send(:include, dsl) - @test_collector.add_test(example, rule) - end + examples.each { |e| @test_collector.add_test(e, rule) } end end end