Class: Guard::BustedRunner
- Inherits:
-
Plugin
- Object
- Plugin
- Guard::BustedRunner
- Defined in:
- lib/guard/busted/runner.rb
Overview
The class responsible for running ‘busted’ command in the proper context.
Instance Attribute Summary collapse
-
#cmd ⇒ Object
Returns the value of attribute cmd.
-
#cmd_all ⇒ Object
Returns the value of attribute cmd_all.
-
#cmd_all_options ⇒ Object
Returns the value of attribute cmd_all_options.
-
#cmd_options ⇒ Object
Returns the value of attribute cmd_options.
Instance Method Summary collapse
-
#initialize(options) ⇒ BustedRunner
constructor
Initialize BustedRunner It accepts following options: - cmd - command to perform for specific spec files, - cmd_options [Array<String>] - options for cmd command, - cmd_all - command to perform for all spec files - cmd_all_options [Array<String>] - options for cmd_all command.
-
#run(paths) ⇒ Object
Run tests for the given paths.
-
#run_all ⇒ Object
Run all tests in the project.
Constructor Details
#initialize(options) ⇒ BustedRunner
Initialize BustedRunner It accepts following options:
- cmd - command to perform for specific spec files,
- cmd_options [Array<String>] - options for cmd command,
- cmd_all - command to perform for all spec files
- cmd_all_options [Array<String>] - options for cmd_all command.
20 21 22 23 24 25 26 27 |
# File 'lib/guard/busted/runner.rb', line 20 def initialize() super @cmd = [:cmd] @cmd_options = Array([:cmd_options]) @cmd_all = [:cmd_all] @cmd_all_options = Array([:cmd_all_options]) end |
Instance Attribute Details
#cmd ⇒ Object
Returns the value of attribute cmd.
10 11 12 |
# File 'lib/guard/busted/runner.rb', line 10 def cmd @cmd end |
#cmd_all ⇒ Object
Returns the value of attribute cmd_all.
10 11 12 |
# File 'lib/guard/busted/runner.rb', line 10 def cmd_all @cmd_all end |
#cmd_all_options ⇒ Object
Returns the value of attribute cmd_all_options.
10 11 12 |
# File 'lib/guard/busted/runner.rb', line 10 def @cmd_all_options end |
#cmd_options ⇒ Object
Returns the value of attribute cmd_options.
10 11 12 |
# File 'lib/guard/busted/runner.rb', line 10 def @cmd_options end |
Instance Method Details
#run(paths) ⇒ Object
Run tests for the given paths
44 45 46 47 48 49 50 51 52 53 |
# File 'lib/guard/busted/runner.rb', line 44 def run(paths) existing_paths = paths.select { |p| Pathname.new(p).exist? } return if existing_paths.empty? UI.info "Running #{existing_paths.join(', ')}" status, stdout = perform_command([@cmd] + @cmd_options + existing_paths) Guard::BustedNotifier.new(stdout, status).notify throw(:task_has_failed) unless status end |
#run_all ⇒ Object
Run all tests in the project
32 33 34 35 36 37 |
# File 'lib/guard/busted/runner.rb', line 32 def run_all UI.info 'Running all tests' status, stdout = perform_command([@cmd_all] + @cmd_all_options) Guard::BustedNotifier.new(stdout, status).notify throw(:task_has_failed) unless status end |