summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorryan <ryan@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-08-27 20:30:57 +0000
committerryan <ryan@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-08-27 20:30:57 +0000
commit4c66fc089080a63f58d95877130a0a0920a409c6 (patch)
tree7339f4d3da5a2d8eb4630dc5d2826a3fa91f6aaf /lib
parent0971109e3dcc8f30df79fba1ac6db174e7c7ecdc (diff)
Imported minitest 2.5.1 (r6596)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33102 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/minitest/spec.rb31
-rw-r--r--lib/minitest/unit.rb2
2 files changed, 27 insertions, 6 deletions
diff --git a/lib/minitest/spec.rb b/lib/minitest/spec.rb
index 7b414e324a..a70bbdd405 100644
--- a/lib/minitest/spec.rb
+++ b/lib/minitest/spec.rb
@@ -94,11 +94,27 @@ class MiniTest::Spec < MiniTest::Unit::TestCase
TYPES = [[//, MiniTest::Spec]]
##
- # Register a new type of spec that matches the spec's description. Eg:
+ # Register a new type of spec that matches the spec's description.
+ # This method can take either a Regexp and a spec class or a spec
+ # class and a block that takes the description and returns true if
+ # it matches.
#
- # register_spec_plugin(/Controller$/, MiniTest::Spec::Rails)
+ # Eg:
+ #
+ # register_spec_type(/Controller$/, MiniTest::Spec::Rails)
+ #
+ # or:
+ #
+ # register_spec_type(MiniTest::Spec::RailsModel) do |desc|
+ # desc.superclass == ActiveRecord::Base
+ # end
- def self.register_spec_type matcher, klass
+ def self.register_spec_type(*args, &block)
+ if block then
+ matcher, klass = block, args.first
+ else
+ matcher, klass = *args
+ end
TYPES.unshift [matcher, klass]
end
@@ -108,8 +124,13 @@ class MiniTest::Spec < MiniTest::Unit::TestCase
# spec_type("BlahController") # => MiniTest::Spec::Rails
def self.spec_type desc
- desc = desc.to_s
- TYPES.find { |re, klass| re === desc }.last
+ TYPES.find { |matcher, klass|
+ if matcher.respond_to? :call then
+ matcher.call desc
+ else
+ matcher === desc.to_s
+ end
+ }.last
end
@@describe_stack = []
diff --git a/lib/minitest/unit.rb b/lib/minitest/unit.rb
index 7fda1a0e22..922ef70183 100644
--- a/lib/minitest/unit.rb
+++ b/lib/minitest/unit.rb
@@ -620,7 +620,7 @@ module MiniTest
end
class Unit
- VERSION = "2.5.0" # :nodoc:
+ VERSION = "2.5.1" # :nodoc:
attr_accessor :report, :failures, :errors, :skips # :nodoc:
attr_accessor :test_count, :assertion_count # :nodoc: