Class: XSpec::Scheduler::Serial

Inherits:
Object
  • Object
show all
Defined in:
lib/xspec/schedulers.rb

Overview

The serial scheduler, unsurprisingly, runs all units of works serially in a loop. It is about as simple a scheduler as you can imagine. Parents are responsible for actually executing the work.

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Serial

Returns a new instance of Serial.



11
12
13
# File 'lib/xspec/schedulers.rb', line 11

def initialize(opts = {})
  @clock = opts.fetch(:clock, ->{ Time.now.to_f })
end

Instance Method Details

#run(context, config) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/xspec/schedulers.rb', line 15

def run(context, config)
  notifier = config.fetch(:notifier)
  notifier.run_start(config)

  context.nested_units_of_work.each do |x|
    notifier.evaluate_start(x)

    start_time  = clock.()
    errors      = x.immediate_parent.execute(x)
    finish_time = clock.()

    result = ExecutedUnitOfWork.new(x, errors, finish_time - start_time)
    notifier.evaluate_finish(result)
  end

  notifier.run_finish
end