Module: Test::Unit::Fixture
Relationships & Source Files | |
Namespace Children | |
Modules:
| |
Classes:
| |
Extension / Inclusion / Inheritance Descendants | |
Included In:
| |
Defined in: | lib/test/unit/fixture.rb |
Class Method Summary
Instance Method Summary
- #create_fixtures_runner(fixtures, options, &block) private
- #run_cleanup private
- #run_fixture(type, options = {}, &block) private
- #run_fixture_callback(method_name, options, &block) private
- #run_setup(&block) private
- #run_teardown private
Class Method Details
.included(base)
[ GitHub ]# File 'lib/test/unit/fixture.rb', line 5
def included(base) base.extend(ClassMethods) [:setup, :cleanup, :teardown].each do |type| observer = lambda do |test_case, _, _, value, callback| if value.nil? test_case.fixture[type].unregister(callback) else test_case.fixture[type].register(callback, value) end end base.register_attribute_observer(type, &observer) end end
Instance Method Details
#create_fixtures_runner(fixtures, options, &block) (private)
[ GitHub ]# File 'lib/test/unit/fixture.rb', line 259
def create_fixtures_runner(fixtures, , &block) if fixtures.empty? block else last_fixture = fixtures.pop create_fixtures_runner(fixtures, ) do block_is_called = false run_fixture_callback(last_fixture, ) do block_is_called = true block.call end block.call unless block_is_called end end end
#run_cleanup (private)
[ GitHub ]# File 'lib/test/unit/fixture.rb', line 289
def run_cleanup run_fixture(:cleanup) end
#run_fixture(type, options = {}, &block) (private)
[ GitHub ]# File 'lib/test/unit/fixture.rb', line 243
def run_fixture(type, ={}, &block) fixtures = [ self.class.fixture.before_callbacks(type), type, self.class.fixture.after_callbacks(type), ].flatten if block runner = create_fixtures_runner(fixtures, , &block) runner.call else fixtures.each do |method_name| run_fixture_callback(method_name, ) end end end
#run_fixture_callback(method_name, options, &block) (private)
[ GitHub ]# File 'lib/test/unit/fixture.rb', line 275
def run_fixture_callback(method_name, , &block) return unless respond_to?(method_name, true) begin __send__(method_name, &block) rescue Exception raise unless [:handle_exception] raise unless handle_exception($!) end end
#run_setup(&block) (private)
[ GitHub ]# File 'lib/test/unit/fixture.rb', line 285
def run_setup(&block) run_fixture(:setup, &block) end
#run_teardown (private)
[ GitHub ]# File 'lib/test/unit/fixture.rb', line 293
def run_teardown run_fixture(:teardown, :handle_exception => true) end