]> git.openstreetmap.org Git - rails.git/blob - vendor/gems/rspec-1.1.2/lib/spec/runner/command_line.rb
added RSpec and RSpec on Rails
[rails.git] / vendor / gems / rspec-1.1.2 / lib / spec / runner / command_line.rb
1 require 'spec/runner/option_parser'
2
3 module Spec
4   module Runner
5     # Facade to run specs without having to fork a new ruby process (using `spec ...`)
6     class CommandLine
7       class << self
8         # Runs specs. +argv+ is the commandline args as per the spec commandline API, +err+
9         # and +out+ are the streams output will be written to.
10         def run(instance_rspec_options)
11           # NOTE - this call to init_rspec_options is not spec'd, but neither is any of this
12           # swapping of $rspec_options. That is all here to enable rspec to run against itself
13           # and maintain coverage in a single process. Therefore, DO NOT mess with this stuff
14           # unless you know what you are doing!
15           init_rspec_options(instance_rspec_options)
16           orig_rspec_options = rspec_options
17           begin
18             $rspec_options = instance_rspec_options
19             return $rspec_options.run_examples
20           ensure
21             ::Spec.run = true
22             $rspec_options = orig_rspec_options
23           end
24         end
25       end
26     end
27   end
28 end