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



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



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



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

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

#locationString

Example location



79
80
81
82
83
84
85
86
87
88
89
# File 'lib/allure_rspec/metadata_parser.rb', line 79

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



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

#title_pathArray<String>

Title path without the final example display name.



72
73
74
# File 'lib/allure_rspec/metadata_parser.rb', line 72

def title_path
  [strip_relative(example.file_path), *SuiteLabels.new(example.example_group).title_path]
end