module Allure::ResultUtils

Variouse helper methods

Constants

ALLURE_ID_LABEL_NAME
EPIC_LABEL_NAME
FEATURE_LABEL_NAME
FRAMEWORK_LABEL_NAME
HOST_LABEL_NAME
LANGUAGE_LABEL_NAME
LEAD_LABEL_NAME
OWNER_LABEL_NAME
PACKAGE_LABEL_NAME
PARENT_SUITE_LABEL_NAME
SEVERITY_LABEL_NAME
STORY_LABEL_NAME
SUB_SUITE_LABEL_NAME
SUITE_LABEL_NAME
TAG_LABEL_NAME
TEST_CLASS_LABEL_NAME
TEST_METHOD_LABEL_NAME
THREAD_LABEL_NAME

Public Class Methods

epic_label(value) click to toggle source

Epic label @param [String] value @return [Allure::Label]

# File lib/allure_ruby_commons/result_utils.rb, line 66
def epic_label(value)
  Label.new(EPIC_LABEL_NAME, value)
end
feature_label(value) click to toggle source

Feature label @param [String] value @return [Allure::Label]

# File lib/allure_ruby_commons/result_utils.rb, line 73
def feature_label(value)
  Label.new(FEATURE_LABEL_NAME, value)
end
framework_label(value) click to toggle source

Framework label @param [String] value @return [Allure::Label]

# File lib/allure_ruby_commons/result_utils.rb, line 59
def framework_label(value)
  Label.new(FRAMEWORK_LABEL_NAME, value)
end
host_label() click to toggle source

Host label @return [Allure::Label]

# File lib/allure_ruby_commons/result_utils.rb, line 46
def host_label
  Label.new(HOST_LABEL_NAME, Socket.gethostname)
end
language_label() click to toggle source

Language label @return [Allure::Label]

# File lib/allure_ruby_commons/result_utils.rb, line 52
def language_label
  Label.new(LANGUAGE_LABEL_NAME, "ruby")
end
package_label(value) click to toggle source

Package label @param [String] value @return [Allure::Label]

# File lib/allure_ruby_commons/result_utils.rb, line 87
def package_label(value)
  Label.new(PACKAGE_LABEL_NAME, value)
end
parent_suite_label(value) click to toggle source

Parent suite label @param [String] value @return [Allure::Label]

# File lib/allure_ruby_commons/result_utils.rb, line 101
def parent_suite_label(value)
  Label.new(PARENT_SUITE_LABEL_NAME, value)
end
prepare_attachment(name, type) click to toggle source

Allure attachment object @param [String] name @param [String] type @return [Allure::Attachment]

# File lib/allure_ruby_commons/result_utils.rb, line 169
def prepare_attachment(name, type)
  extension = ContentType.to_extension(type) || return
  file_name = "#{UUID.generate}-attachment.#{extension}"
  Attachment.new(name: name, source: file_name, type: type)
end
severity_label(value) click to toggle source

Severity label @param [String] value @return [Allure::Label]

# File lib/allure_ruby_commons/result_utils.rb, line 129
def severity_label(value)
  Label.new(SEVERITY_LABEL_NAME, value)
end
status(exception) click to toggle source

Get status based on exception type @param [Exception] exception @return [Symbol]

# File lib/allure_ruby_commons/result_utils.rb, line 154
def status(exception)
  exception.is_a?(RSpec::Expectations::ExpectationNotMetError) ? Status::FAILED : Status::BROKEN
end
status_details(exception) click to toggle source

Get exception status detail @param [Exception] exception @return [Allure::StatusDetails]

# File lib/allure_ruby_commons/result_utils.rb, line 161
def status_details(exception)
  StatusDetails.new(message: exception&.message, trace: exception&.backtrace&.join("\n"))
end
story_label(value) click to toggle source

Story label @param [String] value @return [Allure::Label]

# File lib/allure_ruby_commons/result_utils.rb, line 80
def story_label(value)
  Label.new(STORY_LABEL_NAME, value)
end
sub_suite_label(value) click to toggle source

Parent suite label @param [String] value @return [Allure::Label]

# File lib/allure_ruby_commons/result_utils.rb, line 108
def sub_suite_label(value)
  Label.new(SUB_SUITE_LABEL_NAME, value)
end
suite_label(value) click to toggle source

Suite label @param [String] value @return [Allure::Label]

# File lib/allure_ruby_commons/result_utils.rb, line 94
def suite_label(value)
  Label.new(SUITE_LABEL_NAME, value)
end
tag_label(value) click to toggle source

Tag label @param [String] value @return [Allure::Label]

# File lib/allure_ruby_commons/result_utils.rb, line 122
def tag_label(value)
  Label.new(TAG_LABEL_NAME, value)
end
test_class_label(value) click to toggle source

Test case label @param [String] value @return [Allure::Label]

# File lib/allure_ruby_commons/result_utils.rb, line 115
def test_class_label(value)
  Label.new(TEST_CLASS_LABEL_NAME, value)
end
thread_label() click to toggle source

Current thread label @return [Allure::Label]

# File lib/allure_ruby_commons/result_utils.rb, line 40
def thread_label
  Label.new(THREAD_LABEL_NAME, Thread.current.object_id)
end
timestamp(time = nil) click to toggle source

@param [Time] time @return [Number]

# File lib/allure_ruby_commons/result_utils.rb, line 34
def timestamp(time = nil)
  ((time || Time.now).to_f * 1000).to_i
end

Private Class Methods

url(value, link_pattern) click to toggle source

Construct url from pattern

@param [String] value @param [String] link_pattern @return [String]

# File lib/allure_ruby_commons/result_utils.rb, line 190
def url(value, link_pattern)
  link_pattern.sub("{}", value)
end
url?(value) click to toggle source

Check if value is full url

@param [String] value @return [Boolean]

# File lib/allure_ruby_commons/result_utils.rb, line 181
def url?(value)
  URI.parse(value.to_s).scheme
end