Class: Test::Unit::Fixture::Fixture
Relationships & Source Files | |
Inherits: | Object |
Defined in: | lib/test/unit/fixture.rb |
Class Method Summary
- .new(test_case) ⇒ Fixture constructor
Instance Attribute Summary
Instance Method Summary
Constructor Details
.new(test_case) ⇒ Fixture
# 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
#cleanup (readonly)
[ GitHub ]# File 'lib/test/unit/fixture.rb', line 23
attr_reader :cleanup
#setup (readonly)
[ GitHub ]# File 'lib/test/unit/fixture.rb', line 22
attr_reader :setup
#teardown (readonly)
[ GitHub ]# File 'lib/test/unit/fixture.rb', line 24
attr_reader :teardown
Instance Method Details
#[](type)
[ GitHub ]#after_callbacks(type)
[ GitHub ]# File 'lib/test/unit/fixture.rb', line 49
def after_callbacks(type) @cached_after_callbacks[type] ||= collect_after_callbacks(type) end
#before_callbacks(type)
[ GitHub ]# File 'lib/test/unit/fixture.rb', line 45
def before_callbacks(type) @cached_before_callbacks[type] ||= collect_before_callbacks(type) end
#collect_after_callbacks(type) (private)
[ GitHub ]# File 'lib/test/unit/fixture.rb', line 69
def collect_after_callbacks(type) prepend_callbacks = [] append_callbacks = [] target_test_cases.each do |ancestor| prepend_callbacks << ancestor.fixture[type].after_prepend_callbacks append_callbacks << ancestor.fixture[type].after_append_callbacks end merge_callbacks(prepend_callbacks, append_callbacks) end
#collect_before_callbacks(type) (private)
[ GitHub ]# File 'lib/test/unit/fixture.rb', line 58
def collect_before_callbacks(type) prepend_callbacks = [] append_callbacks = [] target_test_cases.each do |ancestor| prepend_callbacks << ancestor.fixture[type].before_prepend_callbacks append_callbacks << ancestor.fixture[type].before_append_callbacks end merge_callbacks(prepend_callbacks, append_callbacks) end
#collect_target_test_cases (private)
[ GitHub ]#merge_callbacks(prepend_callbacks, append_callbacks) (private)
[ GitHub ]# File 'lib/test/unit/fixture.rb', line 89
def merge_callbacks(prepend_callbacks, append_callbacks) all_callbacks = [] prepend_callbacks.reverse_each do |callbacks| all_callbacks.concat(callbacks) end append_callbacks.each do |callbacks| all_callbacks.concat(callbacks) end all_callbacks end
#target_test_cases (private)
[ GitHub ]# File 'lib/test/unit/fixture.rb', line 54
def target_test_cases @cached_target_test_cases ||= collect_target_test_cases end