Class: RspecStarter::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec_starter/runner.rb

Overview

This class implements the main control loop that processes steps. It maintains a list of steps and executes each one. Steps can be skipped if command line options, or other options dictate turn off the step.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(environment) ⇒ Runner

Returns a new instance of Runner.



7
8
9
10
# File 'lib/rspec_starter/runner.rb', line 7

def initialize(environment)
  @environment = environment
  @steps = @environment.step_contexts.collect { |step_context| step_context.instantiate(self) }
end

Instance Attribute Details

#environmentObject (readonly)

Returns the value of attribute environment.



5
6
7
# File 'lib/rspec_starter/runner.rb', line 5

def environment
  @environment
end

Instance Method Details

#largest_exit_statusObject



21
22
23
24
25
26
27
# File 'lib/rspec_starter/runner.rb', line 21

def largest_exit_status
  @steps.inject(0) do |max, step|
    # If a step doesn't execute, it's exit_status will be nil.
    current = step.exit_status || 0
    [max, current].max
  end
end

#runObject



12
13
14
15
16
17
18
19
# File 'lib/rspec_starter/runner.rb', line 12

def run
  @steps.each do |step|
    next if step.should_skip?

    print "[#{step.id}] "
    step.run
  end
end