module Allure::ResultUtils
Variouse helper methods
Constants
- ALLURE_ID_LABEL_NAME
- EPIC_LABEL_NAME
- FEATURE_LABEL_NAME
- FRAMEWORK_LABEL_NAME
- HOST_LABEL_NAME
- ISSUE_LINK_TYPE
- 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
- TMS_LINK_TYPE
Public Class Methods
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 @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 @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 @return [Allure::Label]
# File lib/allure_ruby_commons/result_utils.rb, line 46 def host_label Label.new(HOST_LABEL_NAME, Socket.gethostname) end
Issue link @param [String] value @param [String] link_pattern @return [Allure::Link]
# File lib/allure_ruby_commons/result_utils.rb, line 146 def issue_link(name, value, link_pattern) link_name = url?(value) ? name : value Link.new(ISSUE_LINK_TYPE, link_name, url(value, link_pattern)) end
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 @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 @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
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 @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
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
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 @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
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 @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 @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 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
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
@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
TMS link @param [String] value @param [String] link_pattern @return [Allure::Link]
# File lib/allure_ruby_commons/result_utils.rb, line 137 def tms_link(name, value, link_pattern) link_name = url?(value) ? name : value Link.new(TMS_LINK_TYPE, link_name, url(value, link_pattern)) end
Private Class Methods
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
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