Class: Test::Unit::Fixture::Fixture

Inherits:
Object
  • Object
show all
Defined in:
lib/test/unit/fixture.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(test_case) ⇒ Fixture

Returns a new instance of Fixture.



25
26
27
28
29
30
31
32
# File 'lib/test/unit/fixture.rb', line 25

def initialize(test_case)
  @test_case = test_case
  @setup = HookPoint.new(@test_case, :setup, :after => :append)
  @cleanup = HookPoint.new(@test_case, :cleanup, :before => :prepend)
  @teardown = HookPoint.new(@test_case, :teardown, :before => :prepend)
  @cached_before_callbacks = {}
  @cached_after_callbacks = {}
end

Instance Attribute Details

#cleanupObject (readonly)

Returns the value of attribute cleanup



23
24
25
# File 'lib/test/unit/fixture.rb', line 23

def cleanup
  @cleanup
end

#setupObject (readonly)

Returns the value of attribute setup



22
23
24
# File 'lib/test/unit/fixture.rb', line 22

def setup
  @setup
end

#teardownObject (readonly)

Returns the value of attribute teardown



24
25
26
# File 'lib/test/unit/fixture.rb', line 24

def teardown
  @teardown
end

Instance Method Details

#[](type) ⇒ Object



34
35
36
37
38
39
40
41
42
43
# File 'lib/test/unit/fixture.rb', line 34

def [](type)
  case type
  when :setup
    @setup
  when :cleanup
    @cleanup
  when :teardown
    @teardown
  end
end

#after_callbacks(type) ⇒ Object



49
50
51
# File 'lib/test/unit/fixture.rb', line 49

def after_callbacks(type)
  @cached_after_callbacks[type] ||= collect_after_callbacks(type)
end

#before_callbacks(type) ⇒ Object



45
46
47
# File 'lib/test/unit/fixture.rb', line 45

def before_callbacks(type)
  @cached_before_callbacks[type] ||= collect_before_callbacks(type)
end