Class: Guard::RSpectacle
- Defined in:
- lib/guard/rspectacle.rb,
lib/guard/rspectacle/runner.rb,
lib/guard/rspectacle/humanity.rb,
lib/guard/rspectacle/notifier.rb,
lib/guard/rspectacle/reloader.rb,
lib/guard/rspectacle/formatter.rb,
lib/guard/rspectacle/inspector.rb
Overview
The RSpecRails guard that gets notifications about the following Guard events: ‘start`, `stop`, `reload`, `run_all` and `run_on_change`.
Defined Under Namespace
Modules: Formatter, Inspector, Runner Classes: Humanity, Notifier, Reloader
Constant Summary collapse
- DEFAULT_OPTIONS =
{ :cli => '', :notification => true, :hide_success => false, :all_on_start => true, :keep_failed => true, :all_after_pass => true, }
Instance Attribute Summary collapse
-
#last_run_passed ⇒ Object
Returns the value of attribute last_run_passed.
-
#rerun_specs ⇒ Object
Returns the value of attribute rerun_specs.
Instance Method Summary collapse
-
#initialize(watchers = [], options = {}) ⇒ RSpectacle
constructor
Initialize Guard::RSpecRails.
-
#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 = {}) ⇒ RSpectacle
Initialize Guard::RSpecRails.
41 42 43 44 45 46 47 48 |
# File 'lib/guard/rspectacle.rb', line 41 def initialize(watchers = [], = {}) = DEFAULT_OPTIONS.merge() super(watchers, ) self.last_run_passed = true self.rerun_specs = [] end |
Instance Attribute Details
#last_run_passed ⇒ Object
Returns the value of attribute last_run_passed.
19 20 21 |
# File 'lib/guard/rspectacle.rb', line 19 def last_run_passed @last_run_passed end |
#rerun_specs ⇒ Object
Returns the value of attribute rerun_specs.
19 20 21 |
# File 'lib/guard/rspectacle.rb', line 19 def rerun_specs @rerun_specs end |
Instance Method Details
#reload ⇒ Object
Gets called when the Guard should reload itself.
66 67 68 69 70 71 |
# File 'lib/guard/rspectacle.rb', line 66 def reload Dir.glob('**/*.rb').each { |file| Reloader.reload_file(file) } self.last_run_passed = true self.rerun_specs = [] end |
#run_all ⇒ Object
Gets called when all specs should be run.
77 78 79 80 81 82 83 84 |
# File 'lib/guard/rspectacle.rb', line 77 def run_all passed, failed_examples, passed_examples = Runner.run(['spec'], .merge({ :message => 'Run all specs'})) self.rerun_specs = failed_examples self.last_run_passed = passed throw :task_has_failed unless passed end |
#run_on_changes(paths) ⇒ Object
Gets called when watched paths and files have changes.
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/guard/rspectacle.rb', line 91 def run_on_changes(paths) specs = Inspector.clean(paths) return false if specs.empty? specs += self.rerun_specs if [:keep_failed] # RSpec reloads the files, so reload only non spec files (paths - specs).each { |path| Reloader.reload_file(path) } passed, failed_examples, passed_examples = Runner.run(specs, ) self.rerun_specs += failed_examples self.rerun_specs -= passed_examples run_all if passed && !self.last_run_passed && [:all_after_pass] self.last_run_passed = passed throw :task_has_failed unless passed end |