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
# File 'lib/test/unit/fixture.rb', line 25

def initialize(test_case)
  @test_case = test_case
  @setup = HookPoint.new(:after => :append)
  @cleanup = HookPoint.new(:before => :prepend)
  @teardown = HookPoint.new(:before => :prepend)
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



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

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

#after_callbacks(type) ⇒ Object



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

def after_callbacks(type)
  target_test_cases.inject([]) do |callbacks, ancestor|
    callbacks | ancestor.fixture[type].after_callbacks
  end
end

#before_callbacks(type) ⇒ Object



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

def before_callbacks(type)
  target_test_cases.inject([]) do |callbacks, ancestor|
    callbacks | ancestor.fixture[type].before_callbacks
  end
end