class RspecProfiling::Run
Attributes
collector[R]
vcs[R]
Public Class Methods
new(collector = RspecProfiling.config.collector.new, vcs = RspecProfiling.config.vcs.new)
click to toggle source
# File lib/rspec_profiling/run.rb, line 11 def initialize(collector = RspecProfiling.config.collector.new, vcs = RspecProfiling.config.vcs.new) @collector = collector @vcs = vcs end
Public Instance Methods
example_finished(*args)
click to toggle source
# File lib/rspec_profiling/run.rb, line 28 def example_finished(*args) collector.insert({ branch: vcs.branch, commit_hash: vcs.sha, date: vcs.time, file: @current_example.file, line_number: @current_example.line_number, description: @current_example.description, status: @current_example.status, exception: @current_example.exception, time: @current_example.time, query_count: @current_example.query_count, query_time: @current_example.query_time, request_count: @current_example.request_count, request_time: @current_example.request_time }) end
Also aliased as: example_passed, example_failed
example_started(example)
click to toggle source
# File lib/rspec_profiling/run.rb, line 23 def example_started(example) example = example.example if example.respond_to?(:example) @current_example = Example.new(example) end
start(*args)
click to toggle source
# File lib/rspec_profiling/run.rb, line 18 def start(*args) start_counting_queries start_counting_requests end
Private Instance Methods
start_counting_queries()
click to toggle source
# File lib/rspec_profiling/run.rb, line 53 def start_counting_queries ActiveSupport::Notifications.subscribe("sql.active_record") do |name, start, finish, id, query| @current_example.try(:log_query, query, start, finish) end end
start_counting_requests()
click to toggle source
# File lib/rspec_profiling/run.rb, line 59 def start_counting_requests ActiveSupport::Notifications.subscribe("process_action.action_controller") do |name, start, finish, id, request| @current_example.try(:log_request, request, start, finish) end end