Class: CapturefulFormatter::Formatter

Inherits:
RSpec::Core::Formatters::BaseFormatter
  • Object
show all
Defined in:
lib/captureful_formatter/formatter.rb

Instance Method Summary collapse

Instance Method Details

#example_failed(notification) ⇒ Object



55
56
57
58
59
# File 'lib/captureful_formatter/formatter.rb', line 55

def example_failed notification
  return unless @should_capture
  @current_scenario.status = :failed
  @current_scenario.exception = notification.exception
end

#example_group_finished(notification) ⇒ Object



25
26
27
28
29
30
31
32
# File 'lib/captureful_formatter/formatter.rb', line 25

def example_group_finished(notification)
  if notification.group.[:parent_example_group].nil?
    @features.push @current_feature
    @should_capture = false
  else
    @current_feature.scenarios.push @current_scenario
  end
end

#example_group_started(notification) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/captureful_formatter/formatter.rb', line 16

def example_group_started notification
  if notification.group.[:parent_example_group].nil?
    @should_capture = CapturefulFormatter.configuration.target_type.include? notification.group.[:type]
    @current_feature = CapturefulFormatter::Structures::Feature.new(notification)
  else
    @current_scenario = CapturefulFormatter::Structures::Scenario.new(notification)
  end
end

#example_passed(notification) ⇒ Object



44
45
46
47
48
# File 'lib/captureful_formatter/formatter.rb', line 44

def example_passed notification
  return unless @should_capture

  @current_scenario.status = :passed
end

#example_pending(notification) ⇒ Object



50
51
52
53
# File 'lib/captureful_formatter/formatter.rb', line 50

def example_pending notification
  return unless @should_capture
  @current_scenario.status = :pending
end

#example_started(notification) ⇒ Object



34
35
36
# File 'lib/captureful_formatter/formatter.rb', line 34

def example_started notification
  return unless @should_capture
end

#start(notification) ⇒ Object



11
12
13
14
# File 'lib/captureful_formatter/formatter.rb', line 11

def start notification
  @should_capture = false
  @features = []
end

#step_started(notification) ⇒ Object



38
39
40
41
42
# File 'lib/captureful_formatter/formatter.rb', line 38

def step_started notification
  return unless @should_capture
  @current_scenario.steps.push CapturefulFormatter::Structures::Step.new(notification)
  save_step_sessions
end

#stop(notification) ⇒ Object



61
62
63
64
65
66
67
# File 'lib/captureful_formatter/formatter.rb', line 61

def stop notification
  publish_reports
rescue => e
  CapturefulFormatter.configuration.logger.error e.to_s
ensure
  cleanup_reports
end