Class: Spectator::Runner
- Inherits:
-
Object
- Object
- Spectator::Runner
- Defined in:
- lib/spectator.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#path_watcher ⇒ Object
readonly
Returns the value of attribute path_watcher.
-
#spec_runner ⇒ Object
readonly
Returns the value of attribute spec_runner.
-
#specs_matcher ⇒ Object
readonly
Returns the value of attribute specs_matcher.
-
#success_notifier ⇒ Object
readonly
Returns the value of attribute success_notifier.
-
#ui ⇒ Object
readonly
Returns the value of attribute ui.
Instance Method Summary collapse
-
#initialize(config) ⇒ Runner
constructor
A new instance of Runner.
- #run ⇒ Object
Constructor Details
#initialize(config) ⇒ Runner
Returns a new instance of Runner.
40 41 42 43 44 45 46 47 |
# File 'lib/spectator.rb', line 40 def initialize(config) @config = config @path_watcher = PathWatcher.new(config) @ui = UI.new(config) @spec_runner = SpecRunner.new(config) @success_notifier = SuccessNotifier.new(config) @specs_matcher = SpecsMatcher.new(config) end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
49 50 51 |
# File 'lib/spectator.rb', line 49 def config @config end |
#path_watcher ⇒ Object (readonly)
Returns the value of attribute path_watcher.
49 50 51 |
# File 'lib/spectator.rb', line 49 def path_watcher @path_watcher end |
#spec_runner ⇒ Object (readonly)
Returns the value of attribute spec_runner.
49 50 51 |
# File 'lib/spectator.rb', line 49 def spec_runner @spec_runner end |
#specs_matcher ⇒ Object (readonly)
Returns the value of attribute specs_matcher.
49 50 51 |
# File 'lib/spectator.rb', line 49 def specs_matcher @specs_matcher end |
#success_notifier ⇒ Object (readonly)
Returns the value of attribute success_notifier.
49 50 51 |
# File 'lib/spectator.rb', line 49 def success_notifier @success_notifier end |
#ui ⇒ Object (readonly)
Returns the value of attribute ui.
49 50 51 |
# File 'lib/spectator.rb', line 49 def ui @ui end |
Instance Method Details
#run ⇒ Object
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 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/spectator.rb', line 51 def run $spectator_debug = config.debug path_watcher.on_change { ui << :run_specs } path_watcher.watch_paths! ui.on(:run_specs) do next unless ui.can_run_specs? ui.status = :running_specs files = path_watcher.pop_files specs = specs_matcher.specs_for(files) if specs.any? result = ui.run spec_runner.command(specs) success_notifier.notify(result) end ui.wait_for_changes end ui.on(:interrupt) do puts ' (Interrupted with CTRL+C)'.red p [ui.status, ui.interrupted_status] case ui.interrupted_status when :wait_for_input then ui.exit when :running_specs then ui.wait_for_changes when :exiting then Kernel.abort else Thread.new { ui.ask_what_to_do } end end trap('INT') { ui.interrupt! } ui.on(:run_all) do next unless ui.can_run_specs? ui.status = :running_specs result = ui.run(spec_runner.command) success_notifier.notify(result) ui.status = nil if ui.status == :running_specs end ui.start end |