Module: Kernel

Defined in:
lib/mini_shoulda/minitest_describe_patch.rb

Overview

I currently have a patch submitted to minitest to allow parent classes to maintain their inhertance chain when describe blocks are used. Please help me get it into core! github.com/seattlerb/minitest/pull/9

Instance Method Summary collapse

Instance Method Details

#describe(desc, &block) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/mini_shoulda/minitest_describe_patch.rb', line 7

def describe desc, &block
  stack = MiniTest::Spec.describe_stack
  name  = [stack.last, desc].compact.join("::")
  sclas = stack.last || (self.is_a?(Class) && self < MiniTest::Spec ? self : MiniTest::Spec)
  cls   = Class.new(sclas)
  (class << cls; self; end).send(:define_method, :to_s) { name }
  cls.nuke_test_methods!
  stack.push cls
  cls.class_eval(&block)
  stack.pop
  cls
end