class FlakeySpecCatcher::CapsuleManager

CapsuleManager class

Contains a file by file summary of all git changes.

A CapsuleManager object contains all ChangeCapsule objects. It delivers summaries of all changes and runs methods on the contained ChangeCapsule objects.

Attributes

change_capsules[R]

Public Class Methods

new() click to toggle source
# File lib/flakey_spec_catcher/capsule_manager.rb, line 14
def initialize
  @change_capsules = []
end

Public Instance Methods

add_capsule(capsule) click to toggle source
# File lib/flakey_spec_catcher/capsule_manager.rb, line 18
def add_capsule(capsule)
  @change_capsules.push(capsule)
end
changed_examples() click to toggle source
# File lib/flakey_spec_catcher/capsule_manager.rb, line 22
def changed_examples
  @change_capsules.map(&:changed_examples).flatten.uniq
end
changed_files() click to toggle source
# File lib/flakey_spec_catcher/capsule_manager.rb, line 26
def changed_files
  @change_capsules.map(&:file_name).uniq
end
condense_reruns() click to toggle source
# File lib/flakey_spec_catcher/capsule_manager.rb, line 34
def condense_reruns
  # Don't re-run if the parent context of a change will be run
  reruns = []
  all_contexts = sorted_change_contexts
  all_contexts.each do |context|
    next if reruns.include?(context.file_name) || context.ancestor_present_in_reruns(reruns)

    reruns.push(context.rerun_info) unless reruns.include?(context.rerun_info)
  end
  reruns
end
find_reruns_by_tags(user_excluded_tags) click to toggle source
# File lib/flakey_spec_catcher/capsule_manager.rb, line 54
def find_reruns_by_tags(user_excluded_tags)
  dropped_tests = []
  sorted_change_contexts.each do |context|
    context.tags.keys.each do |tag|
      next unless user_excluded_tags.key?(tag) &&
                  tag_values_equal?(user_excluded_tags[tag], context.tags[tag])

      dropped_tests << context.rerun_info
    end
  end
  dropped_tests
end
sorted_change_contexts() click to toggle source
# File lib/flakey_spec_catcher/capsule_manager.rb, line 30
def sorted_change_contexts
  @change_capsules.map(&:change_contexts).flatten.sort_by { |c| c.line_number.to_i }
end
tag_values_equal?(user_excluded_tag_value, rspec_tag_value) click to toggle source
# File lib/flakey_spec_catcher/capsule_manager.rb, line 46
def tag_values_equal?(user_excluded_tag_value, rspec_tag_value)
  return true if user_excluded_tag_value.nil? && rspec_tag_value.nil?

  return false if user_excluded_tag_value.nil? || rspec_tag_value.nil?

  (user_excluded_tag_value.tr('\'\"', '') == rspec_tag_value.tr('\'\" ', ''))
end