module OnlyofficeTestrailWrapper::TestrailHelperRspecMetadata

Module for working with rspec metadata

Public Instance Methods

example_time_in_seconds(example) click to toggle source

@return [String] example execution time in seconds

# File lib/onlyoffice_testrail_wrapper/testrail_helper/testrail_helper_rspec_metadata.rb, line 15
def example_time_in_seconds(example)
  execution_time = (Time.now - example.metadata[:execution_result].started_at).to_i
  execution_time = 1 if execution_time.zero? # Testrail cannot receive 0 as elapsed time
  "#{execution_time}s"
end
init_custom_fields(example) click to toggle source

Fill default values for custom fields @param [RSpec::Core::Example] example with metadata @return [Hash] custom fields

# File lib/onlyoffice_testrail_wrapper/testrail_helper/testrail_helper_rspec_metadata.rb, line 24
def init_custom_fields(example)
  custom_fields = {}
  # TODO: Fix dependencies from other project
  return custom_fields if defined?(AppManager).nil?

  custom_fields[:elapsed] = example_time_in_seconds(example)
  custom_fields[:version] = version
  custom_fields[:custom_host] = SystemHelper.hostname
  custom_fields[:custom_screenshot_link] = screenshot_link if example.exception
  custom_fields
end
parse_pending_comment(pending_message) click to toggle source
# File lib/onlyoffice_testrail_wrapper/testrail_helper/testrail_helper_rspec_metadata.rb, line 44
def parse_pending_comment(pending_message)
  return [:pending, 'There is problem with initialization of @bugzilla_helper', nil] if @bugzilla_helper.nil?

  bug_id = @bugzilla_helper.bug_id_from_string(pending_message)
  return [:pending, pending_message] if bug_id.nil?

  bug_status = @bugzilla_helper.bug_status(bug_id)
  status = bug_status.include?('VERIFIED') ? :failed : :pending
  [status, "#{pending_message}\nBug has status: #{bug_status}, test was failed", bug_id]
end
version() click to toggle source

@return [String] version of tested app

# File lib/onlyoffice_testrail_wrapper/testrail_helper/testrail_helper_rspec_metadata.rb, line 7
def version
  return @version if @version
  return @plan.name if @plan&.name

  'Unknown'
end