Class: Guard::Minitest::Runner
- Inherits:
-
Object
- Object
- Guard::Minitest::Runner
- Defined in:
- lib/guard/minitest/runner.rb
Instance Attribute Summary collapse
-
#inspector ⇒ Object
Returns the value of attribute inspector.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Runner
constructor
A new instance of Runner.
- #run(paths, options = {}) ⇒ Object
- #run_all ⇒ Object
- #run_on_additions(_paths) ⇒ Object
- #run_on_modifications(paths = []) ⇒ Object
- #run_on_removals(_paths) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Runner
Returns a new instance of Runner.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/guard/minitest/runner.rb', line 9 def initialize( = {}) @options = { all_after_pass: false, bundler: File.exist?("#{Dir.pwd}/Gemfile"), rubygems: false, drb: false, zeus: false, spring: false, all_env: {}, env: {}, include: [], test_folders: %w(test spec), test_file_patterns: %w(*_test.rb test_*.rb *_spec.rb), cli: nil, autorun: true }.merge() [:test_folders, :test_file_patterns].each do |k| @options[k] = Array(@options[k]).uniq.compact end @inspector = Inspector.new(test_folders, test_file_patterns) end |
Instance Attribute Details
#inspector ⇒ Object
Returns the value of attribute inspector.
7 8 9 |
# File 'lib/guard/minitest/runner.rb', line 7 def inspector @inspector end |
Instance Method Details
#run(paths, options = {}) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/guard/minitest/runner.rb', line 35 def run(paths, = {}) return unless [:all] || !paths.empty? = "Running: #{[:all] ? 'all tests' : paths.join(' ')}" Compat::UI.info , reset: true begin status = _run_possibly_bundled_command(paths, [:all]) rescue Errno::ENOENT => e Compat::UI.error e. throw :task_has_failed end success = status.zero? # When using zeus or spring, the Guard::Minitest::Reporter can't be used because the minitests run in another # process, but we can use the exit status of the client process to distinguish between :success and :failed. if zeus? || spring? Compat::UI.notify(, title: 'Minitest results', image: success ? :success : :failed) end run_all_coz_ok = @options[:all_after_pass] && success && ![:all] run_all_coz_ok ? run_all : success end |
#run_all ⇒ Object
60 61 62 63 |
# File 'lib/guard/minitest/runner.rb', line 60 def run_all paths = inspector.clean_all run(paths, all: true) end |
#run_on_additions(_paths) ⇒ Object
70 71 72 73 |
# File 'lib/guard/minitest/runner.rb', line 70 def run_on_additions(_paths) inspector.clear_memoized_test_files true end |
#run_on_modifications(paths = []) ⇒ Object
65 66 67 68 |
# File 'lib/guard/minitest/runner.rb', line 65 def run_on_modifications(paths = []) paths = inspector.clean(paths) run(paths, all: all_paths?(paths)) end |
#run_on_removals(_paths) ⇒ Object
75 76 77 |
# File 'lib/guard/minitest/runner.rb', line 75 def run_on_removals(_paths) inspector.clear_memoized_test_files end |