Skip to content

Instantly share code, notes, and snippets.

@practicingruby
Created April 16, 2011 17:47
Show Gist options
  • Select an option

  • Save practicingruby/923335 to your computer and use it in GitHub Desktop.

Select an option

Save practicingruby/923335 to your computer and use it in GitHub Desktop.
require "minitest/autorun"
require_relative "../lib/ivory_tower"
require_relative "shared/allowed_units"
# adopted from: https://gist.github.com/839034
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)
test_method_name = "test_#{name.gsub(/\W/,'_')}"
block ||= lambda { skip(name) }
define_method(test_method_name, &block)
end
def setup(&block)
define_method(:setup, &block)
end
def teardown(&block)
define_method(:teardown, &block)
end
end
end
context_class.singleton_class.instance_eval do
define_method(:name) { name.gsub(/\W/,'_') }
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