Class: Test::Spec::TestCase

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

Direct Known Subclasses

FocusedTestCase

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.



529
530
531
532
533
534
535
536
537
538
539
# File 'lib/test/spec.rb', line 529

def initialize(name, parent=nil, superclass=Test::Unit::TestCase)
  @testcase = Class.new(superclass) {
    include Test::Spec::TestCase::InstanceMethods
    extend Test::Spec::TestCase::ClassMethods
    # p "extending onto #{self} with class #{self.class} with superclass #{superclass} and ancestors #{self.ancestors.join(",")}"
  }
  
  @@POSITION ||= 0
  @@POSITION = @@POSITION + 1
  @testcase.init(name, @@POSITION, parent)
end

Instance Attribute Details

#ignoreObject

Returns the value of attribute ignore.



335
336
337
# File 'lib/test/spec.rb', line 335

def ignore
  @ignore
end

#nameObject (readonly)

Returns the value of attribute name.



333
334
335
# File 'lib/test/spec.rb', line 333

def name
  @name
end

#positionObject (readonly)

Returns the value of attribute position.



334
335
336
# File 'lib/test/spec.rb', line 334

def position
  @position
end

#testcaseObject (readonly)

Returns the value of attribute testcase.



332
333
334
# File 'lib/test/spec.rb', line 332

def testcase
  @testcase
end

Instance Method Details

#add(&block) ⇒ Object

Raises:

  • (ArgumentError)


541
542
543
544
545
546
# File 'lib/test/spec.rb', line 541

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

  @testcase.class_eval(&block)
  self
end

#ignore?Boolean

Returns:

  • (Boolean)


548
549
550
# File 'lib/test/spec.rb', line 548

def ignore?
  @ignore == true
end