Class: TurboTest::RSpec::ExampleFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/turbo_test/rspec/example_formatter.rb

Instance Method Summary collapse

Constructor Details

#initialize(packer) ⇒ ExampleFormatter

Returns a new instance of ExampleFormatter.



31
32
33
34
35
# File 'lib/turbo_test/rspec/example_formatter.rb', line 31

def initialize(packer)
  @packer = packer
  
  @colorizer = ::RSpec::Core::Formatters::ConsoleCodes
end

Instance Method Details

#dump_summary(summary) ⇒ Object



61
62
63
64
65
66
# File 'lib/turbo_test/rspec/example_formatter.rb', line 61

def dump_summary(summary)
  count = summary.examples.count
  
  @packer.write([:count, count])
  @packer.flush
end

#example_failed(notification) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/turbo_test/rspec/example_formatter.rb', line 46

def example_failed(notification)
  example = notification.example
  
  presenter = ::RSpec::Core::Formatters::ExceptionPresenter.new(example.exception, example)
  
  message = {
    description: example.full_description,
    location: example.location_rerun_argument,
    report: presenter.fully_formatted(nil, @colorizer),
  }
  
  @packer.write([:failed, message])
  @packer.flush
end

#example_finished(notification) ⇒ Object



41
42
43
44
# File 'lib/turbo_test/rspec/example_formatter.rb', line 41

def example_finished(notification)
  @packer.write([:finished, notification.example.id])
  @packer.flush
end

#outputObject



37
38
39
# File 'lib/turbo_test/rspec/example_formatter.rb', line 37

def output
  @packer
end