Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Helpfully yell if the user forgot to splat their array to Rubysh()

  • Loading branch information...
commit e0ad42a65e8916addad542cccd06891ec6741707 1 parent 83f744b
@gdb authored
Showing with 8 additions and 0 deletions.
  1. +4 −0 lib/rubysh/command.rb
  2. +4 −0 test/unit/lib/rubysh/command.rb
View
4 lib/rubysh/command.rb
@@ -3,6 +3,10 @@ class Command < BaseCommand
attr_accessor :raw_args, :directives, :args
def initialize(args)
+ if args.length == 1 && args[0].kind_of?(Array)
+ raise "It looks like you created a Rubysh::Command with a singleton nested array: #{args.inspect}. That'll never be runnable, and probably indicates you forgot a splat somewhere."
+ end
+
@raw_args = args
@directives = []
@args = nil
View
4 test/unit/lib/rubysh/command.rb
@@ -15,6 +15,10 @@ class CommandTest < UnitTest
command = Rubysh::Command.new(['ls', '/tmp', directive, '/foo'])
assert_equal('Command: ls /tmp 2>&1 /foo', command.to_s)
end
+
+ it 'raises an error when given an unsplatted array' do
+ assert_raises(RuntimeError) {Rubysh::Command.new([['ls', 'stuff']])}
+ end
end
describe 'when calling #run_async' do
Please sign in to comment.
Something went wrong with that request. Please try again.