Sha256: d3e4ffa0392c37bf90ee51af482c25884253d9782dbaddbfc92a7035afc1d8b9
Contents?: true
Size: 1.62 KB
Versions: 4
Compression:
Stored size: 1.62 KB
Contents
# frozen_string_literal: true module Rspeckled module Reporting class Example IGNORED_QUERIES_PATTERN = %r{ ( pg_table| pg_attribute| pg_namespace| show\stables| pragma| sqlite_master/rollback| ^TRUNCATE TABLE| ^ALTER TABLE| ^BEGIN| ^COMMIT| ^ROLLBACK| ^RELEASE| ^SAVEPOINT ) }xi.freeze attr_accessor :counts, :example def initialize(example) self.counts = Hash.new(0) self.example = example end def file metadata[:file_path] end def line_number metadata[:line_number] end def status execution_result.status end def time execution_result.run_time end def description metadata[:full_description] end def exception execution_result.exception end def query_count counts[:query_count] end def query_time counts[:query_time] end def request_count counts[:request_count] end def request_time counts[:request_time] end def log_query(query, start, finish) return if query[:sql] =~ IGNORED_QUERIES_PATTERN counts[:query_count] += 1 counts[:query_time] += (finish - start) end def log_request(_request, start, finish) counts[:request_count] += 1 counts[:request_time] += (finish - start) end private def metadata example.metadata end def execution_result @execution_result ||= begin if example.execution_result.is_a?(Hash) OpenStruct.new(example.execution_result) # rubocop:disable Performance/OpenStruct else example.execution_result end end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems