Module: Test::Spec::TestCase::ClassMethods
- Defined in:
- lib/test/spec.rb
Instance Attribute Summary collapse
-
#count ⇒ Object
Returns the value of attribute count.
-
#name ⇒ Object
Returns the value of attribute name.
-
#parent ⇒ Object
Returns the value of attribute parent.
-
#position ⇒ Object
Returns the value of attribute position.
-
#setups ⇒ Object
Returns the value of attribute setups.
-
#teardowns ⇒ Object
Returns the value of attribute teardowns.
Instance Method Summary collapse
- #context(name, &block) ⇒ Object
- #init(name, position, parent) ⇒ Object
- #setup(&block) ⇒ Object
- #specify(specname, &block) ⇒ Object
- #teardown(&block) ⇒ Object
- #xspecify(specname, &block) ⇒ Object
Instance Attribute Details
#count ⇒ Object
Returns the value of attribute count.
342 343 344 |
# File 'lib/test/spec.rb', line 342 def count @count end |
#name ⇒ Object
Returns the value of attribute name.
343 344 345 |
# File 'lib/test/spec.rb', line 343 def name @name end |
#parent ⇒ Object
Returns the value of attribute parent.
345 346 347 |
# File 'lib/test/spec.rb', line 345 def parent @parent end |
#position ⇒ Object
Returns the value of attribute position.
344 345 346 |
# File 'lib/test/spec.rb', line 344 def position @position end |
#setups ⇒ Object
Returns the value of attribute setups.
347 348 349 |
# File 'lib/test/spec.rb', line 347 def setups @setups end |
#teardowns ⇒ Object
Returns the value of attribute teardowns.
348 349 350 |
# File 'lib/test/spec.rb', line 348 def teardowns @teardowns end |
Instance Method Details
#context(name, &block) ⇒ Object
350 351 352 353 |
# File 'lib/test/spec.rb', line 350 def context(name, &block) (Test::Spec::CONTEXTS[self.name + "\t" + name] ||= Test::Spec::TestCase.new(name, self)).add(&block) end |
#init(name, position, parent) ⇒ Object
379 380 381 382 383 384 385 386 387 388 389 390 391 392 |
# File 'lib/test/spec.rb', line 379 def init(name, position, parent) self.position = position self.parent = parent if parent self.name = parent.name + "\t" + name else self.name = name end self.count = 0 self.setups = [] self.teardowns = [] end |
#setup(&block) ⇒ Object
371 372 373 |
# File 'lib/test/spec.rb', line 371 def setup(&block) setups << block end |
#specify(specname, &block) ⇒ Object
355 356 357 358 359 360 361 |
# File 'lib/test/spec.rb', line 355 def specify(specname, &block) raise ArgumentError, "specify needs a block" if block.nil? self.count += 1 # Let them run in order of definition define_method("test_spec {%s} %03d [%s]" % [name, count, specname], &block) end |
#teardown(&block) ⇒ Object
375 376 377 |
# File 'lib/test/spec.rb', line 375 def teardown(&block) teardowns << block end |
#xspecify(specname, &block) ⇒ Object
363 364 365 366 367 368 369 |
# File 'lib/test/spec.rb', line 363 def xspecify(specname, &block) raise ArgumentError, "xspecify needs a block" if block.nil? specify specname do @_result.add_disabled(specname) end end |