Class: DeltaTest::RelatedSpecList
- Inherits:
-
Object
- Object
- DeltaTest::RelatedSpecList
- Defined in:
- lib/delta_test/related_spec_list.rb
Instance Method Summary collapse
-
#customs ⇒ Set|Nil
Custom spec files.
-
#dependents ⇒ Set|Nil
Dependent spec files.
-
#full ⇒ Set|Nil
Full spec files.
-
#full_tests? ⇒ Boolean
Return if full tests are related.
-
#initialize ⇒ RelatedSpecList
constructor
A new instance of RelatedSpecList.
-
#load_table!(table_file_path) ⇒ Object
Load table from the file.
-
#related_spec_files ⇒ Set<String>
Calculate related spec files.
-
#retrive_changed_files!(commit) ⇒ Object
Retrive changed files in git diff.
Constructor Details
#initialize ⇒ RelatedSpecList
15 16 17 |
# File 'lib/delta_test/related_spec_list.rb', line 15 def initialize @git = Git.new(DeltaTest.config.base_path) end |
Instance Method Details
#customs ⇒ Set|Nil
Custom spec files
88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/delta_test/related_spec_list.rb', line 88 def customs return nil unless @changed_files return @customs if @customs @customs = Set.new DeltaTest.config.custom_mappings.each do |spec_file, patterns| if Utils.files_grep(@changed_files, patterns).any? @customs << spec_file end end @customs end |
#dependents ⇒ Set|Nil
Dependent spec files
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/delta_test/related_spec_list.rb', line 67 def dependents return nil unless @changed_files && @table return @dependents if @dependents @dependents = Set.new @table.each do |spec_file, dependencies| dependent = @changed_files.include?(spec_file) \ || (dependencies & @changed_files).any? @dependents << spec_file if dependent end @dependents end |
#full ⇒ Set|Nil
Full spec files
108 109 110 111 112 |
# File 'lib/delta_test/related_spec_list.rb', line 108 def full return nil unless @table @full ||= Set.new(@table.keys) end |
#full_tests? ⇒ Boolean
Return if full tests are related
49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/delta_test/related_spec_list.rb', line 49 def full_tests? return false unless @changed_files @full_tests ||= if DeltaTest.config.full_test_patterns.empty? false else Utils.files_grep( @changed_files, DeltaTest.config.full_test_patterns ).any? end end |
#load_table!(table_file_path) ⇒ Object
Load table from the file
22 23 24 25 26 27 28 |
# File 'lib/delta_test/related_spec_list.rb', line 22 def load_table!(table_file_path) unless File.exist?(table_file_path) raise TableNotFoundError.new(table_file_path) end @table = DependenciesTable.load(table_file_path) end |
#related_spec_files ⇒ Set<String>
Calculate related spec files
119 120 121 122 123 124 125 |
# File 'lib/delta_test/related_spec_list.rb', line 119 def if full_tests? full else dependents | customs end end |
#retrive_changed_files!(commit) ⇒ Object
Retrive changed files in git diff
36 37 38 39 40 41 42 |
# File 'lib/delta_test/related_spec_list.rb', line 36 def retrive_changed_files!(commit) unless @git.git_repo? raise NotInGitRepositoryError end @changed_files = @git.changed_files(commit) end |