Module: FactorySloth::SpecPicker

Extended by:
SpecPicker
Included in:
SpecPicker
Defined in:
lib/factory_sloth/spec_picker.rb

Instance Method Summary collapse

Instance Method Details

#call(paths:) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/factory_sloth/spec_picker.rb', line 4

def call(paths:)
  paths = ['.'] if paths.empty?

  paths.each_with_object([]) do |path, acc|
    if File.directory?(path)
      acc.concat(Dir["#{path.chomp('/')}/**/*_spec.rb"])
    elsif File.exist?(path)
      acc << path
    else
      raise ArgumentError, "no such file: #{path}"
    end
  end
end