Module: Test::Unit::Fixture

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

Defined Under Namespace

Modules: ClassMethods

Class Method Summary (collapse)

Class Method Details

+ (Object) included(base)



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 |fixture|
    observer = lambda do |test_case, _, _, value, callback|
      if value.nil?
        test_case.send("unregister_#{fixture}_callback", callback)
      else
        test_case.send("register_#{fixture}_callback", callback, value)
      end
    end
    base.register_attribute_observer(fixture, &observer)
  end
end