| Module | Test::Spec::TestCase::ClassMethods |
| In: |
lib/test/spec.rb
|
| after_all | [RW] | |
| before_all | [RW] | |
| count | [RW] | |
| name | [RW] | |
| parent | [RW] | |
| position | [RW] | |
| setups | [RW] | |
| teardowns | [RW] |
# File lib/test/spec.rb, line 465
465: def after(kind=:each, &block)
466: case kind
467: when :each
468: teardown(&block)
469: when :all
470: after_all << block
471: else
472: raise ArgumentError, "invalid argument: after(#{kind.inspect})"
473: end
474: end
# File lib/test/spec.rb, line 454
454: def before(kind=:each, &block)
455: case kind
456: when :each
457: setup(&block)
458: when :all
459: before_all << block
460: else
461: raise ArgumentError, "invalid argument: before(#{kind.inspect})"
462: end
463: end
# File lib/test/spec.rb, line 432
432: def behaves_like(shared_context)
433: if Test::Spec::SHARED_CONTEXTS.include?(shared_context)
434: Test::Spec::SHARED_CONTEXTS[shared_context].each { |block|
435: instance_eval(&block)
436: }
437: elsif Test::Spec::SHARED_CONTEXTS.include?(self.name + "\t" + shared_context)
438: Test::Spec::SHARED_CONTEXTS[self.name + "\t" + shared_context].each { |block|
439: instance_eval(&block)
440: }
441: else
442: raise NameError, "Shared context #{shared_context} not found."
443: end
444: end
old-style (RSpec <1.0):
# File lib/test/spec.rb, line 398
398: def context(name, superclass=Test::Unit::TestCase, klass=Test::Spec::TestCase, &block)
399: (Test::Spec::CONTEXTS[self.name + "\t" + name] ||= klass.new(name, self, superclass)).add(&block)
400: end
Alias for context
# File lib/test/spec.rb, line 477
477: def init(name, position, parent)
478: self.position = position
479: self.parent = parent
480:
481: if parent
482: self.name = parent.name + "\t" + name
483: else
484: self.name = name
485: end
486:
487: self.count = 0
488: self.setups = []
489: self.teardowns = []
490:
491: self.before_all = []
492: self.after_all = []
493: end
# File lib/test/spec.rb, line 428
428: def shared_context(name, &block)
429: Test::Spec::SHARED_CONTEXTS[self.name + "\t" + name] << block
430: end
# File lib/test/spec.rb, line 406
406: def specify(specname, &block)
407: raise ArgumentError, "specify needs a block" if block.nil?
408:
409: self.count += 1 # Let them run in order of definition
410:
411: define_method("test_spec {%s} %03d [%s]" % [name, count, specname], &block)
412: end
# File lib/test/spec.rb, line 402
402: def xcontext(name, superclass=Test::Unit::TestCase, &block)
403: context(name, superclass, Test::Spec::DisabledTestCase, &block)
404: end