Class: Test::Spec::TestCase

Inherits:
Object show all
Defined in:
lib/test/spec.rb

Defined Under Namespace

Modules: ClassMethods, InstanceMethods

Constant Summary collapse

@@POSITION =
0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, parent = nil, superclass = Test::Unit::TestCase) ⇒ TestCase

Returns a new instance of TestCase.



500
501
502
503
504
505
506
507
508
# File 'lib/test/spec.rb', line 500

def initialize(name, parent=nil, superclass=Test::Unit::TestCase)
  @testcase = Class.new(superclass) {
    include InstanceMethods
    extend ClassMethods
  }

  @@POSITION = @@POSITION + 1
  @testcase.init(name, @@POSITION, parent)
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



329
330
331
# File 'lib/test/spec.rb', line 329

def name
  @name
end

#positionObject (readonly)

Returns the value of attribute position.



330
331
332
# File 'lib/test/spec.rb', line 330

def position
  @position
end

#testcaseObject (readonly)

Returns the value of attribute testcase.



328
329
330
# File 'lib/test/spec.rb', line 328

def testcase
  @testcase
end

Instance Method Details

#add(&block) ⇒ Object

Raises:

  • (ArgumentError)


510
511
512
513
514
515
# File 'lib/test/spec.rb', line 510

def add(&block)
  raise ArgumentError, "context needs a block"  if block.nil?

  @testcase.class_eval(&block)
  self
end