Skip to content

Commit

Permalink
Fix IO.popen call on Ruby 1.9.x. Fixes #15.
Browse files Browse the repository at this point in the history
  • Loading branch information
alloy committed Aug 10, 2012
1 parent c4a4d0a commit d348df5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion 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/
Expand Down
2 changes: 1 addition & 1 deletion Ruby/lib/terminal-notifier.rb
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion Ruby/spec/terminal-notifier_spec.rb
Expand Up @@ -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')
Expand Down

0 comments on commit d348df5

Please sign in to comment.