Module: Test::Spec::TestCase::ClassMethods
- Defined in:
- lib/test-spec/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
Instance Attribute Details
#count ⇒ Object
Returns the value of attribute count.
260 261 262 |
# File 'lib/test-spec/test/spec.rb', line 260 def count @count end |
#name ⇒ Object
Returns the value of attribute name.
261 262 263 |
# File 'lib/test-spec/test/spec.rb', line 261 def name @name end |
#parent ⇒ Object
Returns the value of attribute parent.
263 264 265 |
# File 'lib/test-spec/test/spec.rb', line 263 def parent @parent end |
#position ⇒ Object
Returns the value of attribute position.
262 263 264 |
# File 'lib/test-spec/test/spec.rb', line 262 def position @position end |
#setups ⇒ Object
Returns the value of attribute setups.
265 266 267 |
# File 'lib/test-spec/test/spec.rb', line 265 def setups @setups end |
#teardowns ⇒ Object
Returns the value of attribute teardowns.
266 267 268 |
# File 'lib/test-spec/test/spec.rb', line 266 def teardowns @teardowns end |
Instance Method Details
#context(name, &block) ⇒ Object
268 269 270 271 |
# File 'lib/test-spec/test/spec.rb', line 268 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
291 292 293 294 295 296 297 298 299 300 301 302 303 304 |
# File 'lib/test-spec/test/spec.rb', line 291 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
283 284 285 |
# File 'lib/test-spec/test/spec.rb', line 283 def setup(&block) setups << block end |
#specify(specname, &block) ⇒ Object
273 274 275 276 277 278 279 280 281 |
# File 'lib/test-spec/test/spec.rb', line 273 def specify(specname, &block) raise ArgumentError, "specify needs a block" if block.nil? self.count += 1 # Let them run in order of definition # TODO Changed by Jean-Michel # define_method("test_%03d: %s" % [count, specname], &block) define_method("test_spec {%s} %03d [%s]" % [name, count, specname], &block) end |
#teardown(&block) ⇒ Object
287 288 289 |
# File 'lib/test-spec/test/spec.rb', line 287 def teardown(&block) teardowns << block end |