Module: AllureCucumber::TagParser

Included in:
AllureCucumberModel
Defined in:
allure-cucumber/lib/allure_cucumber/tag_parser.rb

Overview

Cucumber tag parser helper methods

Instance Method Summary collapse

Instance Method Details

Parameters:

  • tags (Cucumber::Core::Ast::Tag)

Returns:


29
30
31
32
33
34
35
36
# File 'allure-cucumber/lib/allure_cucumber/tag_parser.rb', line 29

def issue_links(tags)
  return [] unless Allure::Config.link_issue_pattern

  issue_pattern = reserved_patterns[:issue]
  tags
    .select { |tag| tag.name.match?(issue_pattern) }
    .map { |tag| tag.name.match(issue_pattern) { |match| Allure::ResultUtils.issue_link(match[:issue]) } }
end

#severity(tags) ⇒ Allure::Label

Parameters:

  • tags (Cucumber::Core::Ast::Tag)

Returns:


40
41
42
43
44
45
46
47
# File 'allure-cucumber/lib/allure_cucumber/tag_parser.rb', line 40

def severity(tags)
  severity_pattern = reserved_patterns[:severity]
  severity = tags
    .detect { |tag| tag.name.match?(severity_pattern) }&.name
    &.match(severity_pattern)&.[](:severity) || "normal"

  Allure::ResultUtils.severity_label(severity)
end

#status_detail_tags(tags) ⇒ Hash<Symbol, Boolean>

Parameters:

  • tags (Cucumber::Core::Ast::Tag)

Returns:

  • (Hash<Symbol, Boolean>)

51
52
53
54
55
56
57
# File 'allure-cucumber/lib/allure_cucumber/tag_parser.rb', line 51

def status_detail_tags(tags)
  {
    flaky: tags.any? { |tag| tag.match?(reserved_patterns[:flaky]) },
    muted: tags.any? { |tag| tag.match?(reserved_patterns[:muted]) },
    known: tags.any? { |tag| tag.match?(reserved_patterns[:known]) },
  }
end

#tag_labels(tags) ⇒ Array<Allure::Label>

Parameters:

  • tags (Cucumber::Core::Ast::Tag)

Returns:


10
11
12
13
14
# File 'allure-cucumber/lib/allure_cucumber/tag_parser.rb', line 10

def tag_labels(tags)
  tags
    .reject { |tag| reserved?(tag.name) }
    .map { |tag| Allure::ResultUtils.tag_label(tag.name.delete_prefix("@")) }
end

Parameters:

  • tags (Cucumber::Core::Ast::Tag)

Returns:


18
19
20
21
22
23
24
25
# File 'allure-cucumber/lib/allure_cucumber/tag_parser.rb', line 18

def tms_links(tags)
  return [] unless Allure::Config.link_tms_pattern

  tms_pattern = reserved_patterns[:tms]
  tags
    .select { |tag| tag.name.match?(tms_pattern) }
    .map { |tag| tag.name.match(tms_pattern) { |match| Allure::ResultUtils.tms_link(match[:tms]) } }
end