class Example

Attributes

description[R]
duration[R]
exception[R]
file_path[R]
full_description[R]
metadata[R]
run_time[R]
spec[R]
status[R]

Public Class Methods

new(example, report_folder) click to toggle source
# File lib/example.rb, line 10
def initialize(example, report_folder)
  @description = example.description
  @full_description = example.full_description
  @execution_result = example.execution_result
  @metadata = example.metadata
  @file_path = @metadata[:file_path]
  @exception = Oopsy.new(example.exception, @file_path)
  @spec = nil
  @report_folder = report_folder
end

Public Instance Methods

has_exception?() click to toggle source
# File lib/example.rb, line 21
def has_exception?
  !@exception.klass.nil?
end
has_spec?() click to toggle source
# File lib/example.rb, line 25
def has_spec?
  !@spec.nil?
end
klass(prefix = 'label-') click to toggle source
# File lib/example.rb, line 33
def klass(prefix = 'label-')
  class_map = { passed: "#{prefix}success", failed: "#{prefix}danger", pending: "#{prefix}warning" }
  class_map[status.to_sym]
end
screenshot() click to toggle source
# File lib/example.rb, line 38
def screenshot
  return nil unless @metadata[:screenshot]

  unless File.exist?(@metadata[:screenshot])
    puts "The screenshot '#{@metadata[:screenshot]}' does not exist"
  end

  report_dir = Pathname.new(File.expand_path(File.dirname(@report_folder)))
  screenshot = Pathname.new(File.expand_path(@metadata[:screenshot]))
  screenshot.relative_path_from(report_dir).to_s
end
set_spec(spec) click to toggle source
# File lib/example.rb, line 29
def set_spec(spec)
  @spec = spec
end