Sha256: d4eabf6cda722fa8c88602934d25912fc2ed2f4ca76e7433b5e43c35dda79a3e
Contents?: true
Size: 1.52 KB
Versions: 1
Compression:
Stored size: 1.52 KB
Contents
module Sweet module Format module RSpec class Example class << self def from_output(data) data = JSON.parse(data, symbolize_names: true) if data.is_a? String case data[:status] when 'pending' message = data[:pending_message] when 'failed' e = data[:exception] message = "#{e[:class]}\n#{e[:message]}" end backtrace = data[:exception][:backtrace] if data[:exception] new name: data[:full_description], status: data[:status], file_path: data[:file_path], line_number: data[:line_number], duration: data[:run_time], message: message, backtrace: backtrace, screenshot: data[:screenshot] end end attr_accessor :name, :status, :file_path, :line_number, :message, :backtrace, :screenshot def initialize(opts = {}) @name = opts[:name] @status = opts[:status].to_sym if opts[:status] @file_path = sanitize_file_path(opts[:file_path]) @line_number = opts[:line_number] @duration = opts[:duration] @message = opts[:message] @screenshot = opts[:screenshot] end def duration @duration * 1_000_000_000 end private def sanitize_file_path(file_path) file_path.gsub('./', '') end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sweets-0.0.1 | lib/sweet/format/rspec/example.rb |