Class: Rectify::RSpec::DatabaseReporter::Reporter

Inherits:
Object
  • Object
show all
Defined in:
lib/rectify/rspec/database_reporter/reporter.rb

Instance Method Summary collapse

Constructor Details

#initializeReporter

Returns a new instance of Reporter.



34
35
36
# File 'lib/rectify/rspec/database_reporter/reporter.rb', line 34

def initialize
  @query_stats = QueryStats.new
end

Instance Method Details

#example_started(notification) ⇒ Object



45
46
47
# File 'lib/rectify/rspec/database_reporter/reporter.rb', line 45

def example_started(notification)
  @current_example = notification.example
end

#start(_) ⇒ Object



38
39
40
41
42
43
# File 'lib/rectify/rspec/database_reporter/reporter.rb', line 38

def start(_)
  ActiveSupport::Notifications
    .subscribe("sql.active_record") do |_, start, finish, _, query|
      query_stats.add(current_example, start, finish, query)
    end
end

#start_dump(_) ⇒ Object



49
50
51
# File 'lib/rectify/rspec/database_reporter/reporter.rb', line 49

def start_dump(_)
  Display.new(query_stats).render
end