summaryrefslogtreecommitdiffstats
path: root/test/lib/spec/runner/extensions/kernel.rb
blob: f060ec85917519912bdf0b90356596525431c1fa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
module Kernel
  def context(name, &block)
    context = Spec::Runner::Context.new(name, &block)
    context_runner.add_context(context)
  end

private

  def context_runner
    # TODO: Figure out a better way to get this considered "covered" and keep this statement on multiple lines 
    unless $context_runner; \
      $context_runner = ::Spec::Runner::OptionParser.new.create_context_runner(ARGV.dup, STDERR, STDOUT, false); \
      at_exit { $context_runner.run(false) }; \
    end
    $context_runner
  end
end