Skip to content

Commit

Permalink
Fix #2 - Add support for Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Maher4Ever committed Aug 2, 2012
1 parent ba0bca1 commit ff826a5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
9 changes: 8 additions & 1 deletion lib/guard/phpunit/runner.rb
@@ -1,3 +1,4 @@
require 'rbconfig'
require 'tmpdir'
require 'fileutils'

Expand Down Expand Up @@ -46,7 +47,13 @@ def run(paths, options = {})
# @return [Boolean] The status of phpunit
#
def phpunit_exists?
system('which phpunit > /dev/null 2>&1')
command = if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/
'where phpunit > nul 2>&1'
else
'which phpunit > /dev/null 2>&1'
end

system(command)
end

# Executes the testing command on the tests
Expand Down
8 changes: 4 additions & 4 deletions spec/guard/phpunit/runner_spec.rb
Expand Up @@ -15,7 +15,7 @@
subject.stub(:phpunit_exists?).and_return(true)
notifier.stub(:notify_results)

system("`exit 0`") # prime the $? variable
system("exit 0") # prime the $? variable
end

context 'when passed an empty paths list' do
Expand Down Expand Up @@ -80,7 +80,7 @@
end

it 'notifies about the tests output even when they contain failures' do
system("`exit 1`") # prime the $? variable
system("exit 1") # prime the $? variable
output = load_phpunit_output('failing')
subject.stub(:execute_command).and_return(output)
subject.should_receive(:notify_results).with(output, anything())
Expand All @@ -89,7 +89,7 @@
end

it 'notifies about the tests output even when they contain errors' do
system("`exit 2`") # prime the $? variable
system("exit 2") # prime the $? variable
output = load_phpunit_output('errors')
subject.stub(:execute_command).and_return(output)
subject.should_receive(:notify_results).with(output, anything())
Expand All @@ -106,7 +106,7 @@

context 'when PHPUnit fails to execute' do
before do
system("`exit 255`") # prime the $? variable
system("exit 255") # prime the $? variable
notifier.stub(:notify)
end

Expand Down

0 comments on commit ff826a5

Please sign in to comment.