Class: CapturefulFormatter::Formatter

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

Defined Under Namespace

Classes: Example, FailInfo

Instance Method Summary collapse

Instance Method Details

#example_failed(notification) ⇒ Object



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

def example_failed notification
  return unless @should_capture
  @examples[@current_example_hash].status = :failed
  @examples[@current_example_hash].fail_info = FailInfo.new(notification.exception.to_s, notification.formatted_backtrace.dup)
end

#example_group_finished(notification) ⇒ Object



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

def example_group_finished(notification)
  @should_capture = false
  @group_level -= 1
  @group_examples.pop
end

#example_group_started(notification) ⇒ Object



22
23
24
25
26
# File 'lib/captureful_formatter/formatter.rb', line 22

def example_group_started notification
  @should_capture = CapturefulFormatter.configuration.target_type.include? notification.group.[:type]
  @group_level += 1
  @group_examples.push notification.group.description
end

#example_passed(notification) ⇒ Object



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

def example_passed notification
  return unless @should_capture
  @examples[@current_example_hash].status = :passed
end

#example_pending(notification) ⇒ Object



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

def example_pending notification
  return unless @should_capture
  @examples[@current_example_hash].status = :pending
end

#example_started(notification) ⇒ Object



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

def example_started notification
  return unless @should_capture
  @current_example_hash = Digest::MD5.hexdigest(@group_examples.join())
  @examples[@current_example_hash] = Example.new(@group_examples.dup, [] , nil, nil)
end

#start(notification) ⇒ Object



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

def start notification
  @should_capture = false
  @examples = {}
  @group_level = 0
  @group_examples = []
end

#step_started(notification) ⇒ Object



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

def step_started notification
  save_step_sessions notification.description
end

#stop(notification) ⇒ Object



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

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