Class: RSpactor::Runner
- Inherits:
-
Object
- Object
- RSpactor::Runner
- Defined in:
- lib/rspactor/runner.rb
Instance Attribute Summary collapse
-
#dir ⇒ Object
readonly
Returns the value of attribute dir.
-
#inspector ⇒ Object
readonly
Returns the value of attribute inspector.
-
#interactor ⇒ Object
readonly
Returns the value of attribute interactor.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#spork ⇒ Object
readonly
Returns the value of attribute spork.
Class Method Summary collapse
Instance Method Summary collapse
- #cucumber? ⇒ Boolean
-
#initialize(dir, options = {}) ⇒ Runner
constructor
A new instance of Runner.
- #last_run_failed? ⇒ Boolean
- #load_dotfile ⇒ Object
- #run_all_specs ⇒ Object
- #run_cucumber_command(tags = '@wip:2', clear = ) ⇒ Object
- #run_spec_command(paths) ⇒ Object
- #spork? ⇒ Boolean
- #start ⇒ Object
- #start_interactor ⇒ Object
- #start_listener ⇒ Object
Constructor Details
Instance Attribute Details
#dir ⇒ Object (readonly)
Returns the value of attribute dir.
10 11 12 |
# File 'lib/rspactor/runner.rb', line 10 def dir @dir end |
#inspector ⇒ Object (readonly)
Returns the value of attribute inspector.
10 11 12 |
# File 'lib/rspactor/runner.rb', line 10 def inspector @inspector end |
#interactor ⇒ Object (readonly)
Returns the value of attribute interactor.
10 11 12 |
# File 'lib/rspactor/runner.rb', line 10 def interactor @interactor end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
10 11 12 |
# File 'lib/rspactor/runner.rb', line 10 def @options end |
#spork ⇒ Object (readonly)
Returns the value of attribute spork.
10 11 12 |
# File 'lib/rspactor/runner.rb', line 10 def spork @spork end |
Class Method Details
.start(options = {}) ⇒ Object
5 6 7 8 |
# File 'lib/rspactor/runner.rb', line 5 def self.start( = {}) run_in = .delete(:run_in) || Dir.pwd new(run_in, ).start end |
Instance Method Details
#cucumber? ⇒ Boolean
84 85 86 |
# File 'lib/rspactor/runner.rb', line 84 def cucumber? @cucumber ||= File.exist?(File.join(dir, 'features')) end |
#last_run_failed? ⇒ Boolean
80 81 82 |
# File 'lib/rspactor/runner.rb', line 80 def last_run_failed? @last_run_failed == false end |
#load_dotfile ⇒ Object
46 47 48 49 50 51 52 53 54 55 |
# File 'lib/rspactor/runner.rb', line 46 def load_dotfile dotfile = File.join(ENV['HOME'], '.rspactor') if File.exists?(dotfile) begin Kernel.load dotfile rescue => e $stderr.puts "Error while loading #{dotfile}: #{e}" end end end |
#run_all_specs ⇒ Object
57 58 59 |
# File 'lib/rspactor/runner.rb', line 57 def run_all_specs run_spec_command(File.join(dir, 'spec')) end |
#run_cucumber_command(tags = '@wip:2', clear = ) ⇒ Object
71 72 73 74 75 76 77 78 |
# File 'lib/rspactor/runner.rb', line 71 def run_cucumber_command( = '@wip:2', clear = @options[:clear]) return unless cucumber? system("clear;") if clear puts "** Running all #{} tagged features..." cmd = [ruby_opts, cucumber_runner, cucumber_opts()].flatten.join(' ') @last_run_failed = run_command(cmd) end |
#run_spec_command(paths) ⇒ Object
61 62 63 64 65 66 67 68 69 |
# File 'lib/rspactor/runner.rb', line 61 def run_spec_command(paths) paths = Array(paths) if paths.empty? @last_run_failed = nil else cmd = [ruby_opts, spec_runner, paths, spec_opts].flatten.join(' ') @last_run_failed = run_command(cmd) end end |
#spork? ⇒ Boolean
88 89 90 |
# File 'lib/rspactor/runner.rb', line 88 def spork? spork != nil end |
#start ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/rspactor/runner.rb', line 19 def start load_dotfile puts "** RSpactor, now watching at '#{dir}'" spork.start if spork? start_interactor start_listener end |
#start_interactor ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/rspactor/runner.rb', line 27 def start_interactor @interactor = Interactor.new(self) = "** Hit <enter> to skip initial spec #{"& cucumber " if cucumber?}run" aborted = [:skip] || @interactor.wait_for_enter_key(, 2, false) @interactor.start_termination_handler unless aborted run_all_specs run_cucumber_command('~@wip,~@pending', false) end end |