Skip to content

Commit

Permalink
Merge pull request turn-project#38 from cameel/fix-minitest-run-monke…
Browse files Browse the repository at this point in the history
…ypatch-no-trace

Make Turn work with gems that monkey-patch MiniTest::Unit::TestCase.run()
  • Loading branch information
trans committed Jun 4, 2011
2 parents e65d213 + 8050407 commit c4314e7
Showing 1 changed file with 10 additions and 23 deletions.
33 changes: 10 additions & 23 deletions lib/turn/autorun/minitest.rb
Expand Up @@ -74,7 +74,7 @@ def run_test_suites(filter = /./)

@broken = nil

@@out.print(case inst.run(self)
@@out.print(case run_testcase(inst, self)
when :pass
@broken = false
green { pad_with_size "PASS" }
Expand Down Expand Up @@ -150,28 +150,15 @@ def puke(klass, meth, e)
result
end


class TestCase
# Overwrite #run method so that is uses symbols
# as return values rather than characters.
def run(runner)
result = :pass
begin
@passed = nil
self.setup
self.__send__ self.__name__
@passed = true
rescue Exception => e
@passed = false
result = runner.puke(self.class, self.__name__, e)
ensure
begin
self.teardown
rescue Exception => e
result = runner.puke(self.class, self.__name__, e)
end
end
result
private
# A wrapper over MiniTest::Unit::TestCase.run() that returns
# :pass whenever the test succeeds (i.e. run() returns "" or ".")
def run_testcase(testcase, runner)
original_result = testcase.run(runner)
if original_result == "" || original_result == "."
:pass
else
original_result
end
end
end
Expand Down

0 comments on commit c4314e7

Please sign in to comment.