Module: Guard::RSpectacle::Runner
- Defined in:
- lib/guard/rspectacle/runner.rb
Overview
The RSpectacle runner handles the execution of the rspec test.
Class Method Summary collapse
-
.run(examples, options, err = $stderr, out = $stdout) ⇒ Array
Run a suite of RSpec examples.
Class Method Details
.run(examples, options, err = $stderr, out = $stdout) ⇒ Array
Run a suite of RSpec examples.
For reference, see:
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/guard/rspectacle/runner.rb', line 29 def run(examples, , err=$stderr, out=$stdout) = [:message] || "Run #{ examples.join(' ') }" ::Guard::UI.info(, :reset => true) = [:cli].to_s.split .delete('--drb') .delete('-X') += + examples begin status = ::RSpec::Core::Runner.run(, err, out) passed = status == 0 failed_specs = ::Guard::RSpectacle::Notifier.failed_specs || [] passed_specs = ::Guard::RSpectacle::Notifier.passed_specs || [] duration = ::Guard::RSpectacle::Notifier.duration || 0.0 example_count = ::Guard::RSpectacle::Notifier.example_count || -1 failure_count = ::Guard::RSpectacle::Notifier.failure_count || -1 pending_count = ::Guard::RSpectacle::Notifier.pending_count || -1 if [:notification] = " #{ example_count } example#{ example_count == 1 ? '' : 's' }" << ", #{ failure_count } failure#{ failure_count == 1 ? '' : 's' }" << " (#{ pending_count } pending)" if pending_count > 0 << "\nin #{ round(duration) } seconds" if failure_count > 0 ::Guard::RSpectacle::Formatter.notify(::Guard::RSpectacle::Humanity.failure + , :title => 'RSpec results', :image => :failed, :priority => -2) elsif pending_count > 0 ::Guard::RSpectacle::Formatter.notify(::Guard::RSpectacle::Humanity.pending + , :title => 'RSpec results', :image => :pending, :priority => -1) else ::Guard::RSpectacle::Formatter.notify(::Guard::RSpectacle::Humanity.success + , :title => 'RSpec results', :image => :success, :priority => 2) if ![:hide_success] end end [passed, relative(failed_specs), relative(passed_specs)] rescue Exception => e ::Guard::RSpectacle::Formatter.error("Error running specs: #{ e. }") [false, [], []] end end |