Class: FlakeySpecCatcher::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/flakey_spec_catcher/runner.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(test_mode: false, git_controller: FlakeySpecCatcher::GitController.new(test_mode: test_mode), user_config: FlakeySpecCatcher::UserConfig.new, result_manager: FlakeySpecCatcher::RspecResultManager.new(FlakeySpecCatcher::RspecResult), rerun_manager: FlakeySpecCatcher::RerunManager.new(git_controller: git_controller, user_config: user_config)) ⇒ Runner

Returns a new instance of Runner.



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/flakey_spec_catcher/runner.rb', line 15

def initialize(test_mode: false,
  git_controller: FlakeySpecCatcher::GitController.new(test_mode: test_mode),
  user_config: FlakeySpecCatcher::UserConfig.new,
  result_manager: FlakeySpecCatcher::RspecResultManager.new(FlakeySpecCatcher::RspecResult),
  rerun_manager: FlakeySpecCatcher::RerunManager.new(git_controller: git_controller,
                                                     user_config: user_config))

  @git_controller = git_controller
  @user_config = user_config
  @rerun_manager = rerun_manager
  @rspec_result_manager = result_manager
end

Instance Attribute Details

#git_controllerObject (readonly)

Returns the value of attribute git_controller.



13
14
15
# File 'lib/flakey_spec_catcher/runner.rb', line 13

def git_controller
  @git_controller
end

#rerun_managerObject (readonly)

Returns the value of attribute rerun_manager.



13
14
15
# File 'lib/flakey_spec_catcher/runner.rb', line 13

def rerun_manager
  @rerun_manager
end

#user_configObject (readonly)

Returns the value of attribute user_config.



13
14
15
# File 'lib/flakey_spec_catcher/runner.rb', line 13

def user_config
  @user_config
end

Instance Method Details

#rerun_previewObject

rubocop:enable Metrics/AbcSize



44
45
46
47
48
49
50
51
52
53
# File 'lib/flakey_spec_catcher/runner.rb', line 44

def rerun_preview
  puts "\n********************************************"
  puts "Re-run Preview\n"
  @rerun_manager.rerun_capsules.sort.each do |capsule|
    rerun_msg = "  Running #{capsule.testcase} #{@user_config.repeat_factor} times "
    rerun_msg += "using `#{capsule.usage}`" unless capsule.default_usage?
    puts rerun_msg
  end
  puts "\n********************************************"
end

#run_specsObject

end Debug methods



56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/flakey_spec_catcher/runner.rb', line 56

def run_specs
  status = 0
  @user_config.repeat_factor.times do
    @rerun_manager.rerun_capsules.sort.each do |capsule|
      iteration_status = handle_capsule_rerun(capsule)
      status = [status, iteration_status].max
    end
  end

  display_results(status)

  # Always return 0 if silent_mode is enabled
  @user_config.silent_mode ? 0 : status
end

#show_settingsObject

Debug Methods rubocop:disable Metrics/AbcSize



30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/flakey_spec_catcher/runner.rb', line 30

def show_settings
  puts 'Flakey Spec Catcher Settings:'
  puts "  Current Branch: #{@git_controller.branch}"
  puts "  Remote: #{@git_controller.remote}"
  puts "  Current Sha: #{@git_controller.working_commit_sha}"
  puts "  Base Sha: #{@git_controller.base_commit_sha}"
  puts "  Repeat factor: #{@user_config.repeat_factor}"
  puts "  Changed Specs Detected: #{@git_controller.changed_examples}"
  return if @user_config.output_file == '/dev/null'

  puts "  Verbose Output Path: #{@user_config.output_file}"
end