Class Spec::Runner::CommandLine
In: lib/spec/runner/command_line.rb
Parent: Object

Facade to run specs without having to fork a new ruby process (using `spec …`)

Methods

run  

Public Class methods

Runs specs. argv is the commandline args as per the spec commandline API, stderr and stdiout are the streams output will be written to, exit tells whether or not a system exit should be called after the specs are run and warn_if_no_files tells whether or not a warning (the help message) should be printed to stderr in case no files are specified.

[Source]

    # File lib/spec/runner/command_line.rb, line 10
10:       def self.run(argv, stderr, stdout, exit=false, warn_if_no_files=true)
11:         old_context_runner = defined?($context_runner) ? $context_runner : nil
12:         $context_runner = OptionParser.new.create_context_runner(argv, stderr, stdout, warn_if_no_files)
13: 
14:         # If ARGV is a glob, it will actually each over each one of the matching files.
15:         argv.each do |file_or_dir|
16:           if File.directory?(file_or_dir)
17:             Dir["#{file_or_dir}/**/*.rb"].each do |file| 
18:               load file
19:             end
20:           elsif File.file?(file_or_dir)
21:             load file_or_dir
22:           else
23:             raise "File or directory not found: #{file_or_dir}"
24:           end
25:         end
26:         $context_runner.run(exit)
27:         $context_runner = old_context_runner
28:       end

[Validate]