Permalink
Browse files

Correctly handle duplicate named targets

  • Loading branch information...
gdb committed Oct 13, 2013
1 parent 80056d2 commit 22a1937c50abfb739be033b88a0a6d04d1400845
Showing with 12 additions and 2 deletions.
  1. +2 −2 lib/rubysh/command.rb
  2. +10 −0 test/unit/lib/rubysh/command.rb
View
@@ -53,11 +53,11 @@ def set_stdin(runner, value)
end
def status(runner)
- state(runner)[:subprocess].status
+ (subprocess = state(runner)[:subprocess]) ? subprocess.status : nil
end
def pid(runner)
- state(runner)[:subprocess].pid
+ (subprocess = state(runner)[:subprocess]) ? subprocess.pid : nil
end
def prepare!(runner)
@@ -16,5 +16,15 @@ class CommandTest < UnitTest
assert_equal('Command: ls /tmp 2>&1 /foo', command.to_s)
end
end
+
+ describe 'when calling #run_async' do
+ it 'raises the expected error when duplicating a named target' do
+ cmd = Rubysh::Command.new(['ls', '/tmp', Rubysh.>, Rubysh.>])
+ error = assert_raises(Rubysh::Error::BaseError) do
+ cmd.run_async
+ end
+ assert_match(/already has a named target/, error.message)
+ end
+ end
end
end

0 comments on commit 22a1937

Please sign in to comment.