Module: Phocus::ClassMethods

Defined in:
lib/phocus.rb

Constant Summary collapse

@@__test_methods =
{}
@@__focused =
false
@@__focus_next =
false

Instance Method Summary collapse

Instance Method Details

#focusObject Also known as: focused, phocus

Use right before defining a method to focus it.



82
83
84
85
86
87
88
# File 'lib/phocus.rb', line 82

def focus
  unless @@__focused
    clear_test_methods!
    @@__focused = true
  end
  @@__focus_next = true
end

#method_added(name) ⇒ Object

If the method belongs to target group (method_pattern), then remove it unless it is focused.

We don’t want any methods removed if focus is never used, so until it is, keep a reference to methods being defined so that we can come back and remove them later.



101
102
103
104
105
106
107
108
109
110
# File 'lib/phocus.rb', line 101

def method_added(name) #:nodoc:
  if name.to_s.match(Phocus.method_pattern)
    if @@__focused
      @@__focus_next ? @@__focus_next = false : remove_method(name)
    else
      @@__test_methods[self] ||= []
      @@__test_methods[self] << name
    end
  end
end