Class: Guard::Cucumber
- Defined in:
- lib/guard/cucumber.rb,
lib/guard/cucumber/runner.rb,
lib/guard/cucumber/inspector.rb,
lib/guard/cucumber/notification_formatter.rb
Overview
The Cucumber guard that gets notifications about the following Guard events: ‘start`, `stop`, `reload`, `run_all` and `run_on_change`.
Defined Under Namespace
Modules: Inspector, Runner Classes: NotificationFormatter
Instance Method Summary collapse
-
#initialize(watchers = [], options = { }) ⇒ Cucumber
constructor
Initialize Guard::Cucumber.
-
#reload ⇒ Object
Gets called when the Guard should reload itself.
-
#run_all ⇒ Object
Gets called when all specs should be run.
-
#run_on_changes(paths) ⇒ Object
Gets called when watched paths and files have changes.
-
#start ⇒ Object
Gets called once when Guard starts.
Constructor Details
#initialize(watchers = [], options = { }) ⇒ Cucumber
Initialize Guard::Cucumber.
31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/guard/cucumber.rb', line 31 def initialize(watchers = [], = { }) super @options = { :all_after_pass => true, :all_on_start => true, :keep_failed => true, :cli => '--no-profile --color --format progress --strict', :feature_sets => ['features'] }.update() @last_failed = false @failed_paths = [] end |
Instance Method Details
#reload ⇒ Object
Gets called when the Guard should reload itself.
75 76 77 |
# File 'lib/guard/cucumber.rb', line 75 def reload @failed_paths = [] end |
#run_all ⇒ Object
Gets called when all specs should be run.
57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/guard/cucumber.rb', line 57 def run_all passed = Runner.run([:feature_sets], .merge([:run_all] || { }).merge(:message => 'Running all features')) if passed @failed_paths = [] else @failed_paths = read_failed_features if @options[:keep_failed] end @last_failed = !passed throw :task_has_failed unless passed end |
#run_on_changes(paths) ⇒ Object
Gets called when watched paths and files have changes.
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/guard/cucumber.rb', line 84 def run_on_changes(paths) paths += @failed_paths if @options[:keep_failed] paths = Inspector.clean(paths) = @options[:change_format] ? change_format(@options[:change_format]) : @options passed = Runner.run(paths, paths.include?('features') ? .merge({ :message => 'Running all features' }) : ) if passed # clean failed paths memory @failed_paths -= paths if @options[:keep_failed] # run all the specs if the changed specs failed, like autotest run_all if @last_failed && @options[:all_after_pass] else # remember failed paths for the next change @failed_paths += read_failed_features if @options[:keep_failed] # track whether the changed feature failed for the next change @last_failed = true end throw :task_has_failed unless passed end |
#start ⇒ Object
Gets called once when Guard starts.
49 50 51 |
# File 'lib/guard/cucumber.rb', line 49 def start run_all if @options[:all_on_start] end |