Module: Files::Specs
- Defined in:
- lib/specss/files.rb
Class Method Summary collapse
-
.chop_file_paths(specs) ⇒ Object
Returns array of specs to run with the absolute path chopped off.
-
.get_specs(changed_files) ⇒ Object
Returns all specs to run as an array of file paths relative to root.
Class Method Details
.chop_file_paths(specs) ⇒ Object
Returns array of specs to run with the absolute path chopped off
76 77 78 79 80 81 82 83 84 |
# File 'lib/specss/files.rb', line 76 def self.chop_file_paths(specs) specs_to_run = [] specs.each do |s| spec_name = File.basename(s) specs_to_run.push(spec_name) end specs_to_run end |
.get_specs(changed_files) ⇒ Object
Returns all specs to run as an array of file paths relative to root
60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/specss/files.rb', line 60 def self.get_specs(changed_files) specs_to_run = [] specs = Dir.glob('spec/**/*').select{ |e| File.file? e } # Check if each spec is included in the list of changed files specs.each do |s| spec_name = File.basename(s, ".*") spec_name.slice! '_spec' if spec_name.include? '_spec' next if spec_name.include? 'shared_examples' specs_to_run.push(s) if changed_files.include? spec_name end specs_to_run end |