class Qaa::ReportHelper

Attributes

report_info[RW]

Public Class Methods

add_info_report(info) click to toggle source
# File lib/qaa/report_helper.rb, line 50
def self.add_info_report(info)
  if @report_info.nil?
    @report_info = info
  else
    @report_info += info
  end
end
attach_file_to_allure(scenario, report_file) click to toggle source
# File lib/qaa/report_helper.rb, line 40
def self.attach_file_to_allure(scenario, report_file)
  file = "#{report_file.file_path}_#{report_file.file_name}.#{report_file.file_extension}"
  attachment = scenario.attach_file(report_file.file_name, File.new(file)) if File.exist?(file)
  attachment
end
generate_file_path_and_name(directory, folder_name, feature_name, scenario_name, step_name) click to toggle source
# File lib/qaa/report_helper.rb, line 17
def self.generate_file_path_and_name(directory, folder_name, feature_name, scenario_name, step_name)
  time             = Time.now.strftime('%Y-%m-%d_%H-%M-%S')
  report_folder    = File.join("#{directory}", folder_name, feature_name, scenario_name)
  file_name        = step_name||scenario_name
  report_file_name = "#{file_name}_#{time}_#{Fixtures.instance['env']}_#{Fixtures.instance['venture']}"
  FileUtils.mkdir_p(report_folder)
  "#{report_folder}/#{report_file_name}"
end
generate_report_directory(project_dir, report_folder, scenario, step_name) click to toggle source
# File lib/qaa/report_helper.rb, line 6
def self.generate_report_directory(project_dir, report_folder, scenario, step_name)
  if scenario.is_a? RSpec::Core::Example
    feature_name  = File.basename(scenario.file_path, '.rb').underscore_all
    scenario_name = scenario.example_group.description.underscore_all
  else
    feature_name  = scenario.feature.name.underscore_all
    scenario_name = scenario.name.underscore_all
  end
  generate_file_path_and_name(project_dir, report_folder, feature_name, scenario_name, step_name.underscore_all)
end
generate_report_for_step(scenario, report_directory, report_file) click to toggle source
# File lib/qaa/report_helper.rb, line 26
def self.generate_report_for_step(scenario, report_directory, report_file)
  file = File.open("#{report_directory}_#{report_file.file_name}.#{report_file.file_extension}", "a")
  file.write(report_file.file_content) unless report_file.file_content.nil? || report_file.file_content.empty?
  file.close
  attach_file_to_allure(scenario, report_file)
end
report_info() click to toggle source
# File lib/qaa/report_helper.rb, line 46
def self.report_info
  @report_info
end
take_step_screenshot(browser, scenario, screenshot_file_path) click to toggle source
# File lib/qaa/report_helper.rb, line 33
def self.take_step_screenshot(browser, scenario, screenshot_file_path)
  screenshot_file_name = "#{screenshot_file_path}_screenshot.png"
  browser.screenshot.save(screenshot_file_name)
  attach_file_to_allure(scenario, ReportFile.new(file_name: 'screenshot', file_path: screenshot_file_path, file_extension: 'png'))
  screenshot_file_name
end

Public Instance Methods

underscore_all() click to toggle source
# File lib/qaa/report_helper.rb, line 58
def underscore_all
  gsub(/[^a-zA-Z0-9]/, '_').gsub(/^_*|_*$/, '')
end