Class: MiniTest::Unit::TestCase

Inherits:
Object
  • Object
show all
Defined in:
lib/minitest/focus4.rb

Overview

:nodoc:

Class Method Summary collapse

Class Method Details

.focusObject

Focus on the next test defined. Cumulative. Equivalent to running with command line arg: -n /test_name|…/

class MyTest < MiniTest::Unit::TestCase
  ...
  focus
  def test_pass; ... end # this one will run
  ...
end


13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/minitest/focus4.rb', line 13

def self.focus
  opts = MiniTest::Unit.runner.options
  meta = class << self; self; end

  opts[:names] ||= []

  meta.send :define_method, :method_added do |name|
    opts[:names] << name.to_s
    opts[:filter] = "/^(#{Regexp.union(opts[:names]).source})$/"

    meta.send :remove_method, :method_added
  end
end