Imported minitest 2.5.1 (r6596)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33102 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
0971109e3d
commit
4c66fc0890
@ -1,3 +1,8 @@
|
|||||||
|
Sun Aug 28 05:29:50 2011 Ryan Davis <ryand-ruby@zenspider.com>
|
||||||
|
|
||||||
|
* lib/minitest/*: Imported minitest 2.5.1 (r6596)
|
||||||
|
* test/minitest/*: ditto
|
||||||
|
|
||||||
Sat Aug 27 20:46:05 2011 Kazuki Tsujimoto <kazuki@callcc.net>
|
Sat Aug 27 20:46:05 2011 Kazuki Tsujimoto <kazuki@callcc.net>
|
||||||
|
|
||||||
* vm.c (rb_vm_rewrite_dfp_in_errinfo): change return type
|
* vm.c (rb_vm_rewrite_dfp_in_errinfo): change return type
|
||||||
|
@ -94,11 +94,27 @@ class MiniTest::Spec < MiniTest::Unit::TestCase
|
|||||||
TYPES = [[//, MiniTest::Spec]]
|
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]
|
TYPES.unshift [matcher, klass]
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -108,8 +124,13 @@ class MiniTest::Spec < MiniTest::Unit::TestCase
|
|||||||
# spec_type("BlahController") # => MiniTest::Spec::Rails
|
# spec_type("BlahController") # => MiniTest::Spec::Rails
|
||||||
|
|
||||||
def self.spec_type desc
|
def self.spec_type desc
|
||||||
desc = desc.to_s
|
TYPES.find { |matcher, klass|
|
||||||
TYPES.find { |re, klass| re === desc }.last
|
if matcher.respond_to? :call then
|
||||||
|
matcher.call desc
|
||||||
|
else
|
||||||
|
matcher === desc.to_s
|
||||||
|
end
|
||||||
|
}.last
|
||||||
end
|
end
|
||||||
|
|
||||||
@@describe_stack = []
|
@@describe_stack = []
|
||||||
|
@ -620,7 +620,7 @@ module MiniTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
class Unit
|
class Unit
|
||||||
VERSION = "2.5.0" # :nodoc:
|
VERSION = "2.5.1" # :nodoc:
|
||||||
|
|
||||||
attr_accessor :report, :failures, :errors, :skips # :nodoc:
|
attr_accessor :report, :failures, :errors, :skips # :nodoc:
|
||||||
attr_accessor :test_count, :assertion_count # :nodoc:
|
attr_accessor :test_count, :assertion_count # :nodoc:
|
||||||
|
@ -7,6 +7,11 @@
|
|||||||
require 'minitest/autorun'
|
require 'minitest/autorun'
|
||||||
require 'stringio'
|
require 'stringio'
|
||||||
|
|
||||||
|
class MiniSpecA < MiniTest::Spec; end
|
||||||
|
class MiniSpecB < MiniTest::Spec; end
|
||||||
|
class ExampleA; end
|
||||||
|
class ExampleB < ExampleA; end
|
||||||
|
|
||||||
describe MiniTest::Spec do
|
describe MiniTest::Spec do
|
||||||
before do
|
before do
|
||||||
@assertion_count = 4
|
@assertion_count = 4
|
||||||
@ -279,6 +284,38 @@ class TestMeta < MiniTest::Unit::TestCase
|
|||||||
return x, y, z, before_list, after_list
|
return x, y, z, before_list, after_list
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_register_spec_type
|
||||||
|
original_types = MiniTest::Spec::TYPES.dup
|
||||||
|
|
||||||
|
assert_equal [[//, MiniTest::Spec]], MiniTest::Spec::TYPES
|
||||||
|
|
||||||
|
MiniTest::Spec.register_spec_type(/woot/, TestMeta)
|
||||||
|
|
||||||
|
p = lambda do |x| true end
|
||||||
|
MiniTest::Spec.register_spec_type TestMeta, &p
|
||||||
|
|
||||||
|
keys = MiniTest::Spec::TYPES.map(&:first)
|
||||||
|
|
||||||
|
assert_includes keys, /woot/
|
||||||
|
assert_includes keys, p
|
||||||
|
ensure
|
||||||
|
MiniTest::Spec::TYPES.replace original_types
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_spec_type
|
||||||
|
original_types = MiniTest::Spec::TYPES.dup
|
||||||
|
|
||||||
|
MiniTest::Spec.register_spec_type(/A$/, MiniSpecA)
|
||||||
|
MiniTest::Spec.register_spec_type MiniSpecB do |desc|
|
||||||
|
desc.superclass == ExampleA
|
||||||
|
end
|
||||||
|
|
||||||
|
assert_equal MiniSpecA, MiniTest::Spec.spec_type(ExampleA)
|
||||||
|
assert_equal MiniSpecB, MiniTest::Spec.spec_type(ExampleB)
|
||||||
|
ensure
|
||||||
|
MiniTest::Spec::TYPES.replace original_types
|
||||||
|
end
|
||||||
|
|
||||||
def test_structure
|
def test_structure
|
||||||
x, y, z, * = util_structure
|
x, y, z, * = util_structure
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user