Class: FlakeySpecCatcher::GitController

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

Overview

GitController class

Runs a ‘git diff’ between the local working commit and a base commit that represents what is at the top of the source control manager.

The end goal of the GitController is to specify which tests have changed in a form that can be easily sent to RSpec. Because you can specify a test to run via ‘rspec <path_to_spec_file>:<file number>` the GitController will summarize changes in that form.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(test_mode: false, capsule_manager: FlakeySpecCatcher::CapsuleManager.new, user_config: FlakeySpecCatcher::UserConfig.new) ⇒ GitController

Returns a new instance of GitController.



22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/flakey_spec_catcher/git_controller.rb', line 22

def initialize(test_mode: false, capsule_manager: FlakeySpecCatcher::CapsuleManager.new,
  user_config: FlakeySpecCatcher::UserConfig.new)

  @user_config = user_config
  @remote = find_git_remote
  @branch = find_remote_branch
  @capsule_manager = capsule_manager
  # we don't need to do any git comparisons if we have manually specified tests to run.
  return unless @user_config.manual_rerun_patterns.nil? || @user_config.manual_rerun_patterns.empty?

  initialize_git_comparison(test_mode)
  parse_changes
  identify_change_contexts
end

Instance Attribute Details

#base_commit_shaObject (readonly)

Returns the value of attribute base_commit_sha.



19
20
21
# File 'lib/flakey_spec_catcher/git_controller.rb', line 19

def base_commit_sha
  @base_commit_sha
end

#branchObject (readonly)

Returns the value of attribute branch.



19
20
21
# File 'lib/flakey_spec_catcher/git_controller.rb', line 19

def branch
  @branch
end

#capsule_managerObject (readonly)

Returns the value of attribute capsule_manager.



20
21
22
# File 'lib/flakey_spec_catcher/git_controller.rb', line 20

def capsule_manager
  @capsule_manager
end

#git_comparisonObject (readonly)

Returns the value of attribute git_comparison.



19
20
21
# File 'lib/flakey_spec_catcher/git_controller.rb', line 19

def git_comparison
  @git_comparison
end

#remoteObject (readonly)

Returns the value of attribute remote.



19
20
21
# File 'lib/flakey_spec_catcher/git_controller.rb', line 19

def remote
  @remote
end

#working_commit_shaObject (readonly)

Returns the value of attribute working_commit_sha.



19
20
21
# File 'lib/flakey_spec_catcher/git_controller.rb', line 19

def working_commit_sha
  @working_commit_sha
end

Instance Method Details

#changed_examplesObject



37
38
39
# File 'lib/flakey_spec_catcher/git_controller.rb', line 37

def changed_examples
  @capsule_manager.change_capsules.map(&:changed_examples).flatten.uniq
end