Class: Guard::PHPUnit
- Inherits:
-
Guard
- Object
- Guard
- Guard::PHPUnit
- Defined in:
- lib/guard/phpunit.rb,
lib/guard/phpunit/runner.rb,
lib/guard/phpunit/notifier.rb,
lib/guard/phpunit/inspector.rb,
lib/guard/phpunit/formatter.rb
Overview
The PHPUnit guard gets notified about system events.
Defined Under Namespace
Modules: Formatter, Inspector, Notifier, Runner
Constant Summary
- DEFAULT_OPTIONS =
{ :all_on_start => true, :all_after_pass => true, :keep_failed => true, :cli => nil, :tests_path => Dir.pwd }
Instance Method Summary (collapse)
-
- (PHPUnit) initialize(watchers = [], options = {})
constructor
Initialize Guard::PHPUnit.
-
- (Object) run_all
Gets called when all tests should be run.
-
- (Object) run_all_after_pass(tests_passed)
private
Runs all tests after the failed tests pass.
-
- (Object) run_on_change(paths)
Gets called when the watched tests have changes.
-
- (Object) start
Gets called once when Guard starts.
-
- (Object) update_failed_paths(tests_passed, paths)
private
Adds or removes path to the failed_paths bassed on the tests result.
Constructor Details
- (PHPUnit) initialize(watchers = [], options = {})
Initialize Guard::PHPUnit.
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/guard/phpunit.rb', line 32 def initialize(watchers = [], = {}) defaults = DEFAULT_OPTIONS.clone @options = defaults.merge() super(watchers, @options) @failed_paths = [] @previous_failed = false Inspector.tests_path = @options[:tests_path] end |
Instance Method Details
- (Object) run_all
Gets called when all tests should be run.
55 56 57 58 59 60 61 62 |
# File 'lib/guard/phpunit.rb', line 55 def run_all success = Runner.run([:tests_path], .merge( :message => 'Running all tests' )) @previous_failed = !success throw :task_has_failed unless success end |
- (Object) run_all_after_pass(tests_passed) (private)
Runs all tests after the failed tests pass.
100 101 102 103 104 105 106 107 108 |
# File 'lib/guard/phpunit.rb', line 100 def run_all_after_pass(tests_passed) return unless @options[:all_after_pass] if tests_passed run_all if @previous_failed else @previous_failed = true end end |
- (Object) run_on_change(paths)
Gets called when the watched tests have changes.
69 70 71 72 73 74 75 76 |
# File 'lib/guard/phpunit.rb', line 69 def run_on_change(paths) paths = Inspector.clean(paths + @failed_paths) success = Runner.run(paths, ) update_failed_paths(success, paths) run_all_after_pass(success) throw :task_has_failed unless success end |
- (Object) start
Gets called once when Guard starts.
47 48 49 |
# File 'lib/guard/phpunit.rb', line 47 def start run_all if [:all_on_start] end |
- (Object) update_failed_paths(tests_passed, paths) (private)
Adds or removes path to the failed_paths bassed on the tests result.
86 87 88 89 90 91 92 93 94 |
# File 'lib/guard/phpunit.rb', line 86 def update_failed_paths(tests_passed, paths) return unless @options[:keep_failed] if tests_passed @failed_paths -= paths else @failed_paths += paths end end |