module Datadog::CI::Contrib::RSpec::Example::InstanceMethods

Instance methods for configuration

Public Instance Methods

run(example_group_instance, reporter) click to toggle source
Calls superclass method
# File lib/datadog/ci/contrib/rspec/example.rb, line 21
def run(example_group_instance, reporter)
  return super unless configuration[:enabled]

  test_name = full_description.strip
  if metadata[:description].empty?
    # for unnamed it blocks this appends something like "example at ./spec/some_spec.rb:10"
    test_name += " #{description}"
  end

  CI::Test.trace(
    tracer,
    configuration[:operation_name],
    {
      span_options: {
        app: Ext::APP,
        resource: test_name,
        service: configuration[:service_name]
      },
      framework: Ext::FRAMEWORK,
      test_name: test_name,
      test_suite: file_path,
      test_type: Ext::TEST_TYPE
    }
  ) do |span|
    result = super

    case execution_result.status
    when :passed
      CI::Test.passed!(span)
    when :failed
      CI::Test.failed!(span, execution_result.exception)
    else
      CI::Test.skipped!(span, execution_result.exception) if execution_result.example_skipped?
    end

    result
  end
end

Private Instance Methods

configuration() click to toggle source
# File lib/datadog/ci/contrib/rspec/example.rb, line 62
def configuration
  Datadog.configuration[:rspec]
end
tracer() click to toggle source
# File lib/datadog/ci/contrib/rspec/example.rb, line 66
def tracer
  configuration[:tracer]
end