Permalink
Browse files

Use a unified way to check for PHPUnit's existence

This removes the need to know the operating system we are running under

Updates #2
  • Loading branch information...
1 parent 19f3156 commit 8c0df12dc392c1f645e5466dd36342571cfb1a17 @Maher4Ever committed Aug 9, 2012
Showing with 6 additions and 11 deletions.
  1. +5 −9 lib/guard/phpunit/runner.rb
  2. +1 −2 spec/guard/phpunit/runner_spec.rb
@@ -1,4 +1,3 @@
-require 'rbconfig'
require 'tmpdir'
require 'fileutils'
@@ -47,13 +46,10 @@ def run(paths, options = {})
# @return [Boolean] The status of phpunit
#
def phpunit_exists?
- command = if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/
- 'where phpunit > nul 2>&1'
- else
- 'which phpunit > /dev/null 2>&1'
- end
-
- system(command)
+ `phpunit --version`
+ true
+ rescue Errno::ENOENT
+ false
end
# Executes the testing command on the tests
@@ -198,4 +194,4 @@ def execute_command(command)
end
end
end
-end
+end
@@ -31,8 +31,7 @@
end
it 'displays an error when phpunit is not installed' do
- subject.unstub(:phpunit_exists?)
- subject.stub(:system).and_return(false)
+ subject.stub(:phpunit_exists?).and_return(false)
ui.should_receive(:error).with('phpunit is not installed on your machine.', anything)
subject.run( ['tests'] )

0 comments on commit 8c0df12

Please sign in to comment.