Skip to content

Commit

Permalink
Prevent duplicate output for commands. Closes #374
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Dennis Günnewig authored and maxmeyer committed Jun 17, 2016
1 parent 2b10c23 commit 290fa52
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/aruba/command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -56,6 +58,8 @@ def stop(*)

# Terminate command
def terminate(*)
return if __getobj__.stopped?

__getobj__.terminate
event_bus.notify Events::CommandStopped.new(self)

Expand All @@ -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)

Expand Down

0 comments on commit 290fa52

Please sign in to comment.