Class: RSpecConsole::Runner

Inherits:
Object show all
Defined in:
lib/rspec-console/runner.rb

Class Method Summary collapse

Class Method Details

.config_cacheObject



40
41
42
# File 'lib/rspec-console/runner.rb', line 40

def config_cache
  @config_cache ||= RSpecConsole::ConfigCache.new
end

.reset(args) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/rspec-console/runner.rb', line 3

def reset(args)
  require 'rspec/core'

  if Gem.loaded_specs['rspec-core'].version < Gem::Version.new('2.9.10')
    raise 'Please use RSpec 2.9.10 or later'
  end

  ::RSpec::Core::Runner.disable_autorun!
  ::RSpec::Core::Configuration.class_eval { define_method(:command) { 'rspec' } }
  ::RSpec.reset

  config_cache.cache do
    ::RSpec.configure do |config|
      config.output_stream = STDOUT
      config.color_enabled = true if config.respond_to?(:color_enabled=)
      config.color         = true if config.respond_to?(:color=)
    end

    $LOAD_PATH << './spec'
    require "spec_helper"
    begin
      require "rails_helper"
    rescue LoadError
    end
  end
end

.run(args) ⇒ Object



30
31
32
33
34
35
36
37
38
# File 'lib/rspec-console/runner.rb', line 30

def run(args)
  RSpecConsole.hooks.each(&:call)
  reset(args)
  if defined?(::RSpec::Core::CommandLine)
    ::RSpec::Core::CommandLine.new(args).run(STDERR, STDOUT)
  else
    ::RSpec::Core::Runner.run(args, STDERR, STDOUT)
  end
end