Sha256: be543e1a8b1cabb7c7b566c18b09762527147578b8283d3809f48924b2d1d3d1
Contents?: true
Size: 1.24 KB
Versions: 1
Compression:
Stored size: 1.24 KB
Contents
require 'oopsy' class Example attr_reader :description, :full_description, :run_time, :duration, :status, :exception, :file_path, :metadata, :spec, :screenshot def initialize(example) @description = example.description @full_description = example.full_description @execution_result = example.execution_result @run_time = (@execution_result.run_time).round(5) @duration = @execution_result.run_time.to_s(:rounded, precision: 5) @status = @execution_result.status.to_s @metadata = example.metadata @file_path = @metadata[:file_path] @exception = Oopsy.new(example.exception, @file_path) @screenshot = screenshot_path @spec = nil end def has_exception? !@exception.klass.nil? end def has_spec? !@spec.nil? end def set_spec(spec) @spec = spec end def klass(prefix = 'label-') class_map = { passed: "#{prefix}success", failed: "#{prefix}danger", pending: "#{prefix}warning" } class_map[@status.to_sym] end private def screenshot_path filename = File.basename(@metadata[:file_path]) line_number = @metadata[:line_number] default_path = "#{filename}-#{line_number}.png" File.exist?(default_path) ? default_path : @metadata[:screenshot] end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rspec_yah_formatter-0.0.5 | lib/example.rb |