Class: XSpec::Evaluator::Serial

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

Overview

The serial evaluator, unsurprisingly, runs all units of works serially in a loop. It is about as simple an evaluator 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
14
# File 'lib/xspec/evaluators.rb', line 11

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

Instance Method Details

#run(context) ⇒ Object



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

def run(context)
  notifier.run_start

  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