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
69 70 71 72 73 74 75 76 77 |
# File 'lib/specss/files.rb', line 69 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
53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/specss/files.rb', line 53 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 |