Method: MSpecScript#entries

Defined in:
lib/extensions/mspec/mspec/utils/script.rb

#entries(partial) ⇒ Object

Attempts to resolve partial as a file or directory name in the following order:

1. +partial+
2. +partial+ + "_spec.rb"
3. <tt>File.join(config[:prefix], partial)</tt>
4. <tt>File.join(config[:prefix], partial + "_spec.rb")</tt>

If it is a file name, returns the name as an entry in an array. If it is a directory, returns all *_spec.rb files in the directory and subdirectories.

If unable to resolve partial, returns Dir[partial].



164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
# File 'lib/extensions/mspec/mspec/utils/script.rb', line 164

def entries(partial)
  file = partial + "_spec.rb"
  patterns = [partial]
  patterns << file
  if config[:prefix]
    patterns << File.join(config[:prefix], partial)
    patterns << File.join(config[:prefix], file)
  end

  patterns.each do |pattern|
    expanded = File.expand_path(pattern)
    return [expanded] if File.file?(expanded)

    specs = File.join(pattern, "/**/*_spec.rb")
    specs = File.expand_path(specs) rescue specs
    return Dir[specs].sort if File.directory?(expanded)
  end

  Dir[partial]
end