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

.included(base) ⇒ Object



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

def included(base)
  base.extend(ClassMethods)

  [:setup, :cleanup, :teardown].each do |fixture|
    observer = Proc.new do |test_case, _, _, value, method_name|
      if value.nil?
        test_case.send("unregister_#{fixture}_method", method_name)
      else
        test_case.send("register_#{fixture}_method", method_name,
                       value)
      end
    end
    base.register_attribute_observer(fixture, &observer)
  end
end