Class: Guard::RSpec
- Defined in:
- lib/guard/rspec.rb,
lib/guard/rspec/runner.rb,
lib/guard/rspec/inspector.rb
Defined Under Namespace
Modules: Formatter Classes: Inspector, Runner
Instance Method Summary collapse
-
#initialize(watchers = [], options = {}) ⇒ RSpec
constructor
A new instance of RSpec.
- #reload ⇒ Object
- #run_all ⇒ Object
- #run_on_change(paths) ⇒ Object
-
#start ⇒ Object
Call once when guard starts.
Constructor Details
#initialize(watchers = [], options = {}) ⇒ RSpec
Returns a new instance of RSpec.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/guard/rspec.rb', line 9 def initialize(watchers=[], ={}) super @options = { :all_after_pass => true, :all_on_start => true, :keep_failed => true, :spec_paths => ["spec"] }.update() @last_failed = false @failed_paths = [] @runner = Runner.new @inspector = Inspector.new @runner.set_rspec_version() @inspector.excluded = @options[:exclude] @inspector.spec_paths = @options[:spec_paths] end |
Instance Method Details
#reload ⇒ Object
45 46 47 |
# File 'lib/guard/rspec.rb', line 45 def reload @failed_paths = [] end |
#run_all ⇒ Object
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/guard/rspec.rb', line 34 def run_all passed = @runner.run([:spec_paths], .merge([:run_all] || {}).merge(:message => "Running all specs")) @last_failed = !passed if passed @failed_paths = [] else throw :task_has_failed end end |
#run_on_change(paths) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/guard/rspec.rb', line 49 def run_on_change(paths) paths += @failed_paths if @options[:keep_failed] paths = @inspector.clean(paths) passed = @runner.run(paths, ) 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 += paths if @options[:keep_failed] # track whether the changed specs failed for the next change @last_failed = true throw :task_has_failed end end |
#start ⇒ Object
Call once when guard starts
29 30 31 32 |
# File 'lib/guard/rspec.rb', line 29 def start UI.info "Guard::RSpec is running, with RSpec #{@runner.rspec_version}!" run_all if @options[:all_on_start] end |