Class: AllureRspec::RspecMetadataParser

Inherits:
Object
  • Object
show all
Includes:
Utils
Defined in:
lib/allure_rspec/metadata_parser.rb

Overview

RSpec metadata parser

Constant Summary collapse

RSPEC_IGNORED_METADATA =
%i[
  absolute_file_path
  block
  described_class
  description
  description_args
  example_group
  execution_result
  file_path
  full_description
  last_run_status
  line_number
  location
  rerun_file_path
  retry
  retry_attempts
  retry_exceptions
  scoped_id
  shared_group_inclusion_backtrace
  type
].freeze

Instance Method Summary collapse

Methods included from Utils

#strip_relative

Constructor Details

#initialize(example, config) ⇒ RspecMetadataParser

Metadata parser instance

Parameters:



35
36
37
38
# File 'lib/allure_rspec/metadata_parser.rb', line 35

def initialize(example, config)
  @example = example
  @config = config
end

Instance Method Details

#labelsArray<Allure::Label>

Get allure labels

Returns:

  • (Array<Allure::Label>)


42
43
44
45
46
47
48
49
50
51
52
# File 'lib/allure_rspec/metadata_parser.rb', line 42

def labels
  [
    framework_label,
    package_label,
    test_class_label,
    severity,
    *tag_labels,
    *behavior_labels,
    *suite_labels
  ].select(&:value)
end

Get attachable links

Returns:

  • (Array<Allure::Link>)


56
57
58
# File 'lib/allure_rspec/metadata_parser.rb', line 56

def links
  matching_links(:tms) + matching_links(:issue)
end

#locationString

Example location

Returns:

  • (String)


73
74
75
76
77
78
79
80
81
82
83
# File 'lib/allure_rspec/metadata_parser.rb', line 73

def location
  file = example
         .
         .fetch(:shared_group_inclusion_backtrace)
         .last
         &.formatted_inclusion_location

  return example.location unless file

  file
end

#status_detailsAllure::StatusDetails

Get status details

Returns:

  • (Allure::StatusDetails)


62
63
64
65
66
67
68
# File 'lib/allure_rspec/metadata_parser.rb', line 62

def status_details
  Allure::StatusDetails.new(
    flaky: ![:flaky].nil?,
    muted: ![:muted].nil?,
    known: ![:known].nil?
  )
end