Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
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...
commit 8c0df12dc392c1f645e5466dd36342571cfb1a17 1 parent 19f3156
@Maher4Ever authored
Showing with 6 additions and 11 deletions.
  1. +5 −9 lib/guard/phpunit/runner.rb
  2. +1 −2  spec/guard/phpunit/runner_spec.rb
View
14 lib/guard/phpunit/runner.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
View
3  spec/guard/phpunit/runner_spec.rb
@@ -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'] )
Please sign in to comment.
Something went wrong with that request. Please try again.