Module: Test::Unit::Fixture

Included in:
TestCase
Defined in:
lib/test/unit/fixture.rb

Defined Under Namespace

Modules: ClassMethods Classes: Fixture, HookPoint

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/test/unit/fixture.rb', line 5

def included(base)
  base.extend(ClassMethods)

  [:setup, :cleanup, :teardown].each do |type|
    observer = lambda do |test_case, _, _, value, callback|
      if value.nil?
        test_case.fixture[type].unregister(callback)
      else
        test_case.fixture[type].register(callback, value)
      end
    end
    base.register_attribute_observer(type, &observer)
  end
end