Module Test::Spec::TestCase::ClassMethods
In: lib/test/spec.rb

Methods

Attributes

after_all  [RW] 
before_all  [RW] 
count  [RW] 
name  [RW] 
parent  [RW] 
position  [RW] 
setups  [RW] 
teardowns  [RW] 

Public Instance methods

[Source]

     # File lib/test/spec.rb, line 467
467:     def after(kind=:each, &block)
468:       case kind
469:       when :each
470:         teardown(&block)
471:       when :all
472:         after_all << block
473:       else
474:         raise ArgumentError, "invalid argument: after(#{kind.inspect})"
475:       end
476:     end

[Source]

     # File lib/test/spec.rb, line 456
456:     def before(kind=:each, &block)
457:       case kind
458:       when :each
459:         setup(&block)
460:       when :all
461:         before_all << block
462:       else
463:         raise ArgumentError, "invalid argument: before(#{kind.inspect})"
464:       end
465:     end

[Source]

     # File lib/test/spec.rb, line 434
434:     def behaves_like(shared_context)
435:       if Test::Spec::SHARED_CONTEXTS.include?(shared_context)
436:         Test::Spec::SHARED_CONTEXTS[shared_context].each { |block|
437:           instance_eval(&block)
438:         }
439:       elsif Test::Spec::SHARED_CONTEXTS.include?(self.name + "\t" + shared_context)
440:         Test::Spec::SHARED_CONTEXTS[self.name + "\t" + shared_context].each { |block|
441:           instance_eval(&block)
442:         }
443:       else
444:         raise NameError, "Shared context #{shared_context} not found."
445:       end
446:     end

old-style (RSpec <1.0):

[Source]

     # File lib/test/spec.rb, line 400
400:     def context(name, superclass=Test::Unit::TestCase, klass=Test::Spec::TestCase, &block)
401:       (Test::Spec::CONTEXTS[self.name + "\t" + name] ||= klass.new(name, self, superclass)).add(&block)
402:     end
describe(name, superclass=Test::Unit::TestCase, klass=Test::Spec::TestCase, &block)

Alias for context

describe_shared(name, &block)

Alias for shared_context

[Source]

     # File lib/test/spec.rb, line 479
479:     def init(name, position, parent)
480:       self.position = position
481:       self.parent = parent
482:       
483:       if parent
484:         self.name = parent.name + "\t" + name
485:       else
486:         self.name = name
487:       end
488: 
489:       self.count = 0
490:       self.setups = []
491:       self.teardowns = []
492: 
493:       self.before_all = []
494:       self.after_all = []
495:     end
it(specname, &block)

Alias for specify

it_should_behave_like(shared_context)

Alias for behaves_like

[Source]

     # File lib/test/spec.rb, line 422
422:     def setup(&block)
423:       setups << block
424:     end

[Source]

     # File lib/test/spec.rb, line 430
430:     def shared_context(name, &block)
431:       Test::Spec::SHARED_CONTEXTS[self.name + "\t" + name] << block
432:     end

[Source]

     # File lib/test/spec.rb, line 408
408:     def specify(specname, &block)
409:       raise ArgumentError, "specify needs a block"  if block.nil?
410:       
411:       self.count += 1                 # Let them run in order of definition
412:       
413:       define_method("test_spec {%s} %03d [%s]" % [name, count, specname], &block)
414:     end

[Source]

     # File lib/test/spec.rb, line 426
426:     def teardown(&block)
427:       teardowns << block
428:     end

[Source]

     # File lib/test/spec.rb, line 404
404:     def xcontext(name, superclass=Test::Unit::TestCase, &block)
405:       context(name, superclass, Test::Spec::DisabledTestCase, &block)
406:     end
xit(specname, &block)

Alias for xspecify

[Source]

     # File lib/test/spec.rb, line 416
416:     def xspecify(specname, &block)
417:       specify specname do
418:         @_result.add_disabled(specname)
419:       end
420:     end

[Validate]