From d348df5f7cada6c744b18793de1622315c036277 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eloy=20Dur=C3=A1n?= Date: Fri, 10 Aug 2012 23:20:44 +0200 Subject: [PATCH] Fix IO.popen call on Ruby 1.9.x. Fixes #15. --- Ruby/Gemfile.lock | 2 +- Ruby/lib/terminal-notifier.rb | 2 +- Ruby/spec/terminal-notifier_spec.rb | 6 +++++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Ruby/Gemfile.lock b/Ruby/Gemfile.lock index 5f8e0aa..ce25758 100644 --- a/Ruby/Gemfile.lock +++ b/Ruby/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - terminal-notifier (1.3.0) + terminal-notifier (1.4.1) GEM remote: http://rubygems.org/ diff --git a/Ruby/lib/terminal-notifier.rb b/Ruby/lib/terminal-notifier.rb index e2f7908..2453bb3 100644 --- a/Ruby/lib/terminal-notifier.rb +++ b/Ruby/lib/terminal-notifier.rb @@ -17,7 +17,7 @@ def self.execute(verbose, options) command = Shellwords.shelljoin(command) end result = '' - IO.popen(*command) do |stdout| + IO.popen(command) do |stdout| output = stdout.read STDOUT.print output if verbose result << output diff --git a/Ruby/spec/terminal-notifier_spec.rb b/Ruby/spec/terminal-notifier_spec.rb index 9d8170b..e677b12 100644 --- a/Ruby/spec/terminal-notifier_spec.rb +++ b/Ruby/spec/terminal-notifier_spec.rb @@ -15,10 +15,14 @@ require 'shellwords' command = Shellwords.shelljoin(command) end - IO.expects(:popen).with(*command).yields(StringIO.new('output')) + IO.expects(:popen).with(command).yields(StringIO.new('output')) TerminalNotifier.execute(false, :message => 'ZOMG') end + it "returns the result output of the command" do + TerminalNotifier.execute(false, 'help' => '').should == `'#{TerminalNotifier::BIN_PATH}' -help` + end + it "sends a notification" do TerminalNotifier.expects(:execute).with(false, :message => 'ZOMG', :group => 'important stuff') TerminalNotifier.notify('ZOMG', :group => 'important stuff')