class Rspeckled::Reporting::Runner
Constants
- FIELDS
Attributes
example[RW]
outputters[RW]
Public Class Methods
new(outputters: [ Rspeckled::Reporting::Outputs::Text, Rspeckled::Reporting::Outputs::Csv, ])
click to toggle source
# File lib/rspeckled/reporting/runner.rb, line 29 def initialize(outputters: [ Rspeckled::Reporting::Outputs::Text, Rspeckled::Reporting::Outputs::Csv, ]) self.outputters = outputters.map(&:new) end
Public Instance Methods
example_finished(_notification)
click to toggle source
# File lib/rspeckled/reporting/runner.rb, line 55 def example_finished(_notification) # rubocop:disable Metrics/AbcSize outputters.each do |outputter| outputter.insert( branch: `git rev-parse --abbrev-ref HEAD`.chomp, commit_hash: `git rev-parse HEAD`.chomp, date: ::Time.parse(`git show -s --format=%ci HEAD`.chomp), file: example.file, line_number: example.line_number, description: example.description, status: example.status, exception: example.exception, time: example.time, query_count: example.query_count, query_time: example.query_time, query_percentage: example.query_time / example.time * 100.0, request_count: example.request_count, request_time: example.request_time, request_percentage: example.request_time / example.time * 100.0, ) end end
example_started(notification)
click to toggle source
# File lib/rspeckled/reporting/runner.rb, line 51 def example_started(notification) self.example = Example.new(notification.example) end
start(_notification)
click to toggle source
# File lib/rspeckled/reporting/runner.rb, line 37 def start(_notification) return unless defined?(::ActiveSupport::Notifications) ::ActiveSupport::Notifications .subscribe('sql.active_record') do |_name, start, finish, _id, query| example&.log_query(query, start, finish) end ::ActiveSupport::Notifications .subscribe('process_action.action_controller') do |_name, start, finish, _id, reqst| example&.log_request(reqst, start, finish) end end