Class: FlakeySpecCatcher::CapsuleManager
- Inherits:
-
Object
- Object
- FlakeySpecCatcher::CapsuleManager
- Defined in:
- lib/flakey_spec_catcher/capsule_manager.rb
Overview
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.
Instance Attribute Summary collapse
-
#change_capsules ⇒ Object
readonly
Returns the value of attribute change_capsules.
Instance Method Summary collapse
- #add_capsule(capsule) ⇒ Object
- #changed_examples ⇒ Object
- #changed_files ⇒ Object
- #condense_reruns ⇒ Object
- #find_reruns_by_tags(user_excluded_tags) ⇒ Object
-
#initialize ⇒ CapsuleManager
constructor
A new instance of CapsuleManager.
- #sorted_change_contexts ⇒ Object
- #tag_values_equal?(user_excluded_tag_value, rspec_tag_value) ⇒ Boolean
Constructor Details
#initialize ⇒ CapsuleManager
Returns a new instance of CapsuleManager.
14 15 16 |
# File 'lib/flakey_spec_catcher/capsule_manager.rb', line 14 def initialize @change_capsules = [] end |
Instance Attribute Details
#change_capsules ⇒ Object (readonly)
Returns the value of attribute change_capsules.
12 13 14 |
# File 'lib/flakey_spec_catcher/capsule_manager.rb', line 12 def change_capsules @change_capsules end |
Instance Method Details
#add_capsule(capsule) ⇒ Object
18 19 20 |
# File 'lib/flakey_spec_catcher/capsule_manager.rb', line 18 def add_capsule(capsule) @change_capsules.push(capsule) end |
#changed_examples ⇒ Object
22 23 24 |
# File 'lib/flakey_spec_catcher/capsule_manager.rb', line 22 def changed_examples @change_capsules.map(&:changed_examples).flatten.uniq end |
#changed_files ⇒ Object
26 27 28 |
# File 'lib/flakey_spec_catcher/capsule_manager.rb', line 26 def changed_files @change_capsules.map(&:file_name).uniq end |
#condense_reruns ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 |
# 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) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/flakey_spec_catcher/capsule_manager.rb', line 54 def () dropped_tests = [] sorted_change_contexts.each do |context| context..keys.each do |tag| next unless .key?(tag) && tag_values_equal?([tag], context.[tag]) dropped_tests << context.rerun_info end end dropped_tests end |
#sorted_change_contexts ⇒ Object
30 31 32 |
# 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) ⇒ Boolean
46 47 48 49 50 51 52 |
# 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 |