class Guard::RSpec::Inspectors::BaseInspector
Attributes
options[RW]
spec_paths[RW]
Public Class Methods
new(options = {})
click to toggle source
# File lib/guard/rspec/inspectors/base_inspector.rb, line 7 def initialize(options = {}) @options = options @spec_paths = @options[:spec_paths] @chdir = @options[:chdir] end
Public Instance Methods
failed(_locations)
click to toggle source
# File lib/guard/rspec/inspectors/base_inspector.rb, line 17 def failed(_locations) raise NotImplementedError end
paths(_paths)
click to toggle source
# File lib/guard/rspec/inspectors/base_inspector.rb, line 13 def paths(_paths) raise NotImplementedError end
reload()
click to toggle source
# File lib/guard/rspec/inspectors/base_inspector.rb, line 21 def reload raise NotImplementedError end
Private Instance Methods
_clean(paths)
click to toggle source
Leave only spec/feature files from #spec_paths, remove others
# File lib/guard/rspec/inspectors/base_inspector.rb, line 28 def _clean(paths) paths.uniq! paths.compact! spec_dirs = _select_only_spec_dirs(paths) spec_files = _select_only_spec_files(paths) (spec_dirs + spec_files).uniq end
_collect_files(pattern)
click to toggle source
# File lib/guard/rspec/inspectors/base_inspector.rb, line 57 def _collect_files(pattern) base_paths = _spec_paths_with_chdir base_paths.map do |path| # TODO: not tested properly Dir[File.join(path, "**{,/*/**}", pattern)] end end
_paths_with_chdir(paths, chdir)
click to toggle source
# File lib/guard/rspec/inspectors/base_inspector.rb, line 65 def _paths_with_chdir(paths, chdir) paths.map do |path| chdir ? File.join(chdir, path) : path end end
_select_only_spec_dirs(paths)
click to toggle source
# File lib/guard/rspec/inspectors/base_inspector.rb, line 36 def _select_only_spec_dirs(paths) chdir_paths = _spec_paths_with_chdir paths.select do |path| File.directory?(path) || chdir_paths.include?(path) end end
_select_only_spec_files(paths)
click to toggle source
# File lib/guard/rspec/inspectors/base_inspector.rb, line 43 def _select_only_spec_files(paths) spec_files = _collect_files("*[_.]spec.rb") feature_files = _collect_files("*.feature") files = (spec_files + feature_files).flatten paths.select do |path| (files & [@chdir ? File.join(@chdir, path) : path]).any? end end
_spec_paths_with_chdir()
click to toggle source
# File lib/guard/rspec/inspectors/base_inspector.rb, line 53 def _spec_paths_with_chdir _paths_with_chdir(spec_paths, @chdir) end