Class: Paraspec::WorkerFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/paraspec/worker_formatter.rb

Instance Method Summary collapse

Constructor Details

#initialize(output) ⇒ WorkerFormatter

Returns a new instance of WorkerFormatter.



21
22
23
# File 'lib/paraspec/worker_formatter.rb', line 21

def initialize(output)
  @master_client = output.master_client
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, args) ⇒ Object



49
50
# File 'lib/paraspec/worker_formatter.rb', line 49

def method_missing(m, args)
end

Instance Method Details

#dump_summary(notification) ⇒ Object



46
47
# File 'lib/paraspec/worker_formatter.rb', line 46

def dump_summary(notification)
end

#example_failed(notification) ⇒ Object



74
75
76
# File 'lib/paraspec/worker_formatter.rb', line 74

def example_failed(notification)
  example_notification(notification)
end

#example_notification(notification) ⇒ Object



64
65
66
67
68
69
70
71
72
# File 'lib/paraspec/worker_formatter.rb', line 64

def example_notification(notification)
  spec = {
    file_path: notification.example.[:file_path],
    scoped_id: notification.example.[:scoped_id],
  }
  execution_result = notification.example.execution_result
  @master_client.request('example-passed',
    spec: spec, result: execution_result)
end

#example_passed(notification) ⇒ Object



60
61
62
# File 'lib/paraspec/worker_formatter.rb', line 60

def example_passed(notification)
  example_notification(notification)
end

#example_pending(notification) ⇒ Object



78
79
80
# File 'lib/paraspec/worker_formatter.rb', line 78

def example_pending(notification)
  example_notification(notification)
end

#example_started(notification) ⇒ Object



52
53
54
55
56
57
58
# File 'lib/paraspec/worker_formatter.rb', line 52

def example_started(notification)
  spec = {
    file_path: notification.example.[:file_path],
    scoped_id: notification.example.[:scoped_id],
  }
  @master_client.request('notify-example-started', spec: spec)
end

#start(notification) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/paraspec/worker_formatter.rb', line 25

def start(notification)
  # Worker formatter receives start notification for each example
  # that it receives from supervisor.
  # The start notification contains number of examples to be executed,
  # and the load time.
  # The number of examples isn't useful because this is a subset of
  # all of the examples to be run, and we can't wait to receive
  # start notifications from all workers in the master thus
  # start notifications are not aggregatable.
  # Loading time is something that master can figure out on its own.
  # Therefore we do not forward start notifications to master.
  # At the same time master must create and send start notifications
  # to its own formatters, for example the junit formatter
  # requires a start notification for the summary report to work.
end

#stop(notification) ⇒ Object



41
42
43
44
# File 'lib/paraspec/worker_formatter.rb', line 41

def stop(notification)
  # Stop notification doesn't carry any new information, thus
  # master directly invokes reporter.stop from dump_summary.
end