Sha256: 76c1d9ba59ea27981410815ab8cd4f59b308e520ca548f93f6a805b895c72400

Contents?: true

Size: 1.4 KB

Versions: 7

Compression:

Stored size: 1.4 KB

Contents

# frozen_string_literal: true

require_relative "../../ext/test"
require_relative "ext"

module Datadog
  module CI
    module Contrib
      module RSpec
        # Instrument RSpec::Core::Runner
        module Runner
          def self.included(base)
            base.prepend(InstanceMethods)
          end

          module InstanceMethods
            def run_specs(*)
              return super unless datadog_configuration[:enabled]

              test_session = CI.start_test_session(
                tags: {
                  CI::Ext::Test::TAG_FRAMEWORK => Ext::FRAMEWORK,
                  CI::Ext::Test::TAG_FRAMEWORK_VERSION => CI::Contrib::RSpec::Integration.version.to_s
                },
                service: datadog_configuration[:service_name]
              )

              test_module = CI.start_test_module(Ext::FRAMEWORK)

              result = super
              return result unless test_module && test_session

              if result != 0
                test_module.failed!
                test_session.failed!
              else
                test_module.passed!
                test_session.passed!
              end
              test_module.finish
              test_session.finish

              result
            end

            private

            def datadog_configuration
              Datadog.configuration.ci[:rspec]
            end
          end
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
datadog-ci-1.0.0.beta3 lib/datadog/ci/contrib/rspec/runner.rb
datadog-ci-1.0.0.beta2 lib/datadog/ci/contrib/rspec/runner.rb
datadog-ci-1.0.0.beta1 lib/datadog/ci/contrib/rspec/runner.rb
datadog-ci-0.8.3 lib/datadog/ci/contrib/rspec/runner.rb
datadog-ci-0.8.2 lib/datadog/ci/contrib/rspec/runner.rb
datadog-ci-0.8.1 lib/datadog/ci/contrib/rspec/runner.rb
datadog-ci-0.8.0 lib/datadog/ci/contrib/rspec/runner.rb