Class: SpecRunQueue::SystemRunner

Inherits:
Object
  • Object
show all
Defined in:
lib/spec_run_queue/system_runner.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ SystemRunner

Returns a new instance of SystemRunner.



5
6
7
8
# File 'lib/spec_run_queue/system_runner.rb', line 5

def initialize(options = {})
  @options = options
  @notifiers = []
end

Instance Attribute Details

#notifiersObject (readonly)

Returns the value of attribute notifiers.



3
4
5
# File 'lib/spec_run_queue/system_runner.rb', line 3

def notifiers
  @notifiers
end

#optionsObject (readonly)

Returns the value of attribute options.



3
4
5
# File 'lib/spec_run_queue/system_runner.rb', line 3

def options
  @options
end

Instance Method Details

#add_notifier(notifier) ⇒ Object



18
19
20
# File 'lib/spec_run_queue/system_runner.rb', line 18

def add_notifier(notifier)
  @notifiers << notifier
end

#rspec_binObject



10
11
12
# File 'lib/spec_run_queue/system_runner.rb', line 10

def rspec_bin
  options.fetch(:rspec_bin, 'rspec')
end

#rspec_formatObject



14
15
16
# File 'lib/spec_run_queue/system_runner.rb', line 14

def rspec_format
  options.fetch(:rspec_format, 'nested')
end

#run_spec(instruction) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/spec_run_queue/system_runner.rb', line 22

def run_spec(instruction)
  unless sane_instruction?(instruction)
    $stderr.puts "Insane instruction #{instruction.inspect}"
    return
  end

  begin
    cmd = "#{rspec_bin} -f #{rspec_format} --drb"
    cmd << " #{instruction[:target]}"
    cmd << ":#{instruction[:line]}" if instruction[:line]
    puts "Running command #{cmd}"
    output = run_cmd(cmd)

    output_to_notifiers(output)
  rescue => e
    shutdown_message = "Exception #{e.class} occurred, shutting down"
    output_to_notifiers(shutdown_message, :use_full_message => true)
    sleep(1)
    raise e
  end
end