Class: KnapsackPro::RetryFailedTests

Inherits:
Object
  • Object
show all
Defined in:
lib/knapsack_pro/commands/retry_failed_tests.rb

Instance Method Summary collapse

Constructor Details

#initialize(branch) ⇒ RetryFailedTests

Returns a new instance of RetryFailedTests.



8
9
10
# File 'lib/knapsack_pro/commands/retry_failed_tests.rb', line 8

def initialize(branch)
  @branch = branch || `git branch --show-current`.chomp
end

Instance Method Details

#call(runner_args) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/knapsack_pro/commands/retry_failed_tests.rb', line 12

def call(runner_args)
  $stderr.puts "Branch: #{branch}"

  failed_paths = fetch_failed_paths
  return ($stderr.puts "Nothing to run") if failed_paths.size.zero?

  $stderr.puts "Retrying #{failed_paths.size} tests..."
  exec Gem.bin_path("rspec-core", "rspec"), *(runner_args + failed_paths)
end