Class: Specwrk::Worker::CompletionFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/specwrk/worker/completion_formatter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCompletionFormatter

Returns a new instance of CompletionFormatter.



10
11
12
# File 'lib/specwrk/worker/completion_formatter.rb', line 10

def initialize
  @examples = []
end

Instance Attribute Details

#examplesObject (readonly)

Returns the value of attribute examples.



8
9
10
# File 'lib/specwrk/worker/completion_formatter.rb', line 8

def examples
  @examples
end

Instance Method Details

#stop(group_notification) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/specwrk/worker/completion_formatter.rb', line 14

def stop(group_notification)
  group_notification.notifications.map do |notification|
    hash = {
      id: notification.example.id,
      full_description: notification.example.full_description,
      status: notification.example.execution_result.status,
      file_path: notification.example.[:file_path],
      line_number: notification.example.[:line_number],
      started_at: notification.example.execution_result.started_at.iso8601(6),
      finished_at: notification.example.execution_result.finished_at.iso8601(6),
      run_time: notification.example.execution_result.run_time
    }

    if (e = notification.example.exception)
      hash[:exception] = {
        class: e.class.name,
        message: e.message,
        backtrace: notification.formatted_backtrace
      }
    end

    examples << hash
  end
end