From 418396bfd093ab0b5a944bcff22c1ef311910ac4 Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 12 Dec 2016 18:52:03 +0100 Subject: [PATCH] Update terminal-notifier_spec.rb Add test case for arguments starting with a dash. --- Ruby/spec/terminal-notifier_spec.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Ruby/spec/terminal-notifier_spec.rb b/Ruby/spec/terminal-notifier_spec.rb index eaa59b7..226249c 100644 --- a/Ruby/spec/terminal-notifier_spec.rb +++ b/Ruby/spec/terminal-notifier_spec.rb @@ -15,6 +15,13 @@ IO.expects(:popen).with(command).yields(StringIO.new('output')) TerminalNotifier.execute(false, :message => '[ZOMG] "OH YEAH"') end + + it "correctly escapes arguments that start with a dash" do + command = [TerminalNotifier::BIN_PATH, '-message', ' -kittens', '-title', ' -rule'] + command = Shellwords.join(command) if RUBY_VERSION < '1.9' + IO.expects(:popen).with(command).yields(StringIO.new('output')) + TerminalNotifier.execute(false, :message => '-kittens', :title => '-rule') + end it "returns the result output of the command" do TerminalNotifier.execute(false, 'help' => '').should == `'#{TerminalNotifier::BIN_PATH}' -help`