Class: Specjour::Worker

Inherits:
Object
  • Object
show all
Includes:
Protocol, SocketHelpers
Defined in:
lib/specjour/worker.rb

Constant Summary

Constants included from Protocol

Protocol::TERMINATOR, Protocol::TERMINATOR_REGEXP

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from SocketHelpers

#hostname, #ip_from_hostname

Methods included from Protocol

#dump_object, #load_object

Constructor Details

#initialize(project_path, printer_uri, number, batch_size) ⇒ Worker

Returns a new instance of Worker.



10
11
12
13
14
15
16
17
18
# File 'lib/specjour/worker.rb', line 10

def initialize(project_path, printer_uri, number, batch_size)
  @project_path = project_path
  @specs_to_run = specs_to_run
  @number = number.to_i
  @batch_size = batch_size.to_i
  self.printer_uri = printer_uri
  Rspec::DistributedFormatter.batch_size = batch_size
  set_env_variables
end

Instance Attribute Details

#batch_sizeObject (readonly)

Returns the value of attribute batch_size.



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

def batch_size
  @batch_size
end

#numberObject (readonly)

Returns the value of attribute number.



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

def number
  @number
end

#printer_uriObject

Returns the value of attribute printer_uri.



7
8
9
# File 'lib/specjour/worker.rb', line 7

def printer_uri
  @printer_uri
end

#project_pathObject (readonly)

Returns the value of attribute project_path.



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

def project_path
  @project_path
end

#specs_to_runObject (readonly)

Returns the value of attribute specs_to_run.



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

def specs_to_run
  @specs_to_run
end

Instance Method Details

#runObject



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/specjour/worker.rb', line 24

def run
  run_time = 0
  Dir.chdir(project_path)
  while test = connection.next_test
    run_time += Benchmark.realtime do
      run_test test
    end
  end
  connection.send_message(:worker_summary=, {:duration => sprintf("%6f", run_time)})
  connection.send_message(:done)
  connection.disconnect
end