From 153468eead580f67e51f5b8105d277f3bbbe6ded Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dennis=20G=C3=BCnnewig?= Date: Mon, 9 May 2016 15:01:57 +0200 Subject: [PATCH] Prevent duplicate output for commands. Closes #374 If a users decided to use `run_simple`, a command is stopped twice: 1. After the configured wait time 2. On the end of test suite via terminate_all_commands This makes the output appear twice. This is fixed by this PR. It also make a method call fail: 1. Command already stopped, `#stop` is called again 2. Comannd has not been started, but ist `#stop`ped --- lib/aruba/command.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/aruba/command.rb b/lib/aruba/command.rb index 8073b95f2..e3b681b7d 100644 --- a/lib/aruba/command.rb +++ b/lib/aruba/command.rb @@ -48,6 +48,8 @@ def initialize(command, opts = {}) # Stop command def stop(*) + fail Aruba::UserError, 'Please start a command first, before stopping it' if __getobj__.stopped? + __getobj__.stop event_bus.notify Events::CommandStopped.new(self) @@ -56,6 +58,8 @@ def stop(*) # Terminate command def terminate(*) + return if __getobj__.stopped? + __getobj__.terminate event_bus.notify Events::CommandStopped.new(self) @@ -64,6 +68,8 @@ def terminate(*) # Start command def start + fail Aruba::UserError, 'Please stop a command first, before starting it' if __getobj__.started? + __getobj__.start event_bus.notify Events::CommandStarted.new(self)