diff --git a/lib/guard/phpunit.rb b/lib/guard/phpunit.rb index 76f16da..820d037 100644 --- a/lib/guard/phpunit.rb +++ b/lib/guard/phpunit.rb @@ -3,7 +3,7 @@ module Guard - # The PHPUnit guard gets notified about system + # The PHPUnit guard gets notified about system # events. # class PHPUnit < Guard @@ -91,7 +91,7 @@ def update_failed_paths(tests_passed, paths) if tests_passed @failed_paths -= paths else - @failed_paths += paths + @failed_paths += paths end end diff --git a/lib/guard/phpunit/formatter.rb b/lib/guard/phpunit/formatter.rb index 36e2d91..9a9ffac 100644 --- a/lib/guard/phpunit/formatter.rb +++ b/lib/guard/phpunit/formatter.rb @@ -3,7 +3,7 @@ class PHPUnit # The Guard::PHPUnit formatter parses the output # of phpunit which gets printed by the progress - # printer. + # printer. # module Formatter class << self @@ -31,16 +31,16 @@ def parse_output(text) # # @param [String, Array] string_list the words # @param [String] text the tests output - # @return [Integer] the total number assigned to the words + # @return [Integer] the total number assigned to the words # def look_for_words_in(strings_list, text) count = 0 strings_list = Array(strings_list) strings_list.each do |s| text =~ %r{ - (\d+) # count of what we are looking for + (\d+) # count of what we are looking for [ ] # then a space - #{s}s? # then the string + #{s}s? # then the string .* # then whatever \Z # start looking at the end of the text }x @@ -53,7 +53,7 @@ def look_for_words_in(strings_list, text) # # @param [String] text the tests output # @return [Integer] the duration - # + # def look_for_duration_in(text) text =~ %r{Finished in (\d)+ seconds?.*\Z}m $1.nil? ? 0 : $1.to_i diff --git a/lib/guard/phpunit/runner.rb b/lib/guard/phpunit/runner.rb index 32d2829..83bde28 100644 --- a/lib/guard/phpunit/runner.rb +++ b/lib/guard/phpunit/runner.rb @@ -10,7 +10,7 @@ class PHPUnit module Runner class << self - # The exittcode phpunit returns when the tests contain failures + # The exittcode phpunit returns when the tests contain failures # PHPUNIT_FAILURES_EXITCODE = 1 @@ -22,14 +22,14 @@ class << self # about the results. # # @param [Array] path to the tests files. - # @param (see PHPUnit#initialize) + # @param (see PHPUnit#initialize) # @return [Boolean] whether the tests were run successfully # def run(paths, options = {}) paths = Array(paths) - + return false if paths.empty? - + unless phpunit_exists? UI.error('phpunit is not installed on your machine.', :reset => true) return false @@ -49,7 +49,7 @@ def phpunit_exists? system('which phpunit > /dev/null 2>&1') end - # Executes the testing command on the tests + # Executes the testing command on the tests # and returns the status of this process. # # @param (see #run) @@ -77,7 +77,7 @@ def run_tests(paths, options) if $?.success? or tests_contain_failures? or tests_contain_errors? notify_results(output, options) else - notify_failure(options) + notify_failure(options) end $?.success? @@ -112,7 +112,7 @@ def notify_failure(options) return if options[:notification] == false Notifier.notify('Failed! Check the console', :title => 'PHPUnit results', :image => :failed) end - + # Checks the exitstatus of the phpunit command # for a sign of failures in the tests. # @@ -146,7 +146,7 @@ def create_tests_folder_for(paths) end end - # Creates symbolic links inside the folder pointing + # Creates symbolic links inside the folder pointing # back to the paths. # # @see #create_tests_folder_for @@ -162,11 +162,11 @@ def symlink_paths_to_tests_folder(paths, folder) end # Generates the phpunit command for the tests paths. - # + # # @param (see #run) # @param (see #run) # @see #run_tests - # + # def phpunit_command(path, options) formatter_path = File.join( File.dirname(__FILE__), 'formatters', 'PHPUnit-Progress') diff --git a/spec/guard/phpunit/formatter_spec.rb b/spec/guard/phpunit/formatter_spec.rb index bdf944c..2e2560f 100644 --- a/spec/guard/phpunit/formatter_spec.rb +++ b/spec/guard/phpunit/formatter_spec.rb @@ -4,7 +4,7 @@ describe '.parse_output' do context 'when all tests pass' do it 'returns a hash containing the tests result' do - output = load_phpunit_output('passing') + output = load_phpunit_output('passing') subject.parse_output(output).should == { :tests => 2, :failures => 0, :errors => 0, :pending => 0, @@ -15,7 +15,7 @@ context 'when all tests fail' do it 'returns a hash containing the tests result' do - output = load_phpunit_output('failing') + output = load_phpunit_output('failing') subject.parse_output(output).should == { :tests => 2, :failures => 2, :errors => 0, :pending => 0, @@ -26,7 +26,7 @@ context 'when tests are skipped or incomplete' do it 'returns a hash containing the tests result' do - output = load_phpunit_output('skipped_and_incomplete') + output = load_phpunit_output('skipped_and_incomplete') subject.parse_output(output).should == { :tests => 3, :failures => 0, :errors => 0, :pending => 3, @@ -37,7 +37,7 @@ context 'when tests have mixed statuses' do it 'returns a hash containing the tests result' do - output = load_phpunit_output('mixed') + output = load_phpunit_output('mixed') subject.parse_output(output).should == { :tests => 13, :failures => 3, :errors => 1, :pending => 3, diff --git a/spec/guard/phpunit/notifier_spec.rb b/spec/guard/phpunit/notifier_spec.rb index bcd383a..68cc55a 100644 --- a/spec/guard/phpunit/notifier_spec.rb +++ b/spec/guard/phpunit/notifier_spec.rb @@ -22,7 +22,7 @@ subject.notify_results( :tests => 10, :failures => 0, :errors => 0, :pending => 0, - :duration => 5 + :duration => 5 ) end end @@ -36,7 +36,7 @@ subject.notify_results( :tests => 10, :failures => 3, :errors => 4, :pending => 0, - :duration => 6 + :duration => 6 ) end end diff --git a/spec/guard/phpunit/runner_spec.rb b/spec/guard/phpunit/runner_spec.rb index f99f365..d148265 100644 --- a/spec/guard/phpunit/runner_spec.rb +++ b/spec/guard/phpunit/runner_spec.rb @@ -10,11 +10,11 @@ before do FileUtils.stub(:ln_s) FileUtils.stub(:mkdir_p) - + subject.stub(:execute_command) subject.stub(:phpunit_exists?).and_return(true) notifier.stub(:notify_results) - + system("`exit 0`") # prime the $? variable end @@ -54,10 +54,10 @@ it 'prints the tests output to the console' do output = load_phpunit_output('passing') subject.stub(:notify_start) - subject.stub(:execute_command).and_return(output) - + subject.stub(:execute_command).and_return(output) + ui.should_receive(:info).with(output) - + subject.run( ['tests'] ) end @@ -65,7 +65,7 @@ it 'parses the tests output' do output = load_phpunit_output('passing') subject.stub(:execute_command).and_return(output) - + formatter.should_receive(:parse_output).with(output) subject.run( ['tests'] ) diff --git a/spec/guard/phpunit_spec.rb b/spec/guard/phpunit_spec.rb index 93418b4..27a8dd9 100644 --- a/spec/guard/phpunit_spec.rb +++ b/spec/guard/phpunit_spec.rb @@ -114,13 +114,13 @@ it 'throws :task_has_failed when an error occurs' do runner.should_receive(:run).with(['tests/firstTest.php', 'tests/secondTest.php'], anything).and_return(false) expect { subject.run_on_change ['tests/firstTest.php', 'tests/secondTest.php'] }.to throw_symbol :task_has_failed - end + end it 'passes the options to the runner' do runner.should_receive(:run).with(anything, hash_including(defaults)).and_return(true) subject.run_on_change ['tests/firstTest.php', 'tests/secondTest.php'] end - + context 'when tests fail' do before do runner.stub(:run).and_return(false) @@ -163,14 +163,14 @@ expect { subject.run_on_change ['tests/firstTest.php'] }.to throw_symbol :task_has_failed subject.run_on_change ['tests/firstTest.php'] end - + it 'calls #run_all (2)' do expect { subject.run_all }.to throw_symbol :task_has_failed subject.should_receive(:run_all) subject.run_on_change ['tests/firstTest.php'] end end - + context 'with the :all_after_pass option set to false' do subject { Guard::PHPUnit.new(nil, :all_after_pass => false) }