# File lib/test/spec.rb, line 467 def after(kind=:each, &block) case kind when :each teardown(&block) when :all after_all << block else raise ArgumentError, "invalid argument: after(#{kind.inspect})" end end
# File lib/test/spec.rb, line 456 def before(kind=:each, &block) case kind when :each setup(&block) when :all before_all << block else raise ArgumentError, "invalid argument: before(#{kind.inspect})" end end
# File lib/test/spec.rb, line 434 def behaves_like(shared_context) if Test::Spec::SHARED_CONTEXTS.include?(shared_context) Test::Spec::SHARED_CONTEXTS[shared_context].each { |block| instance_eval(&block) } elsif Test::Spec::SHARED_CONTEXTS.include?(self.name + "\t" + shared_context) Test::Spec::SHARED_CONTEXTS[self.name + "\t" + shared_context].each { |block| instance_eval(&block) } else raise NameError, "Shared context #{shared_context} not found." end end
old-style (RSpec <1.0):
# File lib/test/spec.rb, line 400 def context(name, superclass=Test::Unit::TestCase, klass=Test::Spec::TestCase, &block) (Test::Spec::CONTEXTS[self.name + "\t" + name] ||= klass.new(name, self, superclass)).add(&block) end
new-style (RSpec 1.0+):
# File lib/test/spec.rb, line 479 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 = [] self.before_all = [] self.after_all = [] end
# File lib/test/spec.rb, line 422 def setup(&block) setups << block end
# File lib/test/spec.rb, line 408 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
# File lib/test/spec.rb, line 426 def teardown(&block) teardowns << block end
# File lib/test/spec.rb, line 404 def xcontext(name, superclass=Test::Unit::TestCase, &block) context(name, superclass, Test::Spec::DisabledTestCase, &block) end
# File lib/test/spec.rb, line 416 def xspecify(specname, &block) specify specname do @_result.add_disabled(specname) end end
Generated with the Darkfish Rdoc Generator 2.