Class: RSpec::Core::Formatters::TurnipFormatter

Inherits:
BaseFormatter
  • Object
show all
Defined in:
lib/rspec/core/formatters/turnip_formatter.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(output) ⇒ TurnipFormatter

Returns a new instance of TurnipFormatter.



24
25
26
27
# File 'lib/rspec/core/formatters/turnip_formatter.rb', line 24

def initialize(output)
  super(output)
  @scenarios = []
end

Instance Attribute Details

#scenariosObject

Returns the value of attribute scenarios.



14
15
16
# File 'lib/rspec/core/formatters/turnip_formatter.rb', line 14

def scenarios
  @scenarios
end

Class Method Details

.formatted_backtrace(example, exception = nil) ⇒ Object



18
19
20
21
22
# File 'lib/rspec/core/formatters/turnip_formatter.rb', line 18

def self.formatted_backtrace(example, exception = nil)
  exception = example.exception if exception.nil?
  formatter = RSpec.configuration.backtrace_formatter
  formatter.format_backtrace(exception.backtrace, example.)
end

Instance Method Details

#dump_summary(summary) ⇒ Object



29
30
31
32
33
34
35
36
37
# File 'lib/rspec/core/formatters/turnip_formatter.rb', line 29

def dump_summary(summary)
  print_params = {
    scenarios:      scenarios,
    failed_count:   summary.failure_count,
    pending_count:  summary.pending_count,
    total_time:     summary.duration
  }
  output_html(print_params)
end

#example_failed(notification) ⇒ Object



49
50
51
52
# File 'lib/rspec/core/formatters/turnip_formatter.rb', line 49

def example_failed(notification)
  scenario = ::TurnipFormatter::Resource::Scenario::Failure.new(notification.example)
  scenarios << scenario
end

#example_passed(notification) ⇒ Object



39
40
41
42
# File 'lib/rspec/core/formatters/turnip_formatter.rb', line 39

def example_passed(notification)
  scenario = ::TurnipFormatter::Resource::Scenario::Pass.new(notification.example)
  scenarios << scenario
end

#example_pending(notification) ⇒ Object



44
45
46
47
# File 'lib/rspec/core/formatters/turnip_formatter.rb', line 44

def example_pending(notification)
  scenario = ::TurnipFormatter::Resource::Scenario::Pending.new(notification.example)
  scenarios << scenario
end