lib/guard/rspec/inspector.rb in guard-rspec-4.0.3 vs lib/guard/rspec/inspector.rb in guard-rspec-4.0.4
- old
+ new
@@ -42,28 +42,36 @@
end
end
def _focused_paths
return nil unless options[:focus_on_failed]
- File.open(FOCUSED_FILE_PATH).read.split("\n")[0..10]
+ File.open(FOCUSED_FILE_PATH) { |f| f.read.split("\n")[0..10] }
rescue
nil
ensure
File.exist?(FOCUSED_FILE_PATH) && File.delete(FOCUSED_FILE_PATH)
end
def _clean(paths)
paths.uniq!
paths.compact!
- paths = _select_only_spec_files(paths)
+
+ spec_dirs = _select_only_spec_dirs(paths)
+ spec_files = _select_only_spec_files(paths)
+ paths = spec_dirs + spec_files
+
paths
end
+ def _select_only_spec_dirs(paths)
+ paths.select { |p| File.directory?(p) || spec_paths.include?(p) }
+ end
+
def _select_only_spec_files(paths)
spec_files = spec_paths.collect { |path| Dir[File.join(path, "**{,/*/**}", "*[_.]spec.rb")] }
feature_files = spec_paths.collect { |path| Dir[File.join(path, "**{,/*/**}", "*.feature")] }
files = (spec_files + feature_files).flatten
- paths.select { |p| files.include?(p) || spec_paths.include?(p) }
+ paths.select { |p| files.include?(p) }
end
end
end
end