summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorryan <ryan@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-08-21 00:39:57 +0000
committerryan <ryan@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-08-21 00:39:57 +0000
commit17dde49326abb035ef14cd4be8b33337c6248e82 (patch)
tree56d367373041ffb1c72e6b288fda481c789eddce /test
parentba661182a40a486f089e63889897ab98d9db85b5 (diff)
Imported minitest 3.3.0 (r7676)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36747 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/minitest/metametameta.rb22
-rw-r--r--test/minitest/test_minitest_spec.rb27
-rw-r--r--test/minitest/test_minitest_unit.rb383
3 files changed, 162 insertions, 270 deletions
diff --git a/test/minitest/metametameta.rb b/test/minitest/metametameta.rb
index 35a27d51b6..a4f7dfa1e6 100644
--- a/test/minitest/metametameta.rb
+++ b/test/minitest/metametameta.rb
@@ -9,25 +9,29 @@ require 'tempfile'
require 'stringio'
require 'minitest/autorun'
+class MiniTest::Unit::TestCase
+ def clean s
+ s.gsub(/^ {6}/, '')
+ end
+end
+
class MetaMetaMetaTestCase < MiniTest::Unit::TestCase
- def assert_report expected = nil
- expected ||= <<-EOM.gsub(/^ {6}/, '')
- Run options: --seed 42
+ def assert_report expected, flags = %w[--seed 42]
+ header = clean <<-EOM
+ Run options: #{flags.map { |s| s =~ /\|/ ? s.inspect : s }.join " "}
# Running tests:
- .
-
- Finished tests in 0.00
-
- 1 tests, 1 assertions, 0 failures, 0 errors, 0 skips
EOM
+ @tu.run flags
+
output = @output.string.dup
output.sub!(/Finished tests in .*/, "Finished tests in 0.00")
output.sub!(/Loaded suite .*/, 'Loaded suite blah')
output.gsub!(/ = \d+.\d\d s = /, ' = 0.00 s = ')
+ output.gsub!(/0x[A-Fa-f0-9]+/, '0xXXX')
if windows? then
output.gsub!(/\[(?:[A-Za-z]:)?[^\]:]+:\d+\]/, '[FILE:LINE]')
@@ -37,7 +41,7 @@ class MetaMetaMetaTestCase < MiniTest::Unit::TestCase
output.gsub!(/^(\s+)[^:]+:\d+:in/, '\1FILE:LINE:in')
end
- assert_equal(expected, output)
+ assert_equal header + expected, output
end
def setup
diff --git a/test/minitest/test_minitest_spec.rb b/test/minitest/test_minitest_spec.rb
index d267e8d7d0..56aa78d620 100644
--- a/test/minitest/test_minitest_spec.rb
+++ b/test/minitest/test_minitest_spec.rb
@@ -637,20 +637,20 @@ class TestMeta < MiniTest::Unit::TestCase
def test_structure
x, y, z, * = util_structure
- assert_equal "top-level thingy", x.to_s
- assert_equal "top-level thingy::inner thingy", y.to_s
+ assert_equal "top-level thingy", x.to_s
+ assert_equal "top-level thingy::inner thingy", y.to_s
assert_equal "top-level thingy::inner thingy::very inner thingy", z.to_s
- assert_equal "top-level thingy", x.desc
- assert_equal "inner thingy", y.desc
+ assert_equal "top-level thingy", x.desc
+ assert_equal "inner thingy", y.desc
assert_equal "very inner thingy", z.desc
- top_methods = %w(test_0001_top-level-it)
- inner_methods1 = %w(test_0001_inner-it)
+ top_methods = %w(setup teardown test_0001_top-level-it)
+ inner_methods1 = %w(setup teardown test_0001_inner-it)
inner_methods2 = inner_methods1 +
%w(test_0002_anonymous test_0003_anonymous)
- assert_equal top_methods, x.instance_methods(false).sort.map(&:to_s)
+ assert_equal top_methods, x.instance_methods(false).sort.map(&:to_s)
assert_equal inner_methods1, y.instance_methods(false).sort.map(&:to_s)
assert_equal inner_methods2, z.instance_methods(false).sort.map(&:to_s)
end
@@ -658,13 +658,18 @@ class TestMeta < MiniTest::Unit::TestCase
def test_setup_teardown_behavior
_, _, z, before_list, after_list = util_structure
- tc = z.new(nil)
+ @tu = MiniTest::Unit.new
+ @output = StringIO.new("")
+ MiniTest::Unit.runner = nil # protect the outer runner from the inner tests
+ MiniTest::Unit.output = @output
- tc.run_setup_hooks
- tc.run_teardown_hooks
+ tc = z.new :test_0002_anonymous
+ tc.run @tu
assert_equal [1, 2, 3], before_list
assert_equal [3, 2, 1], after_list
+ ensure
+ MiniTest::Unit.output = $stdout
end
def test_children
@@ -696,7 +701,7 @@ class TestMeta < MiniTest::Unit::TestCase
z = describe "second thingy" do end
end
- test_methods = ['test_0001_top level it', 'test_0002_не латинские буквы-и-спецсимволы&いった α, β, γ, δ, ε hello!!! world'].sort
+ test_methods = ['test_0001_top level it', 'test_0002_не латинские буквы-и-спецсимволы&いった α, β, γ, δ, ε hello!!! world'].sort
assert_equal test_methods, [x1, x2]
assert_equal test_methods,
diff --git a/test/minitest/test_minitest_unit.rb b/test/minitest/test_minitest_unit.rb
index b27f3fde33..28c6e93028 100644
--- a/test/minitest/test_minitest_unit.rb
+++ b/test/minitest/test_minitest_unit.rb
@@ -13,8 +13,8 @@ class AnError < StandardError; include MyModule; end
class ImmutableString < String; def inspect; super.freeze; end; end
class TestMiniTestUnit < MetaMetaMetaTestCase
- pwd = Pathname.new(File.expand_path(Dir.pwd))
- basedir = Pathname.new(File.expand_path("lib/minitest")) + 'mini'
+ pwd = Pathname.new File.expand_path Dir.pwd
+ basedir = Pathname.new(File.expand_path "lib/minitest") + 'mini'
basedir = basedir.relative_path_from(pwd).to_s
MINITEST_BASE_DIR = basedir[/\A\./] ? basedir : "./#{basedir}"
BT_MIDDLE = ["#{MINITEST_BASE_DIR}/test.rb:161:in `each'",
@@ -152,12 +152,12 @@ class TestMiniTestUnit < MetaMetaMetaTestCase
bt = util_expand_bt bt
ex = ["-e:1"]
- fu = MiniTest::filter_backtrace(bt)
+ fu = MiniTest::filter_backtrace bt
assert_equal ex, fu
end
def test_run_test
- tc = Class.new(MiniTest::Unit::TestCase) do
+ Class.new MiniTest::Unit::TestCase do
attr_reader :foo
def run_test name
@@ -171,25 +171,19 @@ class TestMiniTestUnit < MetaMetaMetaTestCase
end
end
- Object.const_set(:ATestCase, tc)
-
- @tu.run %w[--seed 42]
-
- expected = "Run options: --seed 42
-
-# Running tests:
+ expected = clean <<-EOM
+ .
-.
+ Finished tests in 0.00
-Finished tests in 0.00
+ 1 tests, 1 assertions, 0 failures, 0 errors, 0 skips
+ EOM
-1 tests, 1 assertions, 0 failures, 0 errors, 0 skips
-"
assert_report expected
end
def test_run_error
- tc = Class.new(MiniTest::Unit::TestCase) do
+ Class.new MiniTest::Unit::TestCase do
def test_something
assert true
end
@@ -199,21 +193,13 @@ Finished tests in 0.00
end
end
- Object.const_set(:ATestCase, tc)
-
- @tu.run %w[--seed 42]
-
- expected = <<-EOM.gsub(/^ {6}/, '')
- Run options: --seed 42
-
- # Running tests:
-
+ expected = clean <<-EOM
E.
Finished tests in 0.00
1) Error:
- test_error(ATestCase):
+ test_error(#<Class:0xXXX>):
RuntimeError: unhandled exception
FILE:LINE:in `test_error'
@@ -224,7 +210,7 @@ Finished tests in 0.00
end
def test_run_error_teardown
- tc = Class.new(MiniTest::Unit::TestCase) do
+ Class.new MiniTest::Unit::TestCase do
def test_something
assert true
end
@@ -234,30 +220,24 @@ Finished tests in 0.00
end
end
- Object.const_set(:ATestCase, tc)
-
- @tu.run %w[--seed 42]
-
- expected = "Run options: --seed 42
+ expected = clean <<-EOM
+ E
-# Running tests:
-
-E
+ Finished tests in 0.00
-Finished tests in 0.00
+ 1) Error:
+ test_something(#<Class:0xXXX>):
+ RuntimeError: unhandled exception
+ FILE:LINE:in `teardown'
- 1) Error:
-test_something(ATestCase):
-RuntimeError: unhandled exception
- FILE:LINE:in `teardown'
+ 1 tests, 1 assertions, 0 failures, 1 errors, 0 skips
+ EOM
-1 tests, 1 assertions, 0 failures, 1 errors, 0 skips
-"
assert_report expected
end
def test_run_failing
- tc = Class.new(MiniTest::Unit::TestCase) do
+ Class.new MiniTest::Unit::TestCase do
def test_something
assert true
end
@@ -267,29 +247,23 @@ RuntimeError: unhandled exception
end
end
- Object.const_set(:ATestCase, tc)
-
- @tu.run %w[--seed 42]
+ expected = clean <<-EOM
+ F.
- expected = "Run options: --seed 42
-
-# Running tests:
-
-F.
+ Finished tests in 0.00
-Finished tests in 0.00
+ 1) Failure:
+ test_failure(#<Class:0xXXX>) [FILE:LINE]:
+ Failed assertion, no message given.
- 1) Failure:
-test_failure(ATestCase) [FILE:LINE]:
-Failed assertion, no message given.
+ 2 tests, 2 assertions, 1 failures, 0 errors, 0 skips
+ EOM
-2 tests, 2 assertions, 1 failures, 0 errors, 0 skips
-"
assert_report expected
end
def test_run_failing_filtered
- tc = Class.new(MiniTest::Unit::TestCase) do
+ Class.new MiniTest::Unit::TestCase do
def test_something
assert true
end
@@ -299,39 +273,37 @@ Failed assertion, no message given.
end
end
- Object.const_set(:ATestCase, tc)
+ expected = clean <<-EOM
+ .
- @tu.run %w[--name /some|thing/ --seed 42]
-
- expected = "Run options: --name \"/some|thing/\" --seed 42
-
-# Running tests:
-
-.
+ Finished tests in 0.00
-Finished tests in 0.00
+ 1 tests, 1 assertions, 0 failures, 0 errors, 0 skips
+ EOM
-1 tests, 1 assertions, 0 failures, 0 errors, 0 skips
-"
- assert_report expected
+ assert_report expected, %w[--name /some|thing/ --seed 42]
end
def test_run_passing
- tc = Class.new(MiniTest::Unit::TestCase) do
+ Class.new MiniTest::Unit::TestCase do
def test_something
assert true
end
end
- Object.const_set(:ATestCase, tc)
+ expected = clean <<-EOM
+ .
- @tu.run %w[--seed 42]
+ Finished tests in 0.00
- assert_report
+ 1 tests, 1 assertions, 0 failures, 0 errors, 0 skips
+ EOM
+
+ assert_report expected
end
def test_run_skip
- tc = Class.new(MiniTest::Unit::TestCase) do
+ Class.new MiniTest::Unit::TestCase do
def test_something
assert true
end
@@ -341,25 +313,19 @@ Finished tests in 0.00
end
end
- Object.const_set(:ATestCase, tc)
-
- @tu.run %w[--seed 42]
+ expected = clean <<-EOM
+ S.
- expected = "Run options: --seed 42
-
-# Running tests:
-
-S.
+ Finished tests in 0.00
-Finished tests in 0.00
+ 2 tests, 1 assertions, 0 failures, 0 errors, 1 skips
+ EOM
-2 tests, 1 assertions, 0 failures, 0 errors, 1 skips
-"
assert_report expected
end
def test_run_skip_verbose
- tc = Class.new(MiniTest::Unit::TestCase) do
+ Class.new MiniTest::Unit::TestCase do
def test_something
assert true
end
@@ -369,27 +335,21 @@ Finished tests in 0.00
end
end
- Object.const_set(:ATestCase, tc)
+ expected = clean <<-EOM
+ #<Class:0xXXX>#test_skip = 0.00 s = S
+ #<Class:0xXXX>#test_something = 0.00 s = .
- @tu.run %w[--seed 42 --verbose]
-
- expected = "Run options: --seed 42 --verbose
-
-# Running tests:
-
-ATestCase#test_skip = 0.00 s = S
-ATestCase#test_something = 0.00 s = .
+ Finished tests in 0.00
-Finished tests in 0.00
+ 1) Skipped:
+ test_skip(#<Class:0xXXX>) [FILE:LINE]:
+ not yet
- 1) Skipped:
-test_skip(ATestCase) [FILE:LINE]:
-not yet
+ 2 tests, 1 assertions, 0 failures, 0 errors, 1 skips
+ EOM
-2 tests, 1 assertions, 0 failures, 0 errors, 1 skips
-"
- assert_report expected
+ assert_report expected, %w[--seed 42 --verbose]
end
def test_default_runner_is_minitest_unit
@@ -397,18 +357,15 @@ not yet
end
def test_run_with_other_runner
-
- runner = Class.new(MiniTest::Unit) do
- # Run once before each suite
- def _run_suite(suite, type)
- begin
- suite.before_suite
- super(suite, type)
- end
+ MiniTest::Unit.runner = Class.new MiniTest::Unit do
+ def _run_suite suite, type
+ suite.before_suite # Run once before each suite
+ super suite, type
end
- end
+ end.new
- tc = Class.new(MiniTest::Unit::TestCase) do
+ Class.new MiniTest::Unit::TestCase do
+ def self.name; "wacky!" end
def self.before_suite
MiniTest::Unit.output.puts "Running #{self.name} tests"
@@ -424,22 +381,15 @@ not yet
end
end
- Object.const_set(:ATestCase, tc)
- MiniTest::Unit.runner = runner.new
- @tu.run %w[--seed 42]
-
- # We should only see 'running ATestCase tests' once
- expected = "Run options: --seed 42
+ expected = clean <<-EOM
+ Running wacky! tests
+ ..
-# Running tests:
-
-Running ATestCase tests
-..
+ Finished tests in 0.00
-Finished tests in 0.00
+ 2 tests, 2 assertions, 0 failures, 0 errors, 0 skips
+ EOM
-2 tests, 2 assertions, 0 failures, 0 errors, 0 skips
-"
assert_report expected
end
@@ -455,7 +405,6 @@ Finished tests in 0.00
end
yield
-
ensure
Class.class_eval do
alias inherited inherited_without_hacks
@@ -478,7 +427,7 @@ Finished tests in 0.00
def test_before_setup
call_order = []
- Class.new(MiniTest::Unit::TestCase) do
+ Class.new MiniTest::Unit::TestCase do
define_method :setup do
super()
call_order << :setup
@@ -497,9 +446,31 @@ Finished tests in 0.00
assert_equal expected, call_order
end
+ def test_passed_eh_teardown_good
+ test_class = Class.new MiniTest::Unit::TestCase do
+ def teardown; assert true; end
+ def test_omg; assert true; end
+ end
+
+ test = test_class.new :test_omg
+ test.run @tu
+ assert test.passed?
+ end
+
+ def test_passed_eh_teardown_flunked
+ test_class = Class.new MiniTest::Unit::TestCase do
+ def teardown; flunk; end
+ def test_omg; assert true; end
+ end
+
+ test = test_class.new :test_omg
+ test.run @tu
+ refute test.passed?
+ end
+
def test_after_teardown
call_order = []
- Class.new(MiniTest::Unit::TestCase) do
+ Class.new MiniTest::Unit::TestCase do
define_method :teardown do
super()
call_order << :teardown
@@ -520,7 +491,7 @@ Finished tests in 0.00
def test_all_teardowns_are_guaranteed_to_run
call_order = []
- Class.new(MiniTest::Unit::TestCase) do
+ Class.new MiniTest::Unit::TestCase do
define_method :after_teardown do
super()
call_order << :after_teardown
@@ -548,91 +519,15 @@ Finished tests in 0.00
assert_equal expected, call_order
end
- def test_setup_hooks
- call_order = []
-
- tc = Class.new(MiniTest::Spec) do
- define_method :setup do
- super()
- call_order << :method
- end
-
- define_method :test2 do
- call_order << :test2
- end
-
- define_method :test1 do
- call_order << :test1
- end
- end
-
- tc.add_setup_hook lambda { call_order << :proc }
-
- argument = nil
-
- tc.add_setup_hook do |arg|
- argument = arg
- call_order << :block
- end
-
- @tu.run %w[--seed 42]
-
- assert_kind_of tc, argument
-
- expected = [:method, :proc, :block, :test1,
- :method, :proc, :block, :test2]
-
- assert_equal expected, call_order
- end
-
- def test_teardown_hooks
+ def test_setup_and_teardown_survive_inheritance
call_order = []
- tc = Class.new(MiniTest::Spec) do
- define_method :teardown do
- super()
- call_order << :method
- end
-
- define_method :test2 do
- call_order << :test2
- end
-
- define_method :test1 do
- call_order << :test1
- end
- end
-
- tc.add_teardown_hook lambda { call_order << :proc }
-
- argument = nil
-
- tc.add_teardown_hook do |arg|
- argument = arg
- call_order << :block
- end
-
- @tu.run %w[--seed 42]
-
- assert_kind_of tc, argument
-
- expected = [:test1, :block, :proc, :method,
- :test2, :block, :proc, :method]
-
- assert_equal expected, call_order
- end
-
- def test_setup_and_teardown_hooks_survive_inheritance
- call_order = []
-
- parent = Class.new(MiniTest::Spec) do
- define_method :setup do
- super()
+ parent = Class.new MiniTest::Spec do
+ before do
call_order << :setup_method
end
- define_method :teardown do
- super()
+ after do
call_order << :teardown_method
end
@@ -641,19 +536,12 @@ Finished tests in 0.00
end
end
- parent.add_setup_hook { call_order << :setup_hook }
- parent.add_teardown_hook { call_order << :teardown_hook }
-
_ = Class.new parent
- parent.add_setup_hook { call_order << :setup_after }
- parent.add_teardown_hook { call_order << :teardown_after }
-
@tu.run %w[--seed 42]
# Once for the parent class, once for the child
- expected = [:setup_method, :setup_hook, :setup_after, :test,
- :teardown_after, :teardown_hook, :teardown_method] * 2
+ expected = [:setup_method, :test, :teardown_method] * 2
assert_equal expected, call_order
end
@@ -683,7 +571,6 @@ class TestMiniTestUnitTestCase < MiniTest::Unit::TestCase
def teardown
assert_equal(@assertion_count, @tc._assertions,
"expected #{@assertion_count} assertions to be fired during the test, not #{@tc._assertions}") if @tc._assertions
- Object.send :remove_const, :ATestCase if defined? ATestCase
end
def test_assert
@@ -706,7 +593,7 @@ class TestMiniTestUnitTestCase < MiniTest::Unit::TestCase
def test_assert_block
exp = ["NOTE: MiniTest::Unit::TestCase#assert_block is deprecated,",
- "use assert. It will be removed on or after 2012-06-01."].join " "
+ "use assert. It will be removed on 2013-01-01."].join " "
out, err = capture_io do
@tc.assert_block do
@@ -1104,12 +991,14 @@ class TestMiniTestUnitTestCase < MiniTest::Unit::TestCase
end
end
- expected = "[RuntimeError] exception expected, not
-Class: <SyntaxError>
-Message: <\"icky\">
----Backtrace---
-FILE:LINE:in `test_assert_raises_triggered_different'
----------------"
+ expected = clean <<-EOM.chomp
+ [RuntimeError] exception expected, not
+ Class: <SyntaxError>
+ Message: <\"icky\">
+ ---Backtrace---
+ FILE:LINE:in `test_assert_raises_triggered_different'
+ ---------------
+ EOM
actual = e.message.gsub(/^.+:\d+/, 'FILE:LINE')
actual.gsub!(/block \(\d+ levels\) in /, '') if RUBY_VERSION >= '1.9.0'
@@ -1124,7 +1013,7 @@ FILE:LINE:in `test_assert_raises_triggered_different'
end
end
- expected = <<-EOM.gsub(/^ {6}/, '').chomp
+ expected = clean <<-EOM
XXX.
[RuntimeError] exception expected, not
Class: <SyntaxError>
@@ -1137,7 +1026,7 @@ FILE:LINE:in `test_assert_raises_triggered_different'
actual = e.message.gsub(/^.+:\d+/, 'FILE:LINE')
actual.gsub!(/block \(\d+ levels\) in /, '') if RUBY_VERSION >= '1.9.0'
- assert_equal expected, actual
+ assert_equal expected.chomp, actual
end
def test_assert_raises_triggered_none
@@ -1171,12 +1060,14 @@ FILE:LINE:in `test_assert_raises_triggered_different'
end
end
- expected = "[StandardError] exception expected, not
-Class: <AnError>
-Message: <\"AnError\">
----Backtrace---
-FILE:LINE:in `test_assert_raises_triggered_subclass'
----------------"
+ expected = clean <<-EOM.chomp
+ [StandardError] exception expected, not
+ Class: <AnError>
+ Message: <\"AnError\">
+ ---Backtrace---
+ FILE:LINE:in `test_assert_raises_triggered_subclass'
+ ---------------
+ EOM
actual = e.message.gsub(/^.+:\d+/, 'FILE:LINE')
actual.gsub!(/block \(\d+ levels\) in /, '') if RUBY_VERSION >= '1.9.0'
@@ -1255,14 +1146,14 @@ FILE:LINE:in `test_assert_raises_triggered_subclass'
end
def test_assert_throws
- @tc.assert_throws(:blah) do
+ @tc.assert_throws :blah do
throw :blah
end
end
def test_assert_throws_different
util_assert_triggered 'Expected :blah to have been thrown, not :not_blah.' do
- @tc.assert_throws(:blah) do
+ @tc.assert_throws :blah do
throw :not_blah
end
end
@@ -1270,7 +1161,7 @@ FILE:LINE:in `test_assert_raises_triggered_subclass'
def test_assert_throws_unthrown
util_assert_triggered 'Expected :blah to have been thrown.' do
- @tc.assert_throws(:blah) do
+ @tc.assert_throws :blah do
# do nothing
end
end
@@ -1315,21 +1206,13 @@ FILE:LINE:in `test_assert_raises_triggered_subclass'
assert_empty asserts.map { |n| n.sub(/^assert/, 'refute') } - refutes
end
- def test_class_inherited
- @assertion_count = 0
-
- Object.const_set(:ATestCase, Class.new(MiniTest::Unit::TestCase))
-
- assert_equal [ATestCase], MiniTest::Unit::TestCase.test_suites
- end
-
def test_class_test_suites
@assertion_count = 0
- Object.const_set(:ATestCase, Class.new(MiniTest::Unit::TestCase))
+ tc = Class.new(MiniTest::Unit::TestCase)
assert_equal 1, MiniTest::Unit::TestCase.test_suites.size
- assert_equal [ATestCase], MiniTest::Unit::TestCase.test_suites
+ assert_equal [tc], MiniTest::Unit::TestCase.test_suites
end
def test_expectation
@@ -1565,7 +1448,7 @@ FILE:LINE:in `test_assert_raises_triggered_subclass'
def test_test_methods_random
@assertion_count = 0
- sample_test_case = Class.new(MiniTest::Unit::TestCase) do
+ sample_test_case = Class.new MiniTest::Unit::TestCase do
def test_test1; assert "does not matter" end
def test_test2; assert "does not matter" end
def test_test3; assert "does not matter" end
@@ -1579,7 +1462,7 @@ FILE:LINE:in `test_assert_raises_triggered_subclass'
def test_test_methods_sorted
@assertion_count = 0
- sample_test_case = Class.new(MiniTest::Unit::TestCase) do
+ sample_test_case = Class.new MiniTest::Unit::TestCase do
def self.test_order; :sorted end
def test_test3; assert "does not matter" end
def test_test2; assert "does not matter" end
@@ -1613,7 +1496,7 @@ FILE:LINE:in `test_assert_raises_triggered_subclass'
end
def util_assert_triggered expected, klass = MiniTest::Assertion
- e = assert_raises(klass) do
+ e = assert_raises klass do
yield
end