Skip to content

Instantly share code, notes, and snippets.

@practicingruby
Forked from defunkt/test-spec-mini.rb
Created April 20, 2011 16:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save practicingruby/931898 to your computer and use it in GitHub Desktop.
Save practicingruby/931898 to your computer and use it in GitHub Desktop.
require "minitest/autorun"
# inspired by some code from Chris Wanstrath (shared w. me by Ryan Smith)
# https://gist.github.com/25455
#
# heavily modified by Gregory Brown at this point..
def context(*args, &block)
return super unless (name = args.first) && block
context_class = Class.new(MiniTest::Unit::TestCase) do
class << self
def test(name, &block)
block ||= lambda { skip(name) }
define_method("test: #{name} ", &block)
end
def setup(&block)
define_method(:setup, &block)
end
def teardown(&block)
define_method(:teardown, &block)
end
def to_s
name
end
end
end
context_class.singleton_class.instance_eval do
define_method(:name) { name }
end
context_class.class_eval(&block)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment