Class: ParallelSpecs::RSpec::DashboardLogger

Inherits:
RSpec::Core::Formatters::BaseTextFormatter
  • Object
show all
Defined in:
lib/parallel_specs/rspec/dashboard_logger.rb

Instance Method Summary collapse

Constructor Details

#initialize(output) ⇒ DashboardLogger

Returns a new instance of DashboardLogger.



23
24
25
26
27
28
29
30
31
32
# File 'lib/parallel_specs/rspec/dashboard_logger.rb', line 23

def initialize(output)
  super

  path = ENV['PARALLEL_SPECS_DASHBOARD_EVENT_LOG']
  raise 'A dashboard event log env var is required for DashboardLogger' if path.to_s.empty?

  FileUtils.mkdir_p(File.dirname(path))
  @event_output = File.open(path, 'a')
  @event_output.sync = true
end

Instance Method Details

#closeObject



54
55
56
# File 'lib/parallel_specs/rspec/dashboard_logger.rb', line 54

def close(*)
  @event_output.close unless @event_output.closed?
end

#example_failed(notification) ⇒ Object



50
51
52
# File 'lib/parallel_specs/rspec/dashboard_logger.rb', line 50

def example_failed(notification)
  emit_example('example_failed', notification)
end

#example_passed(notification) ⇒ Object



42
43
44
# File 'lib/parallel_specs/rspec/dashboard_logger.rb', line 42

def example_passed(notification)
  emit_example('example_passed', notification)
end

#example_pending(notification) ⇒ Object



46
47
48
# File 'lib/parallel_specs/rspec/dashboard_logger.rb', line 46

def example_pending(notification)
  emit_example('example_pending', notification)
end

#example_started(notification) ⇒ Object



38
39
40
# File 'lib/parallel_specs/rspec/dashboard_logger.rb', line 38

def example_started(notification)
  emit_example('example_started', notification)
end

#start(notification) ⇒ Object



34
35
36
# File 'lib/parallel_specs/rspec/dashboard_logger.rb', line 34

def start(notification)
  emit(event: 'start', total: notification.count)
end