class Rspeckled::Reporting::Example

Constants

IGNORED_QUERIES_PATTERN

Attributes

counts[RW]
example[RW]

Public Class Methods

new(example) click to toggle source
# File lib/rspeckled/reporting/example.rb, line 27
def initialize(example)
  self.counts  = Hash.new(0)
  self.example = example
end

Public Instance Methods

description() click to toggle source
# File lib/rspeckled/reporting/example.rb, line 48
def description
  metadata[:full_description]
end
exception() click to toggle source
# File lib/rspeckled/reporting/example.rb, line 52
def exception
  execution_result.exception
end
file() click to toggle source
# File lib/rspeckled/reporting/example.rb, line 32
def file
  metadata[:file_path]
end
line_number() click to toggle source
# File lib/rspeckled/reporting/example.rb, line 36
def line_number
  metadata[:line_number]
end
log_query(query, start, finish) click to toggle source
# File lib/rspeckled/reporting/example.rb, line 72
def log_query(query, start, finish)
  return if query[:sql] =~ IGNORED_QUERIES_PATTERN

  counts[:query_count] += 1
  counts[:query_time]  += (finish - start)
end
log_request(_request, start, finish) click to toggle source
# File lib/rspeckled/reporting/example.rb, line 79
def log_request(_request, start, finish)
  counts[:request_count] += 1
  counts[:request_time]  += (finish - start)
end
query_count() click to toggle source
# File lib/rspeckled/reporting/example.rb, line 56
def query_count
  counts[:query_count]
end
query_time() click to toggle source
# File lib/rspeckled/reporting/example.rb, line 60
def query_time
  counts[:query_time]
end
request_count() click to toggle source
# File lib/rspeckled/reporting/example.rb, line 64
def request_count
  counts[:request_count]
end
request_time() click to toggle source
# File lib/rspeckled/reporting/example.rb, line 68
def request_time
  counts[:request_time]
end
status() click to toggle source
# File lib/rspeckled/reporting/example.rb, line 40
def status
  execution_result.status
end
time() click to toggle source
# File lib/rspeckled/reporting/example.rb, line 44
def time
  execution_result.run_time
end

Private Instance Methods

execution_result() click to toggle source
# File lib/rspeckled/reporting/example.rb, line 90
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
metadata() click to toggle source
# File lib/rspeckled/reporting/example.rb, line 86
def metadata
  example.metadata
end