Class: Minitest::Test
- Inherits:
-
Object
- Object
- Minitest::Test
- Defined in:
- lib/minitest/focus.rb
Overview
:nodoc:
Defined Under Namespace
Classes: Focus
Constant Summary collapse
- @@filtered_names =
:nodoc:
[]
Class Method Summary collapse
- .add_to_filter(name) ⇒ Object
- .filtered_names ⇒ Object
-
.focus(name = nil) ⇒ Object
Focus on the next test defined.
-
.set_focus_trap ⇒ Object
Sets a one-off method_added callback to set focus on the method defined next.
Class Method Details
.add_to_filter(name) ⇒ Object
10 11 12 |
# File 'lib/minitest/focus.rb', line 10 def self.add_to_filter name @@filtered_names << "#{self}##{name}" end |
.filtered_names ⇒ Object
14 15 16 |
# File 'lib/minitest/focus.rb', line 14 def self.filtered_names @@filtered_names end |
.focus(name = nil) ⇒ Object
Focus on the next test defined. Cumulative. Equivalent to running with command line arg: -n /test_name|…/
class MyTest < Minitest::Test
# direct approach
focus def test_method1 # will run
...
end
# indirect approach
focus
def test_method2 # will run
...
end
def test_method3 # will NOT run
...
end
end
40 41 42 43 44 45 46 |
# File 'lib/minitest/focus.rb', line 40 def self.focus name = nil if name then add_to_filter name else set_focus_trap end end |
.set_focus_trap ⇒ Object
Sets a one-off method_added callback to set focus on the method defined next.
52 53 54 55 56 57 58 59 60 |
# File 'lib/minitest/focus.rb', line 52 def self.set_focus_trap = class << self; self; end .send :define_method, :method_added do |name| add_to_filter name .send :remove_method, :method_added end end |