spec/invoker/commander_spec.rb in invoker-1.3.1 vs spec/invoker/commander_spec.rb in invoker-1.3.2
- old
+ new
@@ -16,13 +16,13 @@
end
describe "#start_process" do
describe "when not daemonized" do
before do
- invoker_config.stubs(:processes).returns(
- [OpenStruct.new(:label => "foobar", :cmd => "foobar_command", :dir => ENV['HOME'])]
- )
+ processes = [OpenStruct.new(:label => "foobar", :cmd => "foobar_command", :dir => ENV['HOME'])]
+ invoker_config.stubs(:processes).returns(processes)
+ invoker_config.stubs(:autorunnable_processes).returns(processes)
@commander = Invoker::Commander.new
Invoker.commander = @commander
end
after do
@@ -49,13 +49,13 @@
end
end
describe "when daemonized" do
before do
- invoker_config.stubs(:processes).returns(
- [OpenStruct.new(:label => "foobar", :cmd => "foobar_command", :dir => ENV['HOME'])]
- )
+ processes = [OpenStruct.new(:label => "foobar", :cmd => "foobar_command", :dir => ENV['HOME'])]
+ invoker_config.stubs(:processes).returns(processes)
+ invoker_config.stubs(:autorunnable_processes).returns(processes)
@commander = Invoker::Commander.new
Invoker.commander = @commander
Invoker.daemonize = true
end
@@ -81,9 +81,35 @@
expect(worker).not_to be_nil
expect(worker.command_label).to eq('foobar')
pipe_end_worker = @commander.process_manager.open_pipes[worker.pipe_end.fileno]
expect(pipe_end_worker).not_to be_nil
+ end
+ end
+ end
+
+ describe 'disable_autorun option' do
+ context 'autorun is disabled for a process' do
+ before do
+ @processes = [
+ OpenStruct.new(:label => "foobar", :cmd => "foobar_command", :dir => ENV['HOME']),
+ OpenStruct.new(:label => "panda", :cmd => "panda_command", :dir => ENV['HOME'], :disable_autorun => true)
+ ]
+ invoker_config.stubs(:processes).returns(@processes)
+ invoker_config.stubs(:autorunnable_processes).returns([@processes.first])
+
+ @commander = Invoker::Commander.new
+ end
+
+ it "doesn't run process" do
+ @commander.expects(:install_interrupt_handler)
+ @commander.process_manager.expects(:run_power_server)
+ @commander.expects(:at_exit)
+ @commander.expects(:start_event_loop)
+
+ @commander.process_manager.expects(:start_process).with(@processes[0])
+ @commander.process_manager.expects(:start_process).with(@processes[1]).never
+ @commander.start_manager
end
end
end
describe "#runnables" do